n8n + n8n: AI Email Triage — Gmail Auto-Classifier & Draft Generator
Every unread email is a micro-decision waiting to be made: is this urgent, does it need a reply, can it wait, is it noise? A founder or ops lead handling 80–150 messages a day burns 60–90 minutes just
Every unread email is a micro-decision waiting to be made: is this urgent, does it need a reply, can it wait, is it noise? A founder or ops lead handling 80–150 messages a day burns 60–90 minutes just triaging — before writing a single meaningful response. The cost isn't the reading time. It's the context-switching, the deferred replies that rot in the inbox, and the genuinely urgent message buried under three newsletters and a calendar invite.
The real problem: triage is the bottleneck, not writing
Most "email productivity" advice attacks the wrong step. Templates, snippets, and canned responses speed up writing — but writing is fast once you know what a message is and what it needs. The expensive part is the classification pass your brain runs on every single email: sorting sales from support, urgent from ignorable, needs-reply from FYI. That pass doesn't scale, it can't be delegated cheaply, and it happens dozens of times a day whether you want it to or not.
The second failure mode is latency on the messages that actually matter. A hot lead, a payment failure, a churning customer — these get the same queue position as a LinkedIn digest. By the time you scroll to them, hours have passed. For a busy team, a single missed urgent email can cost far more than the entire month of triage time combined.
The solution: an AI layer that reads before you do
This template puts GPT-4o in front of your inbox. The moment a new email lands in Gmail, the workflow reads it, classifies it into a category (urgent, sales, support, personal, newsletter, spam), drafts a professional reply in your voice, and — if it's flagged urgent — fires a Slack notification with the sender, subject, and a one-line summary. All of this completes before you open your inbox in the morning.
You still stay in control. The AI doesn't send anything. It writes the draft straight into Gmail as a real draft on the thread, so replying becomes a five-second review-and-send instead of a from-scratch composition. The classification lets you batch: knock out all the "sales" drafts in one sitting, ignore the "newsletter" bucket entirely, and never miss an "urgent" flag because Slack already told you.
Step-by-step: building it in n8n
The workflow is roughly seven nodes. Here's how it fits together.
1. Gmail Trigger node. Set the event to Message Received and configure the poll interval to every minute (or use Gmail push via a webhook if you want near-instant reaction). Point it at your primary inbox and, optionally, filter to the label INBOX and is:unread so you don't reprocess old mail. This node outputs the message ID, thread ID, sender, subject, and body.
2. A Set (Edit Fields) node to normalize the payload. Extract from, subject, and a trimmed snippet or full text body into clean variables. Cap the body at ~4,000 characters here to control token cost and avoid feeding huge signature threads to the model.
3. The OpenAI node (or the AI Agent node with an OpenAI Chat Model) set to gpt-4o. This is the brain. Use a system prompt that pins the output to strict JSON, for example:
"You are an email triage assistant. Given the sender, subject, and body, return JSON with exactly these keys: category (one of: urgent, sales, support, personal, newsletter, spam), urgency_score (0-10), summary (one sentence), and draft_reply (a professional reply in a warm, concise tone; empty string if no reply is needed)."
Set the temperature low (0.2–0.3) for consistent classification and enable JSON mode / Response Format: JSON Object so parsing never breaks. Pass the sender, subject, and body from step 2 into the user message.
4. A JSON parse / Set node to pull category, urgency_score, summary, and draft_reply out of the model response into first-class fields. If you used JSON mode, this is trivial; add a small Function node fallback that catches malformed output and defaults category to support so nothing gets dropped.
5. A Gmail node — Create Draft. Use the Draft resource, set the thread ID from step 1 so the draft attaches to the original conversation, and map draft_reply into the message body. Only run this when draft_reply is non-empty — a short IF node before it skips newsletters and spam.
6. An IF (or Switch) node on urgency. Route to the Slack branch when category === "urgent" or urgency_score >= 8. Everything else ends the run silently.
7. A Slack node — Send Message. Post to your #inbox-urgent channel with a formatted block: 🚨 *Urgent from {{sender}}* — {{subject}}\n{{summary}}\nDraft ready in Gmail. Include a link to the Gmail thread so you're one click from acting.
Wire it linearly: Gmail Trigger → Set → OpenAI → Parse → IF(has draft) → Gmail Create Draft, with a parallel branch off the parse node into IF(urgent) → Slack. Activate the workflow and it runs 24/7.
What you actually get out of it
Triage time collapses. Instead of reading everything, you scan a pre-sorted inbox where every actionable email already has a draft attached. The 60–90 minute triage tax drops to a 15-minute review-and-send pass.
Urgent never slips. The Slack ping decouples critical messages from inbox position. A payment failure or hot lead reaches you in under a minute, on the channel you're already watching, with enough context to decide instantly.
Replies get faster and more consistent. GPT-4o drafts in a professional, on-brand tone, so even your quick replies read well. You edit rather than compose — which for most people is a 5–10x speedup on response writing.
It compounds. Feed the categories into a spreadsheet or dashboard and within a week you have data on where your inbox load actually comes from — which lets you fix the source (a support flow, an FAQ, a routing rule) instead of just processing symptoms.
Common pitfalls (and how to dodge them)
Don't let it auto-send. The temptation is to skip the draft step and reply automatically. Resist it. GPT-4o is excellent at drafting but occasionally misreads intent, and one wrong auto-reply to a client erases all the trust the system built. Keep a human on the send button.
Guard against reprocessing loops. If your trigger isn't filtered to unread mail, the draft you create can re-trigger the workflow. Filter on is:unread, or add a Gmail label like triaged at the end of each run and exclude it in the trigger.
Control token cost. Long forwarded threads with full quote history can balloon your prompt to tens of thousands of tokens. Truncate the body in the Set node and strip quoted replies before hitting the model — this cuts your OpenAI bill by more than half on a busy inbox.
Force structured output. The single most common breakage is the model returning prose instead of JSON, which crashes the parse node. Always enable JSON response format, keep temperature low, and add a fallback default so a malformed response degrades gracefully instead of halting the whole run.
Watch classification drift. Review the "spam" and "newsletter" buckets for the first few days — the model can be overconfident and bin a real message. Once you trust the categories, tighten the prompt with two or three real examples from your own inbox to lock in accuracy.
Set this up once and it runs quietly in the background forever. The inbox stops being a decision machine you feed all day, and becomes a queue that's already sorted, drafted, and flagged by the time you sit down.
Ja construimos isso pra voce
Nao comece do zero. O AI Email Triage — Gmail Auto-Classifier & Draft Generator e um workflow n8n pronto para instalar — conecta suas ferramentas em minutos, sem codigo.
Instalar por $49 →