$npx -y skills add googleworkspace/cli --skill recipe-create-gmail-filterCreate a Gmail filter to automatically label, star, or categorize incoming messages.
| 1 | # Create a Gmail Filter |
| 2 | |
| 3 | > **PREREQUISITE:** Load the following skills to execute this recipe: `gws-gmail` |
| 4 | |
| 5 | Create a Gmail filter to automatically label, star, or categorize incoming messages. |
| 6 | |
| 7 | ## Steps |
| 8 | |
| 9 | 1. List existing labels: `gws gmail users labels list --params '{"userId": "me"}' --format table` |
| 10 | 2. Create a new label: `gws gmail users labels create --params '{"userId": "me"}' --json '{"name": "Receipts"}'` |
| 11 | 3. Create a filter: `gws gmail users settings filters create --params '{"userId": "me"}' --json '{"criteria": {"from": "receipts@example.com"}, "action": {"addLabelIds": ["LABEL_ID"], "removeLabelIds": ["INBOX"]}}'` |
| 12 | 4. Verify filter: `gws gmail users settings filters list --params '{"userId": "me"}' --format table` |