Stepthrough Start free

Gmail AI Triage: Auto-Label Every Email and Draft Replies

Practice it step by step

Start the free practice

Take the free module: why it matters, practice and a quick check →

You do every step yourself in a practice copy of n8n. It checks your work as you go, and “Do it for me” finishes any step you get stuck on. Free, about 18 minutes, and nothing touches your real accounts. Open full screen

Free · Live nowBusiness Automationsn8nOpenAIGmail~18 min64 stepsAdvanced

Updated . Built against the tool’s current screens and checked step by step. How we check this lesson

Most mornings start with sorting: new inquiries, client questions, bills. In this free lesson you build an n8n workflow that sorts the inbox before you open it. An AI Text Classifier decides whether each new email is a lead, a client or an invoice, the matching Gmail label goes on, and client emails get a short reply waiting in Drafts. Nothing is ever sent on its own.

At a glance

QuestionAnswer
What you buildBuild an n8n workflow that reads each new email, sorts it as a lead, a client or an invoice with a Text Classifier, adds the matching Gmail label, and drafts a reply to clients for you to check.
Toolsn8n
TimeAbout 18 minutes, 64 steps in 6 parts
LevelAdvanced
CostFree
Ways to learn itPractice it step by step, watch the video

The 6 parts, in short

  1. Your inbox and Gmail: The inbox it sorts, The test email, Open the Gmail Trigger, Pick a credential, and 6 more steps.
  2. Sort every email: Add the next step, Search for classifier, Text Classifier, What to classify, and 9 more steps.
  3. Add the model: Add a chat model, OpenAI Chat Model, Pick a credential, Create one, and 10 more steps.
  4. Apply the labels: Connect Lead, Connect Client, Connect Invoice.
  5. Write the reply: Add the reply writer, Search for llm chain, Basic LLM Chain, Change the prompt source, and 6 more steps.
  6. Save it as a draft: Save the reply, Search for gmail, Gmail, Create a draft, and 10 more steps.

Start here first: How to Do OCR in n8n: Read Receipt Photos into Google Sheets with AI (module 1 of Business Automations)

In the course: Part 9 · n8n Automation Toolkit (Module 93 of the full course)

Part of: AI for Consulting & Agencies (step 22 of 40). Next up: n8n + ProLevelMax: Weekly Review Themes From Trustpilot to Google Sheets

Part of: AI for Marketing Teams (step 34 of 55)

Part of: Email on Autopilot (step 12 of 18). Next up: How to Connect n8n to Slack and Gmail to Answer Every Web Lead in 60 Seconds

Part of: Business Automations with n8n (step 7 of 23). Next up: How to Use n8n to Build AI Agents: A Support Agent That Answers from Your Docs

Gmail AI Triage: Auto-Label Every Email and Draft Replies: video walkthrough

The whole lesson in 2:31, narrated step by step.

Simulated practice environment. Recorded in Stepthrough’s simulated practice environment, not the live tool. Practice it yourself free at learn.ynteractive.com.

2:31 · 4 chapters · 64 steps · narrated with the lesson’s own voice-over

Chapters

Click a chapter to jump the video there.

  1. 0:00 Sort every email
  2. 0:54 Apply the labels
  3. 1:15 Write the reply
  4. 1:48 Save it as a draft

Now do it yourself, free

Watching is the warm-up. The interactive lesson puts you in a practice copy of n8n: you do every step yourself, it checks your work, and “Do it for me” finishes any step you get stuck on. Nothing touches your real accounts.

Practice “Gmail AI Triage: Auto-Label Every Email and Draft Replies” step by step

Full transcript

Sort every email

0:00 You're Sam at Juniper and Vale Marketing, and every morning starts with sorting the inbox. Let AI do it. This workflow already has a Gmail Trigger with a client email pinned, and three steps that each add one Gmail label. What's missing is the part that decides. Click the plus after the Gmail Trigger.

0:15 Type classifier.

0:16 Click Text Classifier. It reads some text and sends it down one output per category.

0:22 Paste this into Text to Classify. The sender, the subject and the start of the message are usually enough to tell what an email is.

0:29 Now the categories. Click Add Category.

0:32 Type Lead.

0:33 Add a description. Lead and Client both sound like customers, so spell out the difference. A lead is someone new.

