recipe-label-and-archive-emails
googleworkspace/cli
Apply Gmail labels to matching messages and archive them to keep your inbox clean.
What is recipe-label-and-archive-emails?
This recipe automates Gmail organization by searching for messages matching specific criteria, applying custom labels, and archiving them. Use it to automatically sort and remove emails from your inbox based on sender, subject, or other filters.
- Search Gmail for messages matching custom query criteria
- Apply custom labels to matching messages
- Archive messages by removing them from the inbox
- Batch process multiple emails with a single workflow
- Keep inbox focused by automatically organizing notifications and low-priority mail
How to install recipe-label-and-archive-emails
npx skills add null --skill recipe-label-and-archive-emails- gws-gmail skill installed and configured
- Google Workspace account with Gmail access
- gws CLI tool installed and authenticated
How to use recipe-label-and-archive-emails
- 1.Search for emails matching your criteria using gws gmail users messages list with a query filter (e.g., from:notifications@service.com)
- 2.Note the MESSAGE_ID values from the search results
- 3.Create or identify the LABEL_ID for the label you want to apply
- 4.Use gws gmail users messages modify to add the label to each message
- 5.Use gws gmail users messages modify again to remove the INBOX label, archiving the message
- 6.Repeat for additional messages or automate with a script for batch processing
Use cases
- Automatically label and archive notification emails from services to reduce inbox clutter
- Sort emails from specific senders into labeled folders while removing them from inbox view
- Organize promotional or marketing emails with a label and archive them systematically
- Create a workflow to handle recurring email patterns without manual intervention
- Maintain inbox zero by automatically processing emails matching defined rules
- Gmail users managing high email volume
- Productivity-focused professionals seeking inbox automation
- Teams using Google Workspace for email management
- Anyone wanting to reduce manual email organization tasks
recipe-label-and-archive-emails FAQ
Use gws gmail users labels list to retrieve all labels and their IDs for your account.
Yes, you can include multiple label IDs in the addLabelIds array when modifying a message.
No, archiving only removes the email from your inbox view. It remains in your Gmail account and can be found via search or in the All Mail folder.
Yes, you can re-add the INBOX label to a message using the same modify command with addLabelIds set to INBOX.
Create a script that runs the search and modify commands on a schedule, or use Gmail filters in combination with this recipe for automated labeling.
Full instructions (SKILL.md)
Source of truth, from googleworkspace/cli.
name: recipe-label-and-archive-emails description: "Apply Gmail labels to matching messages and archive them to keep your inbox clean." metadata: version: 0.22.5 openclaw: category: "recipe" domain: "productivity" requires: bins: - gws skills: - gws-gmail
Label and Archive Gmail Threads
PREREQUISITE: Load the following skills to execute this recipe:
gws-gmail
Apply Gmail labels to matching messages and archive them to keep your inbox clean.
Steps
- Search for matching emails:
gws gmail users messages list --params '{"userId": "me", "q": "from:notifications@service.com"}' --format table - Apply a label:
gws gmail users messages modify --params '{"userId": "me", "id": "MESSAGE_ID"}' --json '{"addLabelIds": ["LABEL_ID"]}' - Archive (remove from inbox):
gws gmail users messages modify --params '{"userId": "me", "id": "MESSAGE_ID"}' --json '{"removeLabelIds": ["INBOX"]}'
Related skills
More from googleworkspace/cli and the wider catalog.
gws-gmail
Send, read, and manage Gmail emails via Google Workspace CLI.
gws-drive
Manage Google Drive files, folders, and shared drives via CLI.
gws-docs
Read and write Google Docs via command line.
gws-calendar
Manage Google Calendar events, calendars, and access control via CLI.
gws-sheets
Read and write Google Sheets spreadsheets via CLI.
gws-gmail-send
Send emails via Gmail with attachments, CC/BCC, HTML support, and draft options.