Build: AI Email Inbox Manager
An inbox that sorts, labels, archives, drafts, and forwards itself — the workflow most builders end up running on their own inbox every single day, and a template that maps directly onto any client with a high-volume shared inbox (support, sales, ops).
What we're building, and why
A new email arrives. AI reads it and assigns one category — Promotions, Social, Personal, Sales, or Miscellaneous. A Switch node routes it down the matching path, where it's labeled and archived out of the primary inbox automatically. Personal emails get an AI-drafted reply waiting in Drafts; sales emails get forwarded to whoever owns that pipeline. The result: an inbox where only the things that actually need a human ever show up unread.
Trigger: new Gmail message
Add trigger → Gmail → On Message Received. This is a polling trigger (see Layer 00), so set the poll interval to something realistic — once an hour is enough for most inboxes and keeps you well under execution limits. Turn Simplify off so the node returns the full email body, not just a 50-character snippet — you need the whole message to classify it accurately.
Pin one test email while you build so you aren't waiting on real inbox traffic every time you run the workflow.
Classify with AI
Add OpenAI → Message a Model with two messages: a system message (the instructions) and a user message (the email itself).
SYSTEM:
You are an intelligent assistant trained to analyze and sort incoming
emails. Categorize each email using exactly one of the following:
- promotions — offers, discounts, marketing blasts
e.g. "50% off our new course", "Amazon deals you might like"
- social — social network notifications
- personal — a direct message from an individual
- sales — a sales inquiry or lead
- misc — anything that doesn't clearly fit the above
Respond with only the category name.
USER:
From: {{ $json.from }}
Subject: {{ $json.subject }}
Body: {{ $json.text }}
Give every category two or three concrete examples in the prompt — a model told what counts
classifies dramatically more reliably than one just given a bare label. The classification result
lands in the node's output at message.content[0].text.
platform.openai.com under API keys, with a minimum $5 balance loaded
under Billing.
Route with a Switch
Add a Switch node with five routing rules, matching the AI's output field against each category using "string contains" — not "equals." A model that returns "category: promotions" instead of a bare "promotions" will silently fail to match an exact-equals condition, and that failure is invisible unless you go looking for it.
Label & archive each path
On the Promotions, Social, and Misc branches, chain two Gmail actions:
- Add label to a message — create matching Gmail labels ahead of time (Gmail's own labels list refreshes after you create one, so re-open the dropdown if it isn't showing yet), and pass in the message ID from the trigger.
- Remove label from a message — remove the built-in
INBOXlabel so the email disappears from the primary view without being deleted.
Drag the same two-action pattern onto multiple branches when they should behave identically — you don't need to rebuild it per branch.
Auto-draft personal replies
On the Personal branch, add another OpenAI → Message a Model call with the sender, subject, and body as input, and a system prompt like:
You are an expert at replying to incoming emails. Write a polished,
warm response. Rules:
1. Never invent placeholder variables like [Name] — write real text only.
2. Sign every email "Best, {{Your Name}}".
Feed the result into Gmail → Create Draft, not Send — pass in the
original threadId so the draft attaches to the existing conversation instead of
starting a new one. Run this for at least a few weeks reviewing drafts before you ever let a
workflow send client-facing email unattended.
Forward sales leads
On the Sales branch, add Gmail → Send a message to whoever owns that inbox, subject prefixed "Fwd:", body containing the original message text. This is the entire "route inbound leads to the right teammate" workflow — no AI required once classification has already happened upstream.
Test & activate
Send yourself one test email per category (a "promotions"-flavored subject, a "personal" note, a "sales inquiry"), re-pin the trigger's output after each, and confirm each one lands in the correct Gmail label with the correct downstream action before activating the workflow live.
Variations worth selling
- Add an "accounting" branch that forwards invoice-looking emails straight to a bookkeeper.
- Log every incoming task-shaped email as a new row in a project tracker.
- Swap the single classifier call for an AI agent once you need it to take multiple actions per email rather than one fixed action per category.
Sources
| Source | Used for |
|---|---|
| Jono Catliff (Automatable), "n8n 8 Hour Masterclass — Build & Sell AI Agents (Automate Anything)" | Primary source for this build's workflow steps |
| n8n docs, Gmail node | Polling trigger, labeling, archiving, drafting |
| n8n docs, Switch node | Routing by AI-assigned category |