⚡ Productivity
Gmail Filter Builder: Search Operator Queries, Nested Label Hierarchy, Filter Actions, Test Searches, and an Importable mailFilters.xml for a Shared Office Inbox
Turn a messy shared inbox into a set of Gmail filters that actually fire: a nested label plan, one tested search query per mail stream using real Gmail operators, the exact filter action checkboxes for each, a safety pass that protects important senders, and an importable mailFilters.xml with import steps.
0Reviews
Prompt
Act as an email operations specialist who builds Gmail filters for small offices and shared mailboxes. You write every filter as a search query first, test it against real mail, and only then attach actions. Inputs: - Who uses the mailbox and what the mail is about: [MailboxOwner] - The kinds of mail that arrive, with sender addresses, domains, and subject patterns: [MailStreams] - The label structure wanted, or current labels to clean up: [LabelPlan] - What should happen to each stream (stay in inbox, skip inbox, star, mark read, forward, never spam): [Actions] - Senders or keywords that must never be archived or deleted: [ProtectedSenders] - Personal Gmail or Google Workspace, and which forwarding addresses are verified: [AccountType] - Output format: [Format] Generate: 1. A nested label hierarchy from LabelPlan using Parent/Child labels, two levels deep at most, with a naming convention. 2. One Gmail search query per stream in MailStreams using operators such as from:, to:, list:, subject:, has:attachment, filename:, larger:, OR, braces for OR groups, quotes for exact phrases, and a minus sign for exclusions. Say why each operator is there. 3. For each query, the filter actions from Actions using Gmail's checkbox names: Skip the Inbox (Archive it), Mark as read, Star it, Apply the label, Forward it to, Delete it, Never send it to Spam, Always mark it as important, Never mark it as important, Categorize as. 4. A safety pass against ProtectedSenders: add exclusions to every archiving filter, never pair Delete it with a broad query, and note that filters act on mail as it arrives, so operators like older_than: belong in cleanup searches, not filters. 5. A test procedure: run each query in the search bar, check the matches, create the filter from that search, and decide whether to tick Also apply filter to matching conversations. 6. An importable mailFilters.xml in the Atom format Gmail exports, one entry per filter, with the import steps under Settings, Filters and Blocked Addresses. Flag any forwarding filter whose address is not verified in AccountType. Constraints: - Only use operators Gmail supports. Do not invent senders or domains beyond those given. - No em dashes.
Instructions
Replace every [bracket] with your details before running. Works on ChatGPT, Claude, and Gemini.
Generated Output
This image was generated using the prompt above.

Examples
Example Input
MailboxOwner: front office of a three building apartment management company; two staff share office@maplerowpm.example on Google Workspace MailStreams: (1) rent payment notices from notifications@payportal.example, subjects start with Payment received; (2) maintenance requests from forms@maplerowpm.example, subject Work Order #; (3) PDF invoices from billing@cleanpro.example and ar@greenlawn.example; (4) newsletters and webinar invites from propsoft.example and leasingwebinars.example; (5) code enforcement notices from codeenforcement.maple.example LabelPlan: Rent, Maintenance, Vendors/Invoices, Vendors/Newsletters, City Actions: rent notices skip inbox and mark read; work orders stay in inbox and get a star; invoices labeled and forwarded to bookkeeping@maplerowpm.example; newsletters skip inbox; city mail never spam and always important ProtectedSenders: the city domain, and any message mentioning eviction or court AccountType: Workspace, bookkeeping address verified Format: labels, queries with actions, safety notes, XML
Example Output
Labels
Rent, Maintenance, Vendors/Invoices, Vendors/Newsletters, City. Keep top level names short so they sort cleanly in the sidebar.
Filters
F1 Rent: from:notifications@payportal.example subject:"Payment received" -{eviction court}
Why: sender plus exact subject phrase; the exclusion keeps legal mentions in the inbox. Actions: Skip the Inbox, Mark as read, Apply the label Rent.
F2 Work orders: from:forms@maplerowpm.example subject:"Work Order"
Actions: Star it, Apply the label Maintenance. No archiving, so requests stay visible.
F3 Invoices: from:{billing@cleanpro.example ar@greenlawn.example} has:attachment filename:pdf
Why: braces make an OR group; has:attachment plus filename:pdf skips reminder emails with no invoice. Actions: Apply the label Vendors/Invoices, Forward it to bookkeeping@maplerowpm.example.
F4 Newsletters: from:{propsoft.example leasingwebinars.example} -{eviction court invoice}
Actions: Skip the Inbox, Apply the label Vendors/Newsletters.
F5 City: from:codeenforcement.maple.example
Actions: Apply the label City, Never send it to Spam, Always mark it as important.
Safety pass
- F1 and F4 archive mail, so both exclude eviction and court. F4 also excludes invoice in case a vendor bills through its newsletter address.
- No filter uses Delete it.
- older_than: is left out of filters. For cleanup, search label:vendors-newsletters older_than:6m and archive by hand.
Test
Paste each query into the search bar, scan the first page of results, then use Create filter from the search options. Tick Also apply filter to matching conversations for F2, F3, and F5 only. For F1 and F4, check the results first so no old legal notice gets archived.
mailFilters.xml
<?xml version='1.0' encoding='UTF-8'?>
<feed xmlns='http://www.w3.org/2005/Atom' xmlns:apps='http://schemas.google.com/apps/2006'>
<title>Mail Filters</title>
<entry><category term='filter'/><title>Mail Filter</title><content/>
<apps:property name='from' value='notifications@payportal.example'/>
<apps:property name='subject' value='"Payment received"'/>
<apps:property name='doesNotHaveTheWord' value='eviction OR court'/>
<apps:property name='label' value='Rent'/>
<apps:property name='shouldArchive' value='true'/>
<apps:property name='shouldMarkAsRead' value='true'/></entry>
<entry><category term='filter'/><title>Mail Filter</title><content/>
<apps:property name='from' value='codeenforcement.maple.example'/>
<apps:property name='label' value='City'/>
<apps:property name='shouldNeverSpam' value='true'/>
<apps:property name='shouldAlwaysMarkAsImportant' value='true'/></entry>
</feed>
Add F2 to F4 as entries in the same pattern. Import: Settings, See all settings, Filters and Blocked Addresses, Import filters, choose the file, Open file, Create filters. The bookkeeping address is verified, so F3 can forward.