Gmail + Gemini: cleaner inbox, ready draft replies
Your inbox is probably lying to you. Important threads are buried under newsletters, “quick questions” that aren’t quick, and random notifications that look urgent until you open them.
Freelancers feel it when client replies slip. Small business owners feel it when sales leads go cold. And if you run marketing, it’s the follow-up pile that quietly gets you. This Gmail Gemini automation cleans the noise and prepares drafts, so you spend your time answering the right messages.
You’ll set up an n8n workflow that labels new emails, moves obvious junk out of sight, and creates ready-to-review reply drafts inside Gmail. Nothing gets sent automatically. You stay in control.
How This Automation Works
Here’s the complete workflow you’ll be setting up:
n8n Workflow Template: Gmail + Gemini: cleaner inbox, ready draft replies
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: "Structured Output Parser", pos: "b", h: 48 }
n2@{ icon: "mdi:message-outline", form: "rounded", label: "RemoveLabel", pos: "b", h: 48 }
n3@{ icon: "mdi:message-outline", form: "rounded", label: "AddLabel", pos: "b", h: 48 }
n4@{ icon: "mdi:message-outline", form: "rounded", label: "TrashMessage", pos: "b", h: 48 }
n5@{ icon: "mdi:message-outline", form: "rounded", label: "GetThread", pos: "b", h: 48 }
n6@{ icon: "mdi:message-outline", form: "rounded", label: "CheckSent", pos: "b", h: 48 }
n7@{ icon: "mdi:brain", form: "rounded", label: "Gemini", pos: "b", h: 48 }
n8@{ icon: "mdi:swap-horizontal", form: "rounded", label: "IF Delete", pos: "b", h: 48 }
n9@{ icon: "mdi:swap-horizontal", form: "rounded", label: "IF Response", pos: "b", h: 48 }
n10@{ icon: "mdi:message-outline", form: "rounded", label: "Create a draft", pos: "b", h: 48 }
n11@{ icon: "mdi:message-outline", form: "rounded", label: "GetThread1", pos: "b", h: 48 }
n12@{ icon: "mdi:location-exit", form: "rounded", label: "CheckCalendar", pos: "b", h: 48 }
n13@{ icon: "mdi:robot", form: "rounded", label: "Structured Output Parser1", pos: "b", h: 48 }
n14@{ icon: "mdi:robot", form: "rounded", label: "AI Email Classifier", pos: "b", h: 48 }
n15@{ icon: "mdi:robot", form: "rounded", label: "AI Draft Maker", pos: "b", h: 48 }
n7 -.-> n14
n7 -.-> n15
n3 --> n9
n6 -.-> n14
n5 -.-> n14
n8 --> n4
n8 --> n3
n11 -.-> n15
n9 --> n15
n2 --> n14
n12 -.-> n15
n0 --> n2
n15 --> n10
n14 --> n8
n1 -.-> n14
n13 -.-> n15
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 trigger
class n1,n13,n14,n15 ai
class n7 aiModel
class n8,n9 decision
Why This Matters: Inbox triage steals your best hours
Inbox “management” usually means micro-decisions all day long. Is this spam or a real person? Is it actionable or just noise? Do you need to reply now, or later, or not at all? Those little calls don’t feel heavy, but they add up fast, especially when you’re switching between tabs, threads, and half-remembered context from last week. Miss one key email and you pay for it twice: once in the awkward follow-up, and again in the scramble to rebuild trust.
None of these alone is the problem. Together, they are.
- You re-read the same email thread just to remember what was agreed, because the context is scattered across replies and sent messages.
- Labels get messy or inconsistent, so “sorting” becomes another task you don’t trust.
- Low-value emails stay visible, which means they keep stealing attention every time you open Gmail.
- Drafting replies takes longer than it should because you start from a blank page instead of a solid first draft.
What You’ll Build: Gmail labeling plus safe AI reply drafts
This workflow starts the moment a new email hits your Gmail inbox. n8n grabs the message, clears any existing labels you don’t want on incoming mail, then hands the content to a Gemini-powered classification agent that reads the email like a human would. It checks context too, pulling in the email thread and even your sent history when needed, so it understands if this is a new request, a follow-up, or something you already handled. Based on your rules, it applies the right Gmail label, and if the message is clearly irrelevant, it can route it toward deletion or out of your way. When an email needs a response, the workflow generates a concise, professional draft reply and saves it in Gmail Drafts for you to review. It never auto-sends.
It’s basically inbox triage with memory. Gmail triggers it, Gemini decides what matters, and Gmail drafts hold the output until you approve it.
What You’re Building
| What Gets Automated | What You’ll Achieve |
|---|---|
|
|
Expected Results
Say you receive about 40 emails a day. If you spend even 2 minutes per email deciding what it is and where it belongs, that’s roughly 80 minutes gone, before you write a single reply. Add 10 more emails that need responses, and drafting at about 5 minutes each is another 50 minutes. With this workflow, labeling and “needs response” decisions happen automatically, and drafting runs in the background. Your active time becomes reviewing maybe 10 drafts, which is often 20 minutes total.
Before You Start
- n8n instance (try n8n Cloud free)
- Self-hosting option if you prefer (Hostinger works well)
- Gmail for inbox access, labels, and drafts.
- Google Gemini to classify emails and draft replies.
- Google OAuth2 credentials (create them in Google Cloud Console).
Skill level: Beginner. You’ll connect accounts, confirm labels exist, and paste in prompts.
Want someone to build this for you? Talk to an automation expert (free 15-minute consultation).
Step by Step
A new Gmail email arrives. The Gmail Trigger watches your inbox and kicks off the workflow the moment a message lands.
The message gets normalized and prepared. n8n parses key fields (sender, subject, body) into structured data and clears any labels you don’t want lingering on fresh mail.
Gemini classifies it with real context. The workflow can fetch the email thread and review your sent history, then the AI Agent decides the right label and whether it should be archived or trashed based on your rules.
Drafts are created only when needed. If the message requires a response, the Reply Drafting Agent generates a short, friendly draft and the Gmail node saves it to Drafts so you can tweak and send.
You can easily modify the labeling categories to match your pipeline (leads, clients, finance, hiring) 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 Gmail trigger that watches for new incoming messages.
- Add the Incoming Gmail Watch node as your trigger.
- Set the polling schedule to
everyMinutein Poll Times. - Credential Required: Connect your
gmailOAuth2credentials. - Leave Filters empty unless you want to restrict which emails are watched.
Step 2: Connect Gmail and Calendar Services
Ensure all Gmail and Calendar nodes used by the agents and actions are authenticated.
- Credential Required: Connect your
gmailOAuth2credentials to Clear Inbox Labels, Apply Gmail Label, Move to Trash, and Generate Reply Draft. - For tool access, Fetch Email Thread, Review Sent History, and Fetch Thread Context are connected as tools for AI agents; ensure Gmail OAuth2 credentials are available to the parent nodes (Email Classification Agent and Reply Drafting Agent).
- Credential Required: Connect your
googleCalendarOAuth2Apicredentials for the tool node Calendar Availability Check (used by Reply Drafting Agent).
Step 3: Set Up Email Classification Agent
Configure the AI classification stage that determines labeling, deletion, and whether a response is needed.
- Add Gemini Chat Model and connect it as the language model for Email Classification Agent and Reply Drafting Agent. Credential Required: Connect your
googlePalmApicredentials to Gemini Chat Model. - In Email Classification Agent, keep Prompt Type set to
defineand ensure the prompt includes your label rules and placeholders (e.g.,[YOUR_EMAIL]and label IDs). - Attach Structured JSON Parser as the output parser with the schema set to
{ "label": "Label name", "labelID": "Label ID", "id": "Email message ID", "requiresResponse": true }. - Confirm the tool connections: Fetch Email Thread and Review Sent History are linked as tools to Email Classification Agent.
⚠️ Common Pitfall: Update placeholder values like [YOUR_EMAIL], [INPUT LABEL 1], and [INPUT LABEL 2] in Email Classification Agent before testing, or the model may return unusable labels.
Step 4: Configure Reply Drafting Agent
Set up the drafting logic that creates a draft reply when a response is required.
- In Reply Drafting Agent, keep Prompt Type set to
defineand verify the prompt rules for tone, language detection, and scheduling. - Attach Draft JSON Parser as the output parser with schema
{ "draft": "string", "notes": "string" }. - Ensure tool connections are present: Fetch Thread Context and Calendar Availability Check are linked as tools to Reply Drafting Agent.
- In Calendar Availability Check, confirm Calendar is set to
[YOUR_EMAIL]and Timezone is set to[YOUR_TIMEZONE].
⚠️ Common Pitfall: Replace [YOUR_TIMEZONE] and [YOUR_NAME] in Reply Drafting Agent to avoid incorrect scheduling suggestions and signatures.
Step 5: Configure Output and Routing Logic
Define how emails are labeled, trashed, or drafted based on AI classification outputs.
- In Clear Inbox Labels, set Operation to
removeLabels, Message ID to={{ $json.id }}, and include label IDs likeINBOX,IMPORTANT, and category labels. - In Deletion Decision, set the condition to compare
={{ $json.output.label }}equalsDELETE. The true branch goes to Move to Trash, and the false branch goes to Apply Gmail Label. - In Move to Trash, set Operation to
addLabels, Label IDs toTRASH, and Message ID to={{ $('Incoming Gmail Watch').item.json.id }}. - In Apply Gmail Label, set Operation to
addLabels, Label IDs to={{ $json.output.labelID }}, and Message ID to={{ $('Incoming Gmail Watch').item.json.id }}. - In Response Requirement Check, set the condition to true when
={{ $('Email Classification Agent').item.json.output.requiresResponse }}istrue. - In Generate Reply Draft, set Resource to
draft, Message to={{ $json.output.draft }}, Subject to=Re: {{ $('Incoming Gmail Watch').item.json.Subject }}, and Send To to={{ $('Incoming Gmail Watch').item.json.From }}.
Tip: The execution flow is linear: Incoming Gmail Watch → Clear Inbox Labels → Email Classification Agent → Deletion Decision. From there, emails either go to Move to Trash or Apply Gmail Label, and only those requiring a response proceed to Reply Drafting Agent and Generate Reply Draft.
Step 6: Test and Activate Your Workflow
Validate that classification, labeling, and drafting behave as expected before turning the workflow on.
- Click Execute Workflow and send a test email to the connected Gmail account.
- Confirm that Clear Inbox Labels removes existing labels and that Email Classification Agent outputs valid JSON via Structured JSON Parser.
- Verify that emails labeled
DELETEmove to trash, while others get labels from Apply Gmail Label. - For emails requiring a reply, check that Generate Reply Draft creates a draft with subject prefix
Re:and body from{{$json.output.draft}}. - Once validated, switch the workflow to Active to run continuously.
Troubleshooting Tips
- Gmail credentials can expire or need specific permissions. If things break, check your n8n Credentials for Google OAuth2 first, then confirm Gmail scopes are allowed.
- 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 Gmail labels already exist.
No. You’ll connect Gmail and Gemini, then adjust a few rules and prompts.
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 Gemini usage costs, which depend on how many emails you process and how long they are.
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 should. Most people customize the labels in the Gmail steps (like “Apply Gmail Label”) and adjust the instructions inside the Email Classification Agent so it matches how you actually work. You can also change what happens after “Deletion Decision” to archive instead of trashing, which is safer early on. If you want meeting suggestions, enable the Calendar Availability Check so the draft can include a couple of time slots.
Usually it’s expired Google OAuth2 credentials or missing Gmail permissions in the consent/scopes setup. Reconnect the Gmail credential in n8n, then re-run a single test email. If it still fails, check that the Gmail account you authorized is the same one receiving the trigger emails and that your workspace admin (if you have one) hasn’t restricted OAuth access.
A typical small business inbox volume is fine, and the practical limit is your n8n plan plus how quickly your AI model responds.
Often, yes, if you care about smarter decision-making. This workflow leans on branching logic (the “Deletion Decision” and “Response Requirement Check”) and context fetching (threads and sent history), which is where n8n tends to feel more flexible. The other upside is control: drafts are created inside Gmail, not pushed out through external steps that are harder to review. Zapier or Make can be simpler for very basic “label this, then send a Slack message” automations, but they get awkward as soon as you want memory and multi-step reasoning. Talk to an automation expert if you want help picking the cleanest setup.
Once this is running, your inbox stops being a to-do list generator. It quietly sorts, flags what matters, and hands you drafts that are ready for a quick human pass.
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.