0:38 Add another category.

0:40 Type Client.

0:41 A client already works with you and writes about their own project.

0:45 One more.

0:46 Type Invoice. That one is obvious, so it needs no description. Anything that fits none of the three is dropped and stays unlabeled.

0:53 Close it.

Apply the labels

0:54 Give it a model. Click the plus under Model.

0:56 OpenAI Chat Model.

0:58 Your saved OpenAI key is already picked. Close it.

1:01 The classifier now has one output per category. Connect each one to its label step. Drag from Lead to Label: Lead.

1:08 Client to Label: Client.

1:10 And Invoice to Label: Invoice. Each label step adds its Gmail label to that email.

Write the reply

1:14 Client emails also get a reply ready for you. Click the plus after Label: Client.

1:19 Type llm.

1:20 Click Basic LLM Chain. It sends one prompt to a model and returns the text.

1:25 It expects a chat message by default, and ours is an email. Open Source for Prompt.

1:30 Define below.

1:31 Paste the prompt. It says what to write and what not to promise, and it pulls the email from the Gmail Trigger by name, because the step right before this one only returns the label result.

1:41 Close it.

1:42 This one needs a model too. Click the plus under its Model.

1:45 OpenAI Chat Model.

1:46 Close it.

Save it as a draft

1:47 Now save that reply as a draft. Click the plus after the chain.

1:51 Type gmail.

1:52 Gmail.

1:53 Under Draft Actions, click Create a draft. It saves a draft and never sends, so you read it first.

1:58 Paste the subject: R E, then the original subject.

2:02 In Message, paste this. It is the text the chain wrote.

2:05 Without a recipient, the draft has nobody to go to. Click Add option.

2:09 To Email.

2:10 Paste the sender from the Gmail Trigger.

2:13 Close it.

2:14 Click Execute workflow. Priya's email goes out the Client side, gets the Client label, and a short reply waits in Drafts. Check it in Gmail, then publish. Read every draft before you send it.

2:24 Simple as that. We show you and you do it. Sign up below to learn AI automation for free.

Watch the 30-second version

A short video from this lesson. Watch, then do it yourself in the free practice copy.

n8n: Sort your inbox before you read it (video)0:24

n8n: Sort your inbox before you read it

Short · 0:24

n8n tip: You ask ChatGPT to help with email, but first you have to find the right ones. Sort first: a label for every kind of email, like Invoices. Then an AI agent only reads that label, writes a draft for each one…

Transcript

n8n tip: You ask ChatGPT to help with email, but first you have to find the right ones. Sort first: a label for every kind of email, like Invoices. Then an AI agent only reads that label, writes a draft for each one, and you check every draft before it sends. Sorted first. Drafted second. You decide. Practice it free.

Watch the full 2:31 video walkthrough

The n8n inbox triage workflow: Gmail Trigger, a Text Classifier with Lead, Client and Invoice outputs wired to three label steps, then a Basic LLM Chain and Create a draft on the Client branch
The n8n inbox triage workflow: Gmail Trigger, a Text Classifier with Lead, Client and Invoice outputs wired to three label steps, then a Basic LLM Chain and Create a draft on the Client branch

The inbox it sorts

The lesson opens on Sam's Gmail: four new emails, nothing labeled, and three labels already made in the left menu (Lead, Client, Invoice). Priya's email is the one pinned to the workflow for the test run; afterwards it carries the Client label and a draft reply waits in Drafts. To test your own build, send yourself these emails (or similar ones) and check that each gets the expected label.

fromsubjectmessageexpected_label
Priya NairOctober newsletter dateCould we push the October newsletter to Thursday? Our new menu photos won't be ready until Wednesday afternoon.Client
Marcus HaleHelp with our website?We're a three-person law firm and our website hasn't been touched since 2019. Do you take on projects like that?Lead
Brightpath HostingInvoice BP-20931 for OctoberYour invoice for October hosting is ready. Amount due: $89.00.Invoice
Marketing WeeklyThis week in email marketingFive subject lines that worked this month.(none: stays unlabeled)

Download the test emails (CSV) Open it in Google Sheets or Excel and send each one to your test inbox.

Where the keys come from

