Gmail + Google Sheets: labeled emails and reply drafts
Your inbox is not the problem. The constant context-switching is. You read an email, decide what it is, label it, maybe draft a reply, then try to remember if you logged it anywhere (and most days, you don’t).
This Gmail Sheets automation hits support leads first, but sales teams and busy operators feel it too. You get consistent labels, AI-assisted reply drafts, and a clean Google Sheets log so nothing important disappears into “I’ll handle it later.”
Below, you’ll see how the workflow routes each email, when it drafts replies, what gets tracked, and what you need to run it reliably.
How This Automation Works
See how this solves the problem:
n8n Workflow Template: Gmail + Google Sheets: labeled emails and reply drafts
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:message-outline", form: "rounded", label: "compliants label", pos: "b", h: 48 }
n2@{ icon: "mdi:message-outline", form: "rounded", label: "info label", pos: "b", h: 48 }
n3@{ icon: "mdi:message-outline", form: "rounded", label: "other label", pos: "b", h: 48 }
n4@{ icon: "mdi:robot", form: "rounded", label: "Mail Classifier", pos: "b", h: 48 }
n5@{ icon: "mdi:swap-vertical", form: "rounded", label: "Set 2", pos: "b", h: 48 }
n6@{ icon: "mdi:swap-vertical", form: "rounded", label: "Set 3", pos: "b", h: 48 }
n7@{ icon: "mdi:swap-vertical", form: "rounded", label: "Set 4", pos: "b", h: 48 }
n8@{ icon: "mdi:database", form: "rounded", label: "Google Sheets2", pos: "b", h: 48 }
n9@{ icon: "mdi:database", form: "rounded", label: "Google Sheets", pos: "b", h: 48 }
n10@{ icon: "mdi:cog", form: "rounded", label: "No Operation, do nothing", pos: "b", h: 48 }
n11@{ icon: "mdi:cog", form: "rounded", label: "No Operation, do nothing1", pos: "b", h: 48 }
n12@{ icon: "mdi:message-outline", form: "rounded", label: "Add label to thread", pos: "b", h: 48 }
n13@{ icon: "mdi:message-outline", form: "rounded", label: "Create a draft: Sales", pos: "b", h: 48 }
n14@{ icon: "mdi:message-outline", form: "rounded", label: "Add label to thread1", pos: "b", h: 48 }
n15@{ icon: "mdi:message-outline", form: "rounded", label: "Create a draft: Support", pos: "b", h: 48 }
n16@{ icon: "mdi:brain", form: "rounded", label: "OpenAI Chat Model", pos: "b", h: 48 }
n17@{ icon: "mdi:robot", form: "rounded", label: "Message a model: Support", pos: "b", h: 48 }
n18@{ icon: "mdi:robot", form: "rounded", label: "Message a model: Sales", pos: "b", h: 48 }
n21@{ icon: "mdi:swap-vertical", form: "rounded", label: "Set", pos: "b", h: 48 }
n22@{ icon: "mdi:swap-vertical", form: "rounded", label: "Set 1", pos: "b", h: 48 }
n21 --> n11
n22 --> n11
n5 --> n10
n6 --> n10
n7 --> n10
n2 --> n6
n3 --> n7
n0 --> n4
n4 --> n17
n4 --> n18
n4 --> n1
n4 --> n2
n4 --> n3
n1 --> n5
n16 -.-> n4
n13 --> n22
n18 --> n13
n18 --> n12
n15 --> n21
n17 --> n14
n17 --> n15
n10 --> n8
n11 --> n9
end
subgraph sg1["Error Flow"]
direction LR
n19@{ icon: "mdi:database", form: "rounded", label: "Append row in sheet", pos: "b", h: 48 }
n20@{ icon: "mdi:play-circle", form: "rounded", label: "Error Trigger", pos: "b", h: 48 }
n20 --> n19
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,n20 trigger
class n4,n17,n18 ai
class n16 aiModel
class n8,n9,n19 database
The Challenge: Inbox triage that eats your day
Most inbox “systems” fall apart the moment volume spikes. You might start the day with good intentions, then a handful of support threads, two sales leads, and one complaint email later, you’re making fast decisions with zero documentation. Labels get inconsistent. Reply quality drops because you’re rushing. And the real kicker is reporting: when someone asks “How many complaints did we get this week?” you’re guessing, or manually searching Gmail like it’s a database. It’s exhausting, and it quietly slows down revenue and retention.
The friction compounds. Here’s where it breaks down in real life.
- Emails get labeled differently by different people, which makes your Gmail filters and saved searches unreliable.
- Reply drafts live in someone’s head (or not at all), so response time slips the moment the day gets busy.
- You end up copying key details into a spreadsheet by hand, and the log is always behind.
- When automation does exist, it fails silently, so you only notice after a customer follows up.
The Fix: Classify emails, label them, draft replies, then log everything
This workflow watches for new emails in Gmail and immediately sorts each one into a practical category: Support, Sales, Complaints, Information, or Other. Once it knows what it’s looking at, it takes the next best action automatically. Support and Sales messages get labeled in Gmail and passed to OpenAI to generate a reply draft that you can quickly review and send. Complaints, Information, and Other still get labeled, but they don’t trigger a draft, so you’re not wasting time generating responses you won’t use. Every email (and every decision) is logged into Google Sheets, which means you finally have a simple, trustworthy record of what came in and how it was handled.
The workflow starts with a Gmail trigger, then an AI classifier decides the category. After that, Gmail labeling and (when relevant) OpenAI draft generation happen automatically, and Google Sheets captures both the “what” and the “why.”
What Changes: Before vs. After
| What This Eliminates | Impact You’ll See |
|---|---|
|
|
Real-World Impact
Say you get 30 inbound emails a day that actually need sorting. Manually, it’s easy to spend about 2 minutes per email deciding a category and labeling it (around an hour), plus another 5 minutes drafting replies for 10 support/sales emails (about 50 more minutes). With this workflow, categorization, labeling, and sheet logging happen automatically, and your “reply time” becomes reviewing drafts, maybe 1 minute each. That’s roughly an hour and a half back on a normal day.
Requirements
- n8n instance (try n8n Cloud free)
- Self-hosting option if you prefer (Hostinger works well)
- Gmail for monitoring, labeling, and drafting replies.
- Google Sheets to log decisions, outputs, and errors.
- OpenAI API key (get it from your OpenAI account dashboard).
Skill level: Intermediate. You’ll connect OAuth credentials, paste a Sheet ID, and confirm columns match.
Need help implementing this? Talk to an automation expert (free 15-minute consultation).
The Workflow Flow
A new Gmail email arrives. The workflow triggers as soon as Gmail receives a message that matches your monitoring settings, so it starts working before your team even opens the inbox.
The email gets classified. An AI text classifier reviews the email content and assigns it to one category: Support, Sales, Complaints, Information, or Other. That decision is also stored as data so it can be logged cleanly later.
Gmail actions happen based on the category. Complaints, Information, and Other get labeled right away. Support and Sales go further: the workflow calls OpenAI to generate a reply draft, then creates the draft in Gmail and applies the correct label to the thread.
Everything is logged to Google Sheets (plus errors). The workflow appends rows to a “Logs” sheet for processed emails and outputs, and it uses a dedicated error trigger to write failures into an “Errors” sheet with the node name, message, time, and execution details.
You can easily modify the categories to match your business (for example, split “Support” into Billing vs Technical) based on your needs. See the full implementation guide below for customization options.
Step-by-Step Implementation Guide
Step 1: Configure the Gmail Trigger
Set up the workflow to monitor unread inbox emails and pass them into the classification stage.
- Add and configure Incoming Gmail Monitor as the trigger for unread inbox messages.
- Set Label IDs to
INBOXand Read Status tounread. - Set the polling schedule to
everyMinuteunder Poll Times. - Credential Required: Connect your gmailOAuth2 credentials.
Step 2: Connect Gmail Actions
Apply labels and draft replies based on category outcomes. Since there are multiple Gmail action nodes, connect the same Gmail account across all of them.
- In Apply Complaint Tag, set Operation to
addLabels, set Message ID to{{ $('Incoming Gmail Monitor').item.json.id }}, and set Label IDs to your complaint label ID. - In Apply Info Tag, set Operation to
addLabels, set Message ID to{{ $('Incoming Gmail Monitor').item.json.id }}, and set Label IDs to your info label ID. - In Apply Other Tag, set Operation to
addLabels, set Message ID to{{ $('Incoming Gmail Monitor').item.json.id }}, and confirm Label IDs isUNREADor replace it with your label ID. - In Tag Sales Thread and Tag Support Thread, set Resource to
thread, Operation toaddLabels, and Thread ID to{{ $('Incoming Gmail Monitor').item.json.threadId }}. - In Draft Sales Response and Draft Support Response, set Resource to
draft, Subject to{{ $json.message.content.Subject }}, Message to{{ $json.message.content.Body }}, and set Send To to{{ $('Incoming Gmail Monitor').item.json.from.value[0].address }}with Thread ID set to{{ $('Incoming Gmail Monitor').item.json.threadId }}. - Credential Required: Connect your gmailOAuth2 credentials to all Gmail action nodes (7 nodes handle tagging and drafting).
[YOUR_ID] label placeholders with real Gmail label IDs, or labeling will silently fail.Step 3: Set Up AI Classification and Replies
Use the classifier to route emails and the OpenAI nodes to draft support and sales replies.
- Open Email Category Sorter and set Input Text to
Subject: {{ $('Incoming Gmail Monitor').item.json.subject }} Text: {{ $('Incoming Gmail Monitor').item.json.text }}. - Confirm the category list in Email Category Sorter includes
support,sales,complaints, andinformation, and keep Fallback asother. - Configure OpenAI Chat Engine with model
gpt-4.1-miniand connect it as the language model for Email Category Sorter. - In Generate Support Reply and Generate Sales Reply, keep JSON Output enabled and confirm the message templates contain the sender name expression
{{ $('Incoming Gmail Monitor').item.json.headers.from.replace(/^From:\s*/, '').match(/^(.*?)(?=\s*<)/)[1] }}and the email body{{ $('Incoming Gmail Monitor').item.json.text }}. - Credential Required: Connect your openAiApi credentials to OpenAI Chat Engine, Generate Support Reply, and Generate Sales Reply.
Step 4: Configure Routing, Decisions, and Parallel Actions
Map each category to set decisions, apply labels, and build output data for logging.
- Verify Email Category Sorter routes to Generate Support Reply, Generate Sales Reply, Apply Complaint Tag, Apply Info Tag, and Apply Other Tag according to the classifier outputs.
- Ensure Generate Support Reply outputs to both Tag Support Thread and Draft Support Response in parallel.
- Ensure Generate Sales Reply outputs to both Draft Sales Response and Tag Sales Thread in parallel.
- In Set Support Decision, set Decision to
Sales, Subject_email to{{ $('Generate Support Reply').item.json.message.content.Subject }}, and Body_email to{{ $('Generate Support Reply').item.json.message.content.Body }}. - In Set Sales Decision, set Decision to
Sales, Subject_email to{{ $('Generate Sales Reply').item.json.message.content.Subject }}, and Body_email to{{ $('Generate Sales Reply').item.json.message.content.Body }}. - In Set Complaint Decision, set Decision to
Compliants; in Set Info Decision set Decision toInfo; and in Set Other Decision set Decision toOther. - Leave Passthrough Holder A and Passthrough Holder B as no-op nodes to merge category outputs before logging.
Sales in this workflow. Change it if you want support replies labeled distinctly.Step 5: Configure Output Logging to Google Sheets
Append all outcomes to spreadsheet logs for auditing and analysis.
- In Append Log Sheet, set Operation to
append, select the target Document ID and Sheet Name, and map Decision to{{ $json.Decision }}and Original Email toSubject: {{ $('Incoming Gmail Monitor').item.json.headers.subject }} Body: {{ $('Incoming Gmail Monitor').item.json.text }}. - In Append Output Sheet, set Operation to
append, select the same spreadsheet, and map Decision to{{ $json.Decision }}, Output Email toSubject: {{ $json.Subject_email }} Body: {{ $json.Body_email }}, and Original Email toSubject: {{ $('Incoming Gmail Monitor').item.json.headers.subject }} Body: {{ $('Incoming Gmail Monitor').item.json.text }}. - Credential Required: Connect your googleSheetsOAuth2Api credentials to Append Log Sheet and Append Output Sheet.
Step 6: Add Error Handling
Capture workflow failures and append them to an error log sheet for troubleshooting.
- Use Error Capture Trigger as the error workflow entry point.
- In Log Error Row, set Operation to
appendand map fields to{{ $now.format('dd-MM-yyyy hh:mm:ss') }},{{ $workflow.id }},{{ $execution.id }},{{ $json.execution.error.message }}, and{{ $json.execution.lastNodeExecuted }}. - Credential Required: Connect your googleSheetsOAuth2Api credentials to Log Error Row.
Step 7: Test and Activate Your Workflow
Validate the end-to-end triage flow before turning it on for production.
- Click Execute Workflow and send a test email to the monitored inbox that matches one category (e.g., sales or support).
- Confirm labeling and drafting: check that tags are applied and drafts are created for sales or support categories.
- Verify that Append Log Sheet and Append Output Sheet receive new rows with the expected values.
- If a test fails, confirm Error Capture Trigger logs an entry in Log Error Row.
- When results are correct, switch the workflow to Active for continuous email triage.
Watch Out For
- Gmail OAuth credentials can expire or need specific permissions. If things break, check the n8n Credentials screen and Google account security settings 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.
- Google Sheets logging is picky about columns and sheet names. Make sure you have “Logs” and “Errors” sheets with the expected headers before you assume the workflow is broken.
Common Questions
Usually about an hour once your Gmail and Sheets are ready.
Yes, but you’ll want someone comfortable connecting Gmail OAuth and checking a spreadsheet’s column headers. No coding, just careful setup.
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 OpenAI API costs, which are usually a few cents per day at typical inbox volume.
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.
Start by changing the categories in the Email Category Sorter, then adjust the “Generate Support Reply” and “Generate Sales Reply” prompts to match your tone and policies. If you don’t want drafts for Sales (or you want them for Complaints), you can reroute the If/branching so different categories go to different OpenAI generation nodes. Many teams also tweak the Google Sheets logging fields so the Logs sheet includes “Sender,” “Subject,” or “SLA target.” Small changes, big payoff.
Most of the time it’s expired or revoked OAuth access in Gmail. Reconnect the Gmail credential in n8n, then confirm the account still has permission to label threads and create drafts. If it fails only during busy periods, you may be hitting Google API limits, so reducing concurrency or batching emails can help.
Plenty for most small teams. On n8n Cloud you’re mainly limited by monthly executions on your plan, and on self-hosting you’re limited by your server size and how fast Gmail/OpenAI respond.
Often, yes, if you care about branching logic and observability. This workflow has multiple paths (Sales vs Support vs Complaint vs Info vs Other), drafts that depend on classification, and an actual error-capture path that logs failures to a sheet. Zapier and Make can do parts of it, but you’ll usually end up with several separate scenarios and less control over what happens when one step fails. n8n also gives you a self-hosting option, which is handy when email volume grows and per-task pricing gets annoying. If you’re unsure, Talk to an automation expert and we’ll help you pick the cleanest route.
Once this is running, your inbox stops being a daily sorting job and turns into a steady, trackable pipeline. The workflow handles the repetitive stuff. You handle the calls that actually need a human.
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.