Recipe Create Gmail Filter

by googleworkspacea3768d0e82adNo license31K starsListed Oct 8, 2026Updated Oct 8, 2026Repository updated yesterday

Create a Gmail filter to automatically label, star, or categorize incoming messages.

AI-generated overview

Creates a Gmail filter that labels, stars, or categorizes incoming messages via gws commands.

What it does
This recipe walks through setting up Gmail message automation using the gws command-line tool. It lists existing labels, creates a new label, creates a filter with criteria and actions such as adding a label or removing a message from the inbox, and then verifies the filter by listing filters. The deliverable is a configured Gmail label and filter rather than a file or document.
When to use it
Use it when you want incoming Gmail messages from particular senders or matching criteria to be labeled, starred, or sorted automatically. It suits setting up or checking mailbox organization rules through the gws tool.
Requirements
Requires the gws binary and the gws-gmail skill; it runs Gmail API commands against an authenticated account, so Gmail access and credentials are needed. It ships no scripts, only instructions.

Create a Gmail Filter

PREREQUISITE: Load the following skills to execute this recipe: gws-gmail

Create a Gmail filter to automatically label, star, or categorize incoming messages.

Steps

  1. List existing labels: gws gmail users labels list --params '{"userId": "me"}' --format table
  2. Create a new label: gws gmail users labels create --params '{"userId": "me"}' --json '{"name": "Receipts"}'
  3. Create a filter: gws gmail users settings filters create --params '{"userId": "me"}' --json '{"criteria": {"from": "[email protected]"}, "action": {"addLabelIds": ["LABEL_ID"], "removeLabelIds": ["INBOX"]}}'
  4. Verify filter: gws gmail users settings filters list --params '{"userId": "me"}' --format table

Source and attribution

Source:googleworkspace/cliinskills/recipe-create-gmail-filterat commita3768d0

License: No license

Content belongs to its original authors. SourceWeft indexes it from a public repository.

Report or request removal