Gmail: in the Gmail Trigger, Credential to connect with, + Create new credential, Sign in with Google, pick the account, Continue (n8n Cloud; no key to copy). OpenAI: at platform.openai.com open API Keys, click + Create new secret key, name it, Create secret key, then Copy (it is shown only once). Add a few dollars under Settings, Billing first. Back in n8n, in the OpenAI Chat Model click Credential to connect with, + Create new credential, paste the key into API Key and Save. The lesson walks through both on screen with a placeholder key.

What you will build

You are Sam at Juniper & Vale Marketing, a made-up agency. The workflow already has a Gmail Trigger with one email pinned to it, from Priya at Fernhill Bakery asking to move the October newsletter to Thursday, and three steps that each add a Gmail label: Label: Lead, Label: Client and Label: Invoice.

You add a Text Classifier with an OpenAI Chat Model and three categories. Lead and Client get a one-line description each, because both sound like customers. You connect each of the classifier's outputs to its label step. After Label: Client you add a Basic LLM Chain that writes a short reply, then Gmail's Create a draft saves it, addressed back to the sender. One test run sends Priya's email down the Client branch, labels it, and leaves a draft for Sam to read.

Why descriptions matter

A Text Classifier only knows your categories by their names and descriptions. "Invoice" is obvious. "Lead" and "Client" are not: both are people who might pay you. One plain sentence for each, new versus existing, is what keeps a client's question from being treated as a cold lead. If a type of email keeps landing in the wrong place, sharpen that description first. Anything that fits none of the categories is dropped by default and simply stays unlabeled. Choose Output on Extra, 'Other' Branch under When No Clear Match if you want to catch those too. The Switch node has the same safety net, called a Fallback output: see how to add a fallback output in n8n.

Gotchas worth knowing

  • Create the Lead, Client and Invoice labels in Gmail first. Add label to message picks from labels that already exist.
  • The label step only returns the message's id, threadId and labels, so the reply prompt and the draft read the email from the Gmail Trigger by name: $('Gmail Trigger').item.json.snippet.
  • Basic LLM Chain expects a chat message by default. Switch Source for Prompt to Define below.
  • A draft has no recipient unless you add the To Email option. Add Thread ID too if you want the draft to sit under the original email.
  • Gmail's own filters and spam folder still run first. This sorts what reaches your inbox.

What you need

  • An n8n account: n8n Cloud from about €20 a month with a free trial, or the free self-hosted Community Edition.
  • An OpenAI API key with a little credit. Classifying one email and writing a short reply costs a fraction of a cent.
  • Gmail connected in n8n, with the three labels created.

Set up before you build (about 10 minutes)

  • Create the three Gmail labels first. In Gmail, click the plus next to Labels in the left sidebar (or the gear, See all settings, Labels, Create new label) and create Lead, Client and Invoice. n8n can only pick labels that already exist.
  • Get an OpenAI API key. Sign in at platform.openai.com, open API keys, create a key and copy it. API use is billed separately from a ChatGPT subscription, so add a few dollars of prepaid credit under Billing. Treat the key like a password: paste it only into n8n's credential box.
  • Connect Gmail in n8n. Add a Gmail Trigger node, click Credential to connect with, create a new Gmail OAuth2 credential and sign in with Google. On self-hosted n8n you need your own Google Cloud OAuth client; on n8n Cloud the sign-in button usually does it for you.
  • Use a test inbox or a test email first. Send yourself a message that looks like a client email, then run the workflow on it. The workflow only labels and drafts, but test on one email before you turn it on.

Keep it safe

The workflow only labels and drafts. It never sends, deletes or archives. Read every draft before you send it, and watch the labels for the first week. If one kind of email always comes from the same sender, a plain Gmail filter labels it with no AI: see How to Label Emails in Gmail with a Filter, Then Draft Replies with AI. Emails pass through OpenAI to be classified, so check your company's rules on client data first.

Try it yourself, free

Reading the steps is a start. Doing them is how it sticks. The interactive module walks you through every click in a practice copy of n8n, checks each step, and never touches your real accounts.

Start “Gmail AI Triage: Auto-Label Every Email and Draft Replies”

Step by step: Gmail AI Triage: Auto-Label Every Email and Draft Replies

All 64 steps of the interactive module, in order. In the module you watch each one, then do it yourself in a practice copy that checks your work.

