Gmail + Google Sheets: inbox triage, logged clean
Your inbox fills up, you scan fast, and somehow the email you actually needed is buried under “quick question” newsletters and fake “following up” promos. It’s not just annoying. It creates mistakes, missed replies, and that constant low-grade stress of “Did I forget someone?”
Marketing managers feel it when leads go cold. Founders feel it at night when they’re still “catching up.” And support teams feel it when genuine requests get lost. This Gmail triage automation clears the noise, replies to real messages automatically, and keeps a clean log you can trust.
Below, you’ll see exactly how the workflow works, the outcomes you can expect, and what you need to run it without turning your email setup into a side project.
How This Automation Works
The full n8n workflow, from trigger to final output:
n8n Workflow Template: Gmail + Google Sheets: inbox triage, logged clean
flowchart LR
subgraph sg0["When clicking ‘Execute workflow’ Flow"]
direction LR
n0@{ icon: "mdi:message-outline", form: "rounded", label: "Delete a message", pos: "b", h: 48 }
n1@{ icon: "mdi:message-outline", form: "rounded", label: "Reply to a message", pos: "b", h: 48 }
n2@{ icon: "mdi:message-outline", form: "rounded", label: "Get many messages", pos: "b", h: 48 }
n3@{ icon: "mdi:database", form: "rounded", label: "Append or update row in sheet", pos: "b", h: 48 }
n4@{ icon: "mdi:database", form: "rounded", label: "Append or update row in sheet1", pos: "b", h: 48 }
n5@{ icon: "mdi:play-circle", form: "rounded", label: "When clicking ‘Execute workf..", pos: "b", h: 48 }
n6@{ icon: "mdi:message-outline", form: "rounded", label: "Email Trigger (IMAP)", pos: "b", h: 48 }
n7@{ icon: "mdi:robot", form: "rounded", label: "Message a model", pos: "b", h: 48 }
n8@{ icon: "mdi:swap-vertical", form: "rounded", label: "AI response formatter", pos: "b", h: 48 }
n9@{ icon: "mdi:swap-horizontal", form: "rounded", label: "categories emails", pos: "b", h: 48 }
n7 --> n8
n0 --> n3
n2 --> n7
n9 --> n0
n9 --> n1
n1 --> n4
n6 --> n7
n8 --> n9
n5 --> n2
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 n5 trigger
class n7 ai
class n9 decision
class n3,n4 database
The Problem: Inbox triage eats time (and focus)
Most inbox “systems” are really just you doing pattern recognition at speed. You skim the sender, the subject line, maybe the first sentence, then decide: delete, archive, reply, or “I’ll do it later.” Multiply that by a busy week and you’re spending hours on tiny decisions. Worse, you start hesitating. Is this actually marketing, or is it a real request disguised as one? One wrong click and you either lose a customer email, or you waste energy replying to junk. It’s exhausting because it never fully ends.
The friction compounds. And it shows up in very specific ways.
- You lose about 30–60 minutes a day just sorting and re-sorting messages that don’t deserve your attention.
- Real emails sit longer because the “quick deletes” keep interrupting your reply flow.
- Manual inbox work creates inconsistent handling, so two similar emails get two totally different outcomes.
- There’s no reliable audit trail, which matters the moment someone asks, “Did we respond to this?”
The Solution: AI-based Gmail triage with a Google Sheets log
This workflow watches your inbox, classifies each incoming email, and takes the right action automatically. When a message arrives (via an IMAP email listener, or by pulling from Gmail in bulk), it sends the sender, subject, and body to an AI model (Google Gemini in this build) to decide if it’s marketing or genuine. If it’s marketing, the workflow deletes it and records the email ID and subject in a “Deleted emails” tab in Google Sheets. If it’s not marketing, it generates a polite, tailored reply, sends that reply through Gmail, and logs the email ID and subject in a separate “Replied emails” tab. Simple outcome: less noise, faster follow-up, and a clean record of what happened.
The workflow starts with an inbox trigger, then uses AI to classify and draft. Finally, it routes the message down the right path (delete or reply) and logs the action to Google Sheets so you can review, audit, or improve your rules later.
What You Get: Automation vs. Results
| What This Workflow Automates | Results You’ll Get |
|---|---|
|
|
Example: What This Looks Like
Say your inbox gets about 50 emails a day. If even 30 of those are marketing, and you spend roughly 20 seconds deciding what to do with each, that’s around 10 minutes of pure “delete labor,” plus the context switching that comes with it. Add another 10–15 genuine emails where you spend about 5 minutes writing polite replies, and you’re near an hour daily. With this workflow, the “triage + first response” becomes a quick review task: maybe 5–10 minutes to sanity-check replies and scan the Google Sheets log, while the rest runs in the background.
What You’ll Need
- n8n instance (try n8n Cloud free)
- Self-hosting option if you prefer (Hostinger works well)
- Gmail for reading, deleting, and replying.
- Google Sheets to log deleted and replied emails.
- Google Gemini API key (get it from Google AI Studio / Google Cloud console).
Skill level: Intermediate. You’ll connect Google credentials, paste an API key, and test with a few real emails before turning it loose.
Don’t want to set this up yourself? Talk to an automation expert (free 15-minute consultation).
How It Works
A new email arrives (or you run a bulk cleanup). The IMAP Email Listener can trigger on incoming messages, and there’s also a Manual Start path that retrieves multiple emails when you want to process a backlog.
The message gets classified and a reply is prepared. Gemini reviews the sender, subject, and body to decide “marketing vs not marketing,” and it also returns a suggested response for genuine emails. A formatting step then pulls the key values out of the AI output so the next routing decision is reliable.
The workflow routes the email to the correct action. A switch routes marketing emails to Gmail deletion, while non-marketing emails go to a Gmail reply action using the generated text.
Everything is logged to Google Sheets. Deleted emails get written to a “Deleted emails” tab and replied emails to a “Replied emails” tab, each capturing Email ID and subject so you can audit what happened later.
You can easily modify the categories (beyond just marketing vs non-marketing) to include things like job applications, invoices, or customer support. See the full implementation guide below for customization options.
Step-by-Step Implementation Guide
Step 1: Configure the Manual Trigger
This workflow can be started manually or via IMAP monitoring. Configure both entry points so you can test manually and also listen for new inbox activity.
- Add the Manual Start Trigger node and leave default settings for manual testing.
- Add the IMAP Email Listener node to listen for incoming messages.
- Credential Required: Connect your IMAP Email credentials in IMAP Email Listener.
Step 2: Connect Gmail Retrieval
Set up the Gmail list action so the workflow can pull multiple emails for classification.
- Add the Retrieve Multiple Emails node connected from Manual Start Trigger.
- Set Operation to
getAll. - Set Limit to
2to fetch two emails per run. - Credential Required: Connect your Gmail OAuth2 credentials in Retrieve Multiple Emails.
Step 3: Set Up AI Classification
Use Gemini to classify emails as marketing or non-marketing and generate a reply message when needed.
- Add Gemini Classifier Prompt connected from both Retrieve Multiple Emails and IMAP Email Listener.
- Set Model to
models/gemini-2.5-flash. - Enable JSON Output by setting jsonOutput to
true. - Set the message prompt content to the full instruction block, including expressions like
{{ $json.Subject }},{{ $json.From }},{{ $json.snippet }}, and{{ $json.id }}. - Credential Required: Connect your Google Gemini credentials in Gemini Classifier Prompt.
- Add Format AI Output and map content.parts[0].text to
{{ $json.content.parts[0].text }}so downstream nodes can read structured fields.
true.Step 4: Configure Email Routing Logic
Route emails based on the AI’s isMarketing flag to either delete or reply.
- Add Route Email Category after Format AI Output.
- Configure a rule using Left Value
{{ $json.content.parts[0].text.isMarketing }}with a boolean Operation oftrue. - Add a second rule using the same Left Value with a boolean Operation of
false.
Step 5: Configure Gmail Actions and Logging
When marketing is detected, the email is deleted and logged; otherwise, the workflow replies and logs the response.
- Connect Route Email Category to Remove Email Message for the marketing path.
- In Remove Email Message, set Operation to
deleteand Message ID to{{ $json.content.parts[0].text.id }}. - Credential Required: Connect your Gmail OAuth2 credentials in Remove Email Message.
- Connect Remove Email Message to Update Deleted Log Sheet, and set Operation to
appendOrUpdate. - In Update Deleted Log Sheet, set Document ID to
[YOUR_ID]and Sheet Name todeleted emails. - Map columns to expressions: subject →
{{ $('Retrieve Multiple Emails').item.json.Subject }}and email id →{{ $('Retrieve Multiple Emails').item.json.From }}. - Credential Required: Connect your Google Sheets credentials in Update Deleted Log Sheet.
- Connect the non-marketing path to Send Reply Email, set Operation to
reply, Message ID to{{ $json.content.parts[0].text.id }}, and Message to{{ $json.content.parts[0].text.replyMessage }}. - Credential Required: Connect your Gmail OAuth2 credentials in Send Reply Email.
- Connect Send Reply Email to Update Reply Log Sheet, set Operation to
appendOrUpdate, Document ID to[YOUR_ID], and Sheet Name toreplied email. - Map columns to expressions: subject →
{{ $('Retrieve Multiple Emails').item.json.Subject }}and email id →{{ $('Retrieve Multiple Emails').item.json.From }}. - Credential Required: Connect your Google Sheets credentials in Update Reply Log Sheet.
[YOUR_ID] values for Document ID and Sheet Name or logging will fail.Step 6: Test and Activate Your Workflow
Validate routing, AI output, and logging before turning the workflow on.
- Click Execute Workflow from Manual Start Trigger to run a test cycle.
- Confirm that Gemini Classifier Prompt returns structured JSON and that Format AI Output exposes
content.parts[0].text. - Verify that marketing emails go to Remove Email Message and log to Update Deleted Log Sheet, while non-marketing emails go to Send Reply Email and log to Update Reply Log Sheet.
- Once successful, toggle the workflow to Active so IMAP Email Listener runs in production.
Common Gotchas
- Gmail credentials can expire or need specific permissions. If things break, check the Gmail node credential status in n8n (and your Google OAuth consent/permissions) 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.
- Gemini prompts that start generic tend to stay generic. Add examples of “real customer email vs marketing email” early, or you will keep tweaking the classifier after misroutes.
Frequently Asked Questions
About 30–60 minutes if your Google credentials and Sheet are ready.
No. You’ll mostly connect accounts, paste an API key, and tweak the AI prompt. The only “technical” part is testing with a few emails so routing feels safe.
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 Google Gemini API usage costs, which are usually small for basic classification and short replies.
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 it’s a smart move at first. Swap the Gmail “delete” action (the node that removes the email) for a Gmail “add label” action, then keep the Google Sheets logging as-is. Common tweaks include adding a third category like “customer support,” writing replies as drafts instead of sending, and logging more fields (sender, date, category) into new columns.
Usually it’s expired or revoked Google OAuth permissions in n8n, honestly. Reconnect the Gmail credential, then confirm the account has access to read, send, and modify messages. If it fails only sometimes, you may be hitting Gmail API rate limits when processing many emails at once, so reduce batch size or add a short wait between actions.
A few hundred a day is realistic on a small setup, and more if you tune batching and hosting. On n8n Cloud, capacity depends on your plan’s monthly executions. If you self-host, there’s no hard execution limit, but your server and Gmail API limits still apply. For bulk cleanup (like thousands of old emails), run it in batches and watch for rate limiting so you don’t get partial runs.
For inbox triage, n8n tends to win when you need branching logic, parsing, and “log everything” behavior in one flow. It’s also easier to self-host, which matters if your inbox volume is unpredictable. Zapier and Make are fine for simple “new email → add row” cases, but auto-classification plus conditional delete/reply gets messy fast. If you’re dealing with customer emails, you’ll also want tighter control over what gets sent automatically, which n8n handles well. Talk to an automation expert if you want help choosing the safest setup.
Once this is running, inbox cleanup stops being a daily job. You get quieter mornings, faster replies where it matters, and a simple spreadsheet record that settles the “what happened to that email?” question for good.
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.