Gmail + OpenAI: inbox triage that labels and archives
Your inbox isn’t “busy.” It’s noisy, demanding, and weirdly good at hiding the one email that actually matters. You open Gmail, scan subject lines, mark a few as unread “for later,” and somehow 20 minutes disappears.
Gmail inbox triage hits hardest when your work depends on fast context switching. A startup founder feels it in the morning. An operations manager feels it all day. A team lead feels it when a “small request” turns into a fire drill. This workflow gives you a clean, priority-driven inbox without babysitting it.
You’ll see how the automation reads new unread emails, classifies them with OpenAI using the Eisenhower Matrix, applies the right Gmail label, and archives the low-value stuff automatically.
How This Automation Works
The full n8n workflow, from trigger to final output:
n8n Workflow Template: Gmail + OpenAI: inbox triage that labels and archives
flowchart LR
subgraph sg0["Gmail Flow"]
direction LR
n0@{ icon: "mdi:play-circle", form: "rounded", label: "Gmail Trigger", pos: "b", h: 48 }
n1@{ icon: "mdi:robot", form: "rounded", label: "AI Email Classifier", pos: "b", h: 48 }
n2@{ icon: "mdi:brain", form: "rounded", label: "OpenAI GPT-4", pos: "b", h: 48 }
n3@{ icon: "mdi:message-outline", form: "rounded", label: "Label: Not Urgent + Important", pos: "b", h: 48 }
n4@{ icon: "mdi:message-outline", form: "rounded", label: "Label: Urgent + Important", pos: "b", h: 48 }
n5@{ icon: "mdi:message-outline", form: "rounded", label: "Label: Urgent + Not Important", pos: "b", h: 48 }
n6@{ icon: "mdi:message-outline", form: "rounded", label: "Label: Not Urgent + Not Impo..", pos: "b", h: 48 }
n7@{ icon: "mdi:message-outline", form: "rounded", label: "Archive Email", pos: "b", h: 48 }
n8@{ icon: "mdi:play-circle", form: "rounded", label: "Manual Test Trigger", pos: "b", h: 48 }
n9@{ icon: "mdi:message-outline", form: "rounded", label: "Batch Process Emails", pos: "b", h: 48 }
n10@{ icon: "mdi:swap-horizontal", form: "rounded", label: "Filter Valid Emails", pos: "b", h: 48 }
n2 -.-> n1
n0 --> n1
n1 --> n4
n1 --> n3
n1 --> n5
n1 --> n6
n10 --> n1
n8 --> n9
n9 --> n10
n6 --> n7
end
%% Styling
classDef trigger fill:#e8f5e9,stroke:#388e3c,stroke-width:2px
classDef ai fill:#e3f2fd,stroke:#1976d2,stroke-width:2px
classDef aiModel fill:#e8eaf6,stroke:#3f51b5,stroke-width:2px
classDef decision fill:#fff8e1,stroke:#f9a825,stroke-width:2px
classDef database fill:#fce4ec,stroke:#c2185b,stroke-width:2px
classDef api fill:#fff3e0,stroke:#e65100,stroke-width:2px
classDef code fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px
classDef disabled stroke-dasharray: 5 5,opacity: 0.5
class n0,n8 trigger
class n1 ai
class n2 aiModel
class n10 decision
The Problem: Email Triage Becomes a Daily Tax
Most inboxes fail the same way. The urgent messages don’t look urgent until you open them, and by then you’ve already been dragged into five other threads. Promotions, newsletters, “quick questions,” status updates, receipts. They all arrive wearing the same outfit, which means your brain has to do the sorting every single time. That decision fatigue is real, and it shows up as missed deadlines, slow replies to the right people, and a constant low-grade feeling that you’re behind.
It adds up fast. Here’s where it breaks down in practice.
- You end up re-reading the same emails because you didn’t decide what they meant the first time.
- Important but non-urgent threads get buried, so strategic work keeps slipping into “someday.”
- Time-sensitive but delegable requests still land on you, because nothing flags them as “hand this off.”
- Low-value noise stays visible, which makes you check email more often than you should.
The Solution: Eisenhower Labels Applied Automatically in Gmail
This workflow turns your Gmail inbox into a live priority system. When a new unread email arrives (or when you run a batch cleanup manually), n8n pulls the message content and sends it through an OpenAI-powered classifier. That classifier uses the Eisenhower Matrix, so every email becomes one of four categories: Urgent + Important, Not Urgent + Important, Urgent + Not Important, or Not Urgent + Not Important. n8n then applies the matching Gmail label automatically. If the email is low priority, it also gets archived, so it stops stealing attention the moment it lands.
The workflow starts with a Gmail trigger watching your inbox. OpenAI makes the judgment call based on your prompt and the email context. Finally, Gmail labels are applied, and low-priority messages are moved out of sight so your inbox stays focused.
What You Get: Automation vs. Results
| What This Workflow Automates | Results You’ll Get |
|---|---|
|
|
Example: What This Looks Like
Say you get about 60 emails a day and you spend maybe 30 seconds deciding what each one is. That’s roughly 30 minutes of pure sorting, before you even do the work. With this workflow, the “sorting” becomes automatic: the trigger runs in the background, OpenAI classifies in moments, and Gmail labels land immediately. You’ll still read the important ones, but you stop burning half an hour on deciding what to ignore.
What You’ll Need
- n8n instance (try n8n Cloud free)
- Self-hosting option if you prefer (Hostinger works well)
- Gmail to read, label, and archive messages
- OpenAI to classify urgency and importance
- OpenAI API key (get it from your OpenAI dashboard)
Skill level: Intermediate. You’ll connect Gmail OAuth and paste an API key, then update Gmail label IDs inside the workflow once.
Don’t want to set this up yourself? Talk to an automation expert (free 15-minute consultation).
How It Works
A new email arrives (or you run a cleanup batch). The Gmail trigger monitors unread messages, and there’s also a manual start path that can pull a batch of emails for a first-time “inbox reset.”
Only valid email records get processed. A filter step checks that the pulled items look like real emails, which prevents odd edge cases from wasting runs.
OpenAI decides what matters. The AI classifier reads the email text and assigns one of the four Eisenhower categories, based on the prompt you provide and the context inside the message.
Gmail is updated automatically. The workflow applies the matching label. If it’s “Not Urgent + Not Important,” it also archives it so it’s out of your working inbox.
You can easily modify which senders are included and what “urgent” means for your business based on your needs. See the full implementation guide below for customization options.
Step-by-Step Implementation Guide
Step 1: Configure the Gmail Trigger
Set up the workflow to listen for new inbox emails in Gmail so they can be classified and labeled automatically.
- Add the Inbox Watch Trigger node and open its settings.
- Set Poll Times to
everyMinute. - Keep Simple set to
false. - Credential Required: Connect your gmailOAuth2 credentials.
Step 2: Connect Gmail for Batch Retrieval
Enable manual batch processing for testing or backfilling unread emails before relying on the trigger alone.
- Add the Manual Execution Start node to start batch runs.
- Connect Manual Execution Start to Retrieve Batch Emails.
- In Retrieve Batch Emails, set Operation to
getAll. - Set Limit to
5and Simple tofalse. - Under Filters, set Label IDs to
INBOXand Read Status tounread. - Credential Required: Connect your gmailOAuth2 credentials.
Step 3: Validate Email Records Before AI Classification
Filter out records that do not contain email text so the AI classifier receives clean input.
- Add the Validate Email Records node after Retrieve Batch Emails.
- Configure the condition to check that Left Value is
{{ $json.text }}with the Exists operator. - Connect Validate Email Records to AI Priority Sorter.
text field, the classifier will return empty results. Ensure your Gmail data includes parsed message content.Step 4: Set Up AI Classification with OpenAI
Configure the classifier to categorize each email using the Eisenhower Matrix prompt and categories.
- Open AI Priority Sorter and set Input Text to
{{ $json.text }}. - Use the provided System Prompt Template describing Eisenhower Matrix classification.
- Ensure the four categories are defined:
Urgent + Important,Not Urgent + Important,Urgent + Not Important, andNot Urgent + Not Important. - Confirm that OpenAI Chat Engine is connected as the language model for AI Priority Sorter.
- Credential Required: Connect your openAiApi credentials in OpenAI Chat Engine (add credentials to the parent node, not the classifier).
Step 5: Configure Gmail Labeling and Archiving Actions
Apply priority labels based on AI categories and archive low-priority emails for inbox hygiene.
- Connect AI Priority Sorter to all four label nodes for priority routing.
- Set Message ID to
{{ $json.id }}in each label node: Apply Label: Urgent & Key, Apply Label: Important Later, Apply Label: Urgent Delegate, and Apply Label: Low Priority. - Set Operation to
addLabelsin each label node. - Replace
[YOUR_ID]in Label IDs with your actual Gmail label IDs in each label node. - Connect Apply Label: Low Priority to Archive Low Priority and set Operation to
removeLabels. - In Archive Low Priority, set Label IDs to
INBOX,CATEGORY_PERSONAL,CATEGORY_FORUMS,CATEGORY_PROMOTIONS,CATEGORY_SOCIAL, andCATEGORY_UPDATES. - Credential Required: Connect your gmailOAuth2 credentials to all Gmail action nodes (labeling and archiving).
[YOUR_ID] in label nodes will cause Gmail API errors. Replace with actual label IDs before testing.AI Priority Sorter outputs to Apply Label: Urgent & Key, Apply Label: Important Later, Apply Label: Urgent Delegate, and Apply Label: Low Priority in parallel.
Step 6: Test and Activate Your Workflow
Run a manual test to validate classification and Gmail actions, then activate for continuous inbox monitoring.
- Click Execute Workflow and use Manual Execution Start to test batch retrieval.
- Verify that Validate Email Records passes emails with
{{ $json.text }}and that AI Priority Sorter returns one of the four categories. - Confirm Gmail labels are applied by the appropriate label node and that Archive Low Priority removes inbox categories for low-priority emails.
- Enable the workflow and confirm Inbox Watch Trigger processes new incoming emails every minute.
Common Gotchas
- Gmail credentials can expire or need specific permissions. If things break, check the Gmail OAuth connection in your n8n Credentials list first.
- If you’re using Wait nodes or external rendering, processing times vary. Bump up the wait duration if downstream nodes fail on empty responses.
- Default prompts in AI nodes are generic. Add your brand voice early or you’ll be editing outputs forever.
Frequently Asked Questions
About 30 minutes once your Gmail labels are created.
No. You’ll connect Gmail and OpenAI, then paste label IDs into the Gmail steps.
Yes. n8n has a free self-hosted option and a free trial on n8n Cloud. Cloud plans start at $20/month for higher volume. You’ll also need to factor in OpenAI API costs, which are usually a few cents per batch of emails depending on volume and model.
Two options: n8n Cloud (managed, easiest setup) or self-hosting on a VPS. For self-hosting, Hostinger VPS is affordable and handles n8n well. Self-hosting gives you unlimited executions but requires basic server management.
Yes, and it’s a common tweak. You can add a filter before the AI Priority Sorter to only allow specific senders or domains through, then route everything else to a default label. Some teams also change the prompt examples so certain clients always classify as “Urgent + Important,” while newsletters automatically go to “Not Urgent + Not Important.”
Usually it’s expired OAuth credentials or a permission scope issue. Reconnect Gmail in n8n, then confirm the workflow is using the correct credential entry on every Gmail action (labeling and archiving included). If it only fails sometimes, you may be hitting Gmail API limits during batch runs, so reduce the batch size or space out executions.
A typical setup can handle hundreds of emails a day without issues, and self-hosting scales mostly with your server and API limits.
It depends, but n8n is often the better fit for AI-based routing like this. You get more control over the prompt and the branching logic without paying extra for every path, and you can self-host for unlimited executions if volume climbs. Zapier and Make can absolutely do email labeling, but the moment you want richer classification, batch processing, or custom fallbacks, the costs and complexity show up fast. If you want, Talk to an automation expert and we’ll sanity-check the best option for your inbox and volume.
Your inbox stops being a to-do list written by other people. The workflow handles the repetitive triage so you can focus on the emails that actually move work forward.
Need Help Setting This Up?
Our automation experts can build and customize this workflow for your specific needs. Free 15-minute consultation—no commitment required.