1. Your inbox and Gmail

  1. The inbox it sorts. This is Sam's Gmail at Juniper & Vale Marketing: a new lead, a client question, a hosting bill and a newsletter, none of them sorted. In the left menu under Labels there are already three labels: Lead, Client and Invoice (in your Gmail, make them with the + next to Labels). Click the Labels list.

    This is Sam's Gmail at Juniper and Vale Marketing. A new lead, a client question, a hosting bill, and a newsletter. None of them sorted. On the left, under Labels, there are already three labels. Lead, Client, and Invoice. In your own Gmail, make them with the plus next to Labels.

  2. The test email. The top email, from Priya Nair at Fernhill Bakery, is the one pinned to the workflow for testing. The newsletter fits no label, so it should stay as it is. Switch to the n8n tab.

    The top one, from Priya at Fernhill Bakery, is the email pinned to the workflow for testing. The newsletter fits no label, so it should stay as it is. Switch to the n eight n tab.

  3. Open the Gmail Trigger. First, let n8n into this Gmail. Double-click the Gmail Trigger.

    First, let n eight n into this Gmail.

  4. Pick a credential. Credential to connect with is empty. Click it.

    Credential to connect with is empty.

  5. Create one. Click + Create new credential.
  6. Sign in with Google. On n8n Cloud, Gmail connects with your Google sign-in, so there is no key to copy. Click Sign in with Google.

    On n eight n cloud, Gmail connects with your Google sign in. There's no key to copy.

  7. Choose the account. A Google window opens. Pick the account whose inbox you want sorted, here Sam Rivera.

    A Google window opens. Pick the account whose inbox you want sorted.

  8. Allow access. Google lists what n8n may do: read the email, and add labels and drafts. Click Continue.

    Google lists what n eight n may do. Read the email, and add labels and drafts.

  9. Connected. It says Account connected. Close the window with the X.

    Account connected. Close the window.

  10. Close the node. The trigger now uses Gmail account, and Priya's email is pinned on the right. Close the node.

    The trigger now uses that Gmail account, and Priya's email is pinned on the right. Close it.

2. Sort every email

  1. Add the next step. The Gmail Trigger checks the inbox every minute, and one client email is pinned to it. The three Label steps are ready. Click the + after Gmail Trigger.

    You're Sam at Juniper and Vale Marketing, and every morning starts with sorting the inbox. Let AI do it. This workflow already has a Gmail Trigger with a client email pinned, and three steps that each add one Gmail label. What's missing is the part that decides.

  2. Search for classifier. Type classifier.
  3. Text Classifier. Click Text Classifier.

    It reads some text and sends it down one output per category.

  4. What to classify. Point to Text to Classify and click Expression first (in Fixed the {{ }} stay plain text). Then paste who it is from, the subject and the snippet.

    Point to Text to Classify and switch it to Expression, then paste this. The sender, the subject and the start of the message are usually enough to tell what an email is.

  5. Add a category. Click Add Category.

    Now the categories.

  6. Name it Lead. In Category, type Lead.
  7. Describe it. In Description, paste: *Someone new asking about our services, prices or availability*.

    Add a description. Lead and Client both sound like customers, so spell out the difference. A lead is someone new.

  8. Add a category. Click Add Category.

    Add another category.

  9. Name it Client. In Category, type Client.
  10. Describe it. In Description, paste: *An existing client writing about their own project or account with us*.

    A client already works with you and writes about their own project.

  11. Add a category. Click Add Category.

    One more.

  12. Name it Invoice. In Category, type Invoice.

    That one is obvious, so it needs no description. Anything that fits none of the three is dropped and stays unlabeled.

  13. Close the node. Close the node.

    Close it.

