Gmail + Slack: urgent emails flagged, labels stay tidy
Your inbox is probably “organized” right up until the day it isn’t. One urgent customer thread hides behind newsletters, random CCs, and meeting logistics, and suddenly you’re reacting instead of working.
This Gmail Slack automation hits support leads first, honestly, but ops managers and agency owners feel it too. The outcome is simple: urgent emails get flagged and pushed to Slack, while everything else gets labeled automatically so you can stop babysitting Gmail.
Below you’ll see exactly what this workflow does, what you need to connect, and how the pieces fit together before you decide to implement it.
How This Automation Works
Here’s the complete workflow you’ll be setting up:
n8n Workflow Template: Gmail + Slack: urgent emails flagged, labels stay tidy
flowchart LR
subgraph sg0["Gmail Check Every 2 Min Flow"]
direction LR
n0["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/code.svg' width='40' height='40' /></div><br/>Extract and Clean Email Cont.."]
n1@{ icon: "mdi:brain", form: "rounded", label: "OpenAI Chat Model", pos: "b", h: 48 }
n2@{ icon: "mdi:robot", form: "rounded", label: "Structured Output Parser", pos: "b", h: 48 }
n3@{ icon: "mdi:robot", form: "rounded", label: "Classify and Extract Entities", pos: "b", h: 48 }
n4["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/code.svg' width='40' height='40' /></div><br/>Parse and Validate AI Response"]
n5@{ icon: "mdi:swap-horizontal", form: "rounded", label: "Check Classification Success", pos: "b", h: 48 }
n6@{ icon: "mdi:swap-horizontal", form: "rounded", label: "Route by Category", pos: "b", h: 48 }
n7@{ icon: "mdi:message-outline", form: "rounded", label: "Label: Inquiry", pos: "b", h: 48 }
n8@{ icon: "mdi:message-outline", form: "rounded", label: "Label: Support Request", pos: "b", h: 48 }
n9@{ icon: "mdi:message-outline", form: "rounded", label: "Label: Newsletter", pos: "b", h: 48 }
n10@{ icon: "mdi:message-outline", form: "rounded", label: "Label: Marketing", pos: "b", h: 48 }
n11@{ icon: "mdi:message-outline", form: "rounded", label: "Label: Personal", pos: "b", h: 48 }
n12@{ icon: "mdi:message-outline", form: "rounded", label: "Label: Urgent", pos: "b", h: 48 }
n13@{ icon: "mdi:message-outline", form: "rounded", label: "Label: Spam", pos: "b", h: 48 }
n14@{ icon: "mdi:message-outline", form: "rounded", label: "Label: Invoice/Receipt", pos: "b", h: 48 }
n15@{ icon: "mdi:message-outline", form: "rounded", label: "Label: Meeting Request", pos: "b", h: 48 }
n16@{ icon: "mdi:database", form: "rounded", label: "Log All Emails", pos: "b", h: 48 }
n17@{ icon: "mdi:swap-horizontal", form: "rounded", label: "Check if High Priority or Ur..", pos: "b", h: 48 }
n18["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/slack.svg' width='40' height='40' /></div><br/>Send Urgent Email Alert"]
n19@{ icon: "mdi:database", form: "rounded", label: "Log Classification Errors", pos: "b", h: 48 }
n20@{ icon: "mdi:play-circle", form: "rounded", label: "Gmail Check Every 2 Min", pos: "b", h: 48 }
n13 --> n16
n12 --> n16
n7 --> n16
n11 --> n16
n10 --> n16
n9 --> n16
n1 -.-> n3
n6 --> n7
n6 --> n8
n6 --> n9
n6 --> n10
n6 --> n11
n6 --> n12
n6 --> n13
n6 --> n14
n6 --> n15
n14 --> n16
n15 --> n16
n8 --> n16
n20 --> n0
n2 -.-> n3
n5 --> n6
n5 --> n19
n3 --> n4
n4 --> n5
n4 --> n17
n0 --> n3
n17 --> n18
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 n20 trigger
class n2,n3 ai
class n1 aiModel
class n5,n6,n17 decision
class n16,n19 database
class n0,n4 code
classDef customIcon fill:none,stroke:none
class n0,n4,n18 customIcon
Why This Matters: Inbox triage steals your best hours
Most inbox stress isn’t caused by “too much email.” It’s the constant sorting. You scan subject lines, open messages “just in case,” decide what to do, then forget where you put it. And when something truly urgent shows up, it looks exactly like the five things you already postponed. That mental load is sneaky. It eats the first hour of your day, breaks your focus, and makes you slower at the work you’re actually paid to do.
It adds up fast. Here’s where it breaks down in real teams.
- Urgent requests get buried because “unread” is not a priority system.
- Manual labeling is inconsistent, so the same type of email ends up scattered across your inbox.
- You spend about 1–2 hours a day re-reading emails just to remember what matters.
- Nothing gets logged, which means you can’t review patterns, volume, or recurring senders when problems keep repeating.
What You’ll Build: AI email labeling with urgent Slack alerts
This workflow watches your Gmail inbox every couple minutes for unread messages. When a new email lands, it cleans up the messy HTML (so the content is readable), then sends the important parts to an AI agent for classification and entity extraction. The AI returns a structured result that is parsed into clean JSON, validated, and checked for quality before anything touches your inbox. Once the category is confirmed, n8n routes the message through a nine-way sorter (Inquiry, Support, Newsletter, Marketing, Personal, Urgent, Spam, Invoice, Meeting) and applies the right Gmail label automatically. Finally, every email gets recorded to Google Sheets for tracking, and truly urgent messages trigger a Slack alert so you see them immediately.
The workflow starts with a Gmail trigger, then runs AI classification with a structured parser to keep outputs predictable. After that, routing applies the correct label, logging happens in Google Sheets, and high-priority items get pushed into Slack so you can react fast without living in Gmail.
What You’re Building
| What Gets Automated | What You’ll Achieve |
|---|---|
|
|
Expected Results
Say your team gets about 40 emails a day in a shared inbox. Manually sorting and labeling even 1 minute per email is roughly 40 minutes, and urgent ones still slip through when you’re heads-down. With this workflow, the “work” is basically zero: Gmail gets checked every 2 minutes, labeling happens automatically, and urgent items post to Slack as they arrive. You’ll still read and respond, but you stop spending about an hour just organizing.
Before You Start
- n8n instance (try n8n Cloud free)
- Self-hosting option if you prefer (Hostinger works well)
- Gmail to monitor unread emails and apply labels.
- Slack to receive urgent email alerts.
- OpenAI API key (get it from the OpenAI dashboard) or another LLM provider supported in your setup.
Skill level: Intermediate. You’ll connect accounts, paste an API key, and adjust categories without writing much code.
Want someone to build this for you? Talk to an automation expert (free 15-minute consultation).
Step by Step
A new unread email arrives. The Gmail trigger polls your inbox every 2 minutes and pulls in the subject, sender, and message content for anything unread.
The email gets cleaned up. A sanitizing step strips noisy HTML so signatures, tracking junk, and weird formatting don’t confuse the classifier.
AI categorizes the message. The AI agent (using an OpenAI chat model in this template) classifies the email and extracts entities, then a structured output parser converts that result into predictable JSON that can be validated.
Labels, logs, and alerts happen automatically. n8n routes the email to the correct category, applies the Gmail label, records the event in Google Sheets, and sends a Slack alert if the message is flagged as high priority.
You can easily modify the nine categories to match your business (or route to a different Slack channel) based on your needs. See the full implementation guide below for customization options.
Step-by-Step Implementation Guide
Step 1: Configure the Gmail Trigger
Start by setting up the workflow trigger that polls unread Gmail messages on a schedule.
- Add and open Gmail Poll Trigger.
- Set Filters → Read Status to
unread. - Set Poll Times to
everyMinute. - Credential Required: Connect your Gmail credentials (Google OAuth) to Gmail Poll Trigger.
Step 2: Connect Google Sheets
Configure the two Sheets nodes to log classified emails and classification errors.
- Open Record All Emails and select the target spreadsheet in Document, then set Sheet Name to
Sheet1. - Verify the column mappings include values like
{{ $json.subject }},{{ $json.category }}, and{{ $json.actionItemsJson }}. - Credential Required: Connect your googleSheetsOAuth2Api credentials to Record All Emails.
- Open Record Classification Errors and set Sheet Name to
Error Log. - Credential Required: Connect your googleSheetsOAuth2Api credentials to Record Classification Errors.
Step 3: Set Up AI Classification and Parsing
Configure the AI agent, language model, and structured parser that classify and extract entities from emails.
- Open Categorize and Pull Entities and set Text to
Sender: {{ $json.senderName }} ({{ $json.senderEmail }})\nSubject: {{ $json.subject }}\nBody: {{ $json.bodyText }}. - In OpenAI Conversation Model, set Model to
gpt-4.1-mini, Max Tokens to1500, and Temperature to0.2. - Open Structured Result Parser and confirm the JSON Schema Example matches your desired fields (category, priority, sentiment, entities, actionItems, summary).
- Credential Required: Connect your OpenAI credentials to OpenAI Conversation Model.
- Note: Structured Result Parser is an AI tool sub-node; credentials should be added to OpenAI Conversation Model, not the parser.
Step 4: Configure Processing and Validation Logic
Clean the email payload, validate AI results, and route valid classifications.
- Open Sanitize Email Payload and keep the JavaScript logic that extracts
messageId,senderEmail,subject, and abodyTextlimited to 3000 characters. - Open Validate AI Output and keep Mode as
runOnceForEachItemto enforce valid categories, priorities, and sentiments. - Open Verify Classification Result and ensure the condition checks
{{ $json.classificationValid }}is true. - Open Route by Email Category and confirm the rules compare
{{ $json.category }}to values likeInquiry,Support Request, andUrgent.
Validate AI Output outputs to both Verify Classification Result and Flag High Priority in parallel.
Step 5: Configure Output and Notification Actions
Apply Gmail labels, record results, and send urgent alerts to Slack.
- For each Gmail label node (Apply Label: Inquiry, Apply Label: Support, Apply Label: Newsletter, Apply Label: Marketing, Apply Label: Personal, Apply Label: Urgent, Apply Label: Spam, Apply Label: Invoice, Apply Label: Meeting), set Operation to
addLabelsand Message ID to{{ $('Sanitize Email Payload').first().json.messageId }}. - Credential Required: Connect your Gmail credentials (Google OAuth) to all Gmail label nodes.
- Open Flag High Priority and ensure conditions include
{{ $json.priority }} = High,{{ $json.category }} = Urgent, or{{ $json.sentiment }} = Urgent. - Open Send Urgent Slack Alert and keep Text as the multi-line template starting with
🚨 *URGENT EMAIL ALERT*. - Credential Required: Connect your Slack credentials to Send Urgent Slack Alert and select the target Channel.
Each label node routes into Record All Emails, ensuring all classified emails are logged after labeling.
Step 6: Add Error Handling
Invalid AI outputs are captured and recorded for review.
- In Verify Classification Result, ensure the false output is connected to Record Classification Errors.
- Confirm Record Classification Errors maps fields like
{{ $json.classificationError }}and{{ $json.bodyText.substring(0, 500) }}for quick troubleshooting.
Step 7: Test and Activate Your Workflow
Run a controlled test to verify labeling, logging, and alerts before turning it on.
- Manually execute Gmail Poll Trigger with a sample unread email in your inbox.
- Check that labels are applied in Gmail and that a new row appears in Record All Emails.
- If you send a high-priority email, confirm Send Urgent Slack Alert posts the formatted message.
- For invalid or malformed AI results, verify that Record Classification Errors logs the issue.
- Once validated, toggle the workflow to Active for continuous automation.
Troubleshooting Tips
- Gmail credentials can expire or need specific permissions. If things break, check your n8n Gmail credential connection test and Google account security settings 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.
Quick Answers
About 30 minutes if your accounts and API key are ready.
No. You’ll mostly connect credentials and tweak categories, with optional small edits to prompts and validation.
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 day for normal inbox volume.
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 you probably should. You can change the nine-way “Route by Email Category” switch to add or remove categories, then duplicate or delete the matching “Apply Label” Gmail nodes. Common tweaks include adding a “Refund” category, routing “Invoices” to accounting, and sending “Support” to a dedicated Slack channel while leaving newsletters silent.
Usually it’s expired OAuth access or the wrong Gmail permissions. Reconnect your Gmail credential inside n8n, then confirm the trigger can read unread messages and the labeling nodes can modify labels. If it works for a while and then fails, check Google account security prompts and token revocations. Also watch for inbox rules moving messages out of “unread” before the poll runs.
A few hundred emails per day is realistic for most setups.
It depends on how strict you want the classification to be. This workflow uses AI with structured parsing, validation, and a multi-branch router, which n8n handles cleanly without turning into a maze of paid steps. You also get self-hosting as an option, which matters once you’re processing lots of emails. Zapier and Make can work, but complex branching plus AI steps tends to get expensive and harder to debug. If you want help choosing, Talk to an automation expert.
Once this is running, your inbox stops being a to-do list you have to rebuild every morning. Urgent emails surface in Slack, everything else gets labeled, and you stay in control without hovering over Gmail.
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.