How to Build an AI Inbox Triage Agent with n8n (Step by Step)
The short answer
An AI inbox triage agent is a workflow that watches your inbox, asks an LLM to classify each new email (urgent, needs reply, FYI, newsletter, spam-ish), applies a Gmail label, and drafts a reply when one is needed. In n8n this takes four nodes: a Gmail trigger, an AI Agent or LLM node, a Gmail label node, and a Gmail draft node.
What you need
You need an n8n instance (n8n Cloud or self-hosted), a Gmail account connected with OAuth, and an API key for an LLM provider.
- n8n (Cloud or self-hosted on a VPS)
- Gmail OAuth credential in n8n
- An LLM API key (any provider n8n supports)
Step 1: Trigger on new email
Add a Gmail Trigger node set to poll for new messages. Filter out anything already labeled so the agent never processes the same thread twice.
Step 2: Classify with an LLM
Pass the sender, subject, and the first part of the body to an LLM node. Ask for strict JSON: a category, a priority from 1 to 3, and whether a reply is needed. Strict JSON keeps the next nodes simple and makes failures easy to spot.
Step 3: Label and draft
Use a Switch node on the category to apply the matching Gmail label. For emails that need a reply, generate a short draft and save it with the Gmail 'create draft' operation. Never auto-send in v1; drafts keep a human in the loop.
Step 4: Daily digest
Add a Schedule Trigger that runs each morning, collects yesterday's priority-1 emails and open drafts, and emails you a one-screen summary.
Want the full version?
The full Inbox Triage Agent template adds editable label rules, an offline sample run with tests, honest cost-per-run notes, a Python + AGENTS.md version for Claude Code or Cursor, and a changelog.
Related
- Template: Inbox Triage Agent
- Tool: n8n
- Tool: Hostinger VPS (n8n hosting)
FAQ
Can n8n read and label Gmail?
Yes. n8n has a Gmail trigger and Gmail node that can read messages, add labels, and create drafts using an OAuth credential.
Is it safe to let an AI agent handle my inbox?
Keep it to labeling and drafting, not sending. Review drafts before they go out, and limit what the LLM sees to what it needs.
Agent Drop: the weekly newsletter
One new agent template, one tool worth using, three links. Free, weekly.