3. Add the model

  1. Add a chat model. Click the + under Model.

    Give it a model.

  2. OpenAI Chat Model. Click OpenAI Chat Model.

    OpenAI Chat Model.

  3. Pick a credential. The model needs an OpenAI API key. Click Credential to connect with.

    The model needs an OpenAI API key.

  4. Create one. Click + Create new credential.

    Create new credential.

  5. Where the key comes from. The API Key box needs a key from OpenAI. Switch to the OpenAI tab: platform.openai.com, the developer site (not ChatGPT), with API Keys in the left menu. It needs a few dollars of credit under Settings › Billing first. (No key yet? In your own n8n you can pick n8n's free Gateway credits on the model instead.)

    The API key box needs a key from OpenAI. Switch to the OpenAI tab. It's platform dot openai dot com, the developer site, not ChatGPT. API Keys is in the left menu. Put a few dollars of credit on it first, under Settings, Billing. Or, in your own n eight n, pick the free gateway credits on the model instead.

  6. Create a key. Click + Create new secret key.
  7. Name it and create it. Name it after what will use it, here n8n inbox triage. Leave the rest and click Create secret key.

    Name it after what will use it. Leave the rest, and click create secret key.

  8. Copy it now. OpenAI shows the key only this once. Click Copy. (This one is a placeholder.)

    OpenAI shows the key only this once.

  9. Done. Click Done. Treat the key like a password: never paste it into a chat or a screen recording.

    Treat that key like a password. Never paste it into a chat or a screen recording.

  10. Back to n8n. Switch back to the n8n tab. The credential window is still open.

    Switch back to the n eight n tab. The credential window is still open.

  11. Paste the key. Paste the key into API Key.
  12. Save it. Click Save. n8n tests the key and shows Connection tested successfully.

    n eight n tests the key, and says connection tested successfully.

  13. Close the window. Close the credential window with the X.

    Close the window.

  14. Close the node. Your saved OpenAI account is picked. Close the node.

    Your saved OpenAI key is already picked. Close it.

4. Apply the labels

  1. Connect Lead. Drag from the Lead output of Text Classifier to Label: Lead. (Here, click the dot.)

    The classifier now has one output per category. Connect each one to its label step.

  2. Connect Client. Drag from the Client output of Text Classifier to Label: Client. (Here, click the dot.)

    Client to Label: Client.

  3. Connect Invoice. Drag from the Invoice output of Text Classifier to Label: Invoice. (Here, click the dot.)

    And Invoice to Label: Invoice. Each label step adds its Gmail label to that email.

5. Write the reply

  1. Add the reply writer. Only client emails get a draft. Click the + after Label: Client.

    Client emails also get a reply ready for you.

  2. Search for llm chain. Type llm chain.
  3. Basic LLM Chain. Click Basic LLM Chain.

    It sends one prompt to a model and returns the text.

  4. Change the prompt source. Open Source for Prompt (User Message).

    It expects a chat message by default, and ours is an email.

  5. Define below. Choose Define below.

    Define below.

  6. Write the prompt. Point to Prompt (User Message), click Expression, then paste the prompt. It pulls the email from Gmail Trigger by name.

    Switch Prompt to Expression, then paste the prompt. It says what to write and what not to promise, and it pulls the email from the Gmail Trigger by name, because the step right before this one only returns the label result.

    Write a short reply to this client email for Juniper & Vale Marketing.
    Thank them and answer only what the email asks. If it needs a decision or a new date, say we'll confirm today. Don't promise anything else.
    Plain text, under 100 words, signed "Sam".
    
    From: {{ $('Gmail Trigger').item.json.From }}
    Subject: {{ $('Gmail Trigger').item.json.Subject }}
    Message: {{ $('Gmail Trigger').item.json.snippet }}
  7. Close the node. Close the node.

    Close it.

  8. Add its model. Click the + under Model on Basic LLM Chain.

    This one needs a model too.

  9. OpenAI Chat Model. Click OpenAI Chat Model.

    OpenAI Chat Model.

  10. Close the node. Close the node.

    Close it.

6. Save it as a draft

  1. Save the reply. Click the + after Basic LLM Chain.

    Now save that reply as a draft.

  2. Search for gmail. Type gmail.
  3. Gmail. Click Gmail.

    Gmail.

  4. Create a draft. Scroll down to Draft Actions and click Create a draft.

    Under Draft Actions, click Create a draft. It saves a draft and never sends, so you read it first.

  5. Subject. Paste Re: plus the original subject into Subject.
  6. Message. Paste {{ $json.text }} into Message: the reply the chain wrote.

    In Message, paste this. It is the text the chain wrote.

  7. Add option. Click Add option.

    Without a recipient, the draft has nobody to go to.

  8. To Email. Choose To Email.

    To Email.

  9. Reply to the sender. Paste the sender from Gmail Trigger.
  10. Close the node. Close the node.

    Close it.

  11. Test it. Click Execute workflow. It runs on the pinned client email.

    Priya's email goes out the Client side, gets the Client label, and a short reply waits in Drafts. Check it in Gmail, then publish. Read every draft before you send it.

  12. Check Gmail. Switch to the Gmail tab to see what the run did.

    Now check Gmail. Switch to the Gmail tab.

  13. Labeled. Priya's email now has the Client label. Once the workflow is published, the lead and the bill get theirs as they arrive, and the newsletter stays unlabeled. Click Drafts.

    Priya's email now has the Client label. Once it's published, new leads and bills get their labels as they arrive, and the newsletter is left alone.

  14. The draft reply. The reply to Priya waits here, unsent. Click it to read it.

    The reply to Priya is waiting here, not sent.

All free Stepthrough videos

Screenshots

Frequently asked questions

How does the interactive lesson work?
Each step is shown to you first on the left (Watch). Then you do it yourself in a practice copy on the right (Your turn), and every click is checked. If you get stuck, press Do it for me. It is a practice copy, so no real accounts are touched.
Is this free?
Stepthrough is completely free. Running the workflow for real needs your own n8n account, an OpenAI API key with some credit, and Gmail.
Will it send emails for me?
No. Client emails get a reply saved as a draft. You read it, change it if needed, and send it yourself.
Can I add more categories?
Yes. Add another category in the Text Classifier, then a label step for its new output. Keep each description to one clear sentence.
How is this different from Gmail filters?
Filters match fixed words or senders. The classifier reads what the email is about, so a new client's question gets the right label even if it doesn't contain the words a filter looks for.

Start this module free

More in Business Automations

All 61 modules in Business Automations

More n8n tutorials

How to Create an AI Agent in n8n That Saves Ideas to Google Sheets: a step from the interactive moduleHow to Create an AI Agent in n8n That Saves Ideas to Google Sheets

Build an AI agent for BrightPath Marketing that generates social media post ideas and saves them to Google Sheets — chat trigger, AI Agent, system prompt, model…

Free · Live ~12 min Intermediate

How to Build in Lovable: A Web App with an n8n AI Backend: a step from the interactive moduleHow to Build in Lovable: A Web App with an n8n AI Backend

Build a contact form in Lovable and connect it to an n8n workflow — webhook trigger, AI Agent, Google Sheets, Gmail, and a Respond node that ties it all together.

Free · Live ~15 min Advanced

Build an AI Follow-Up Agent for HVAC Service Calls: a step from the interactive moduleBuild an AI Follow-Up Agent for HVAC Service Calls

Build an AI agent for Cedar Ridge Heating & Air that writes follow-up messages for completed service calls and saves them to Google Sheets — chat trigger, AI Agent…

Free · Live ~12 min Intermediate

Build an AI Service Request Form for Your HVAC Company: a step from the interactive moduleBuild an AI Service Request Form for Your HVAC Company

Build a service request form in Lovable for Cedar Ridge Heating & Air and connect it to n8n — the AI agent sorts each job into repair, maintenance, install or…

Free · Live ~15 min Advanced

Build an AI Job Follow-Up Agent for Electricians: a step from the interactive moduleBuild an AI Job Follow-Up Agent for Electricians

Build an AI agent for Oak & Wire Electric that writes follow-up messages after completed jobs and tracks them in Google Sheets — chat trigger, AI Agent, system prompt…

Free · Live ~12 min Intermediate

Build an AI Quote Request Form for Electrical Contractors: a step from the interactive moduleBuild an AI Quote Request Form for Electrical Contractors

Build a quote request form in Lovable and connect it to an n8n workflow — webhook trigger, an AI Agent that drafts an initial estimate note, Google Sheets, Gmail, and a…

Free · Live ~15 min Advanced

From the blog

All blog posts

Plain-English definitions, each with an example from a free lesson.

Accounts receivable vs accounts payableBasic LLM Chain (n8n)Intent classification (intent detection)Interactive voice response (IVR)Model routerPrecision and recallText Classifier (n8n)False positive and false negative

The full AI glossary

Browse related tutorials