Skip to content

Automate Gmail with n8n: labels, digests and auto-replies

Automate Gmail with n8n: labels, digests and auto-replies

This page may contain affiliate links.

If your inbox looks like a game of Jenga that's about to collapse, you're not alone. Most people I know in the UK tech scene have given up on "inbox zero" and settled for "inbox vaguely under control". The good news is you don't need a fancy paid email app to fix this. If you're already dabbling with n8n — or fancy giving it a go — you can wire Gmail up to a workflow that labels, summarises and even replies to your mail while you're making a brew.

n8n is an open-source automation tool. You can self-host it for free or use their cloud tier, and it has a native Gmail node that handles OAuth without you having to wrestle with Google's console too much. Let's build three genuinely useful workflows: auto-labelling, a daily digest, and auto-replies.

Before you start: the boring but essential bits

You'll need an n8n instance running. Self-hosting on a cheap VPS or a Raspberry Pi 4/5 is perfectly fine for personal Gmail automation — the workloads are tiny. A Pi 4 with 4GB RAM handles it comfortably, and a decent 32GB microSD card is a tenner or so. If you'd rather not faff, n8n Cloud has a free trial and paid tiers, but check their current pricing yourself as it changes.

Connect Gmail via the Gmail OAuth2 credential in n8n. You'll create a Google Cloud project, enable the Gmail API, and paste the client ID and secret into n8n. It takes about ten minutes and Google's own docs walk you through it. Do this once and every workflow below can reuse the same credential.

One warning: Gmail API quotas. The free tier gives you a generous but finite number of calls per day. If you're processing thousands of emails a minute you'll hit it. For personal use, you won't get close.

Workflow 1: Automatic labelling by sender and keyword

This is the gateway drug. The goal: when an email arrives, n8n reads it, decides which label it deserves, and applies it. No more manually dragging things into folders.

Start with a Gmail Trigger node set to poll every minute (or use a webhook via Google Pub/Sub if you want instant, but polling is simpler). Then add a Switch or IF node. For example:

• If from contains @yourbank.co.uk → apply label Finance
• If subject contains invoice or receipt → apply label Finance/Receipts
• If from ends in @github.com → apply label Dev
• If subject matches newsletter or unsubscribe → apply label Newsletters

Then a Gmail node set to "Add Label" using the message ID from the trigger. You'll need to create the labels in Gmail first — n8n can't invent them on the fly without extra work.

Want to get clever? Add an OpenAI or Ollama node and ask the model to classify the email into one of your labels. A prompt like:

Classify this email into exactly one of: Finance, Dev, Newsletters, Personal, Spam. Reply with only the label name. Email: {{ $json.snippet }}

That handles the messy stuff your keyword rules miss. Local models via Ollama keep your email off third-party servers, which matters if you're handling anything sensitive.

Workflow 2: A daily digest you'll actually read

Instead of notifications pinging all day, batch your email into one summary at a time that suits you — say 7am and 6pm.

Use a Schedule Trigger node set to 0 7 * * * (7am daily). Follow it with a Gmail node in "Get Many" mode, filtered by is:unread newer_than:1d. Then feed the results into a Code node to build a tidy list, or straight into an AI Agent node with a prompt like:

Summarise these unread emails in under 150 words. Group by urgency. Flag anything that needs a reply today. Emails: {{ $json.map(e => e.subject + ' — ' + e.snippet).join('\n') }}

Finally, send the output to yourself via Gmail (Send), Telegram, or Slack. I route mine to Telegram because the notification is less ignorable than another email.

If you want this running 24/7 without leaving a laptop on, a small always-on mini PC or a Pi in a case is the sensible move — search for a Raspberry Pi 5 kit on Amazon if you're starting from scratch: Raspberry Pi 5 kits on Amazon UK. It'll pay for itself versus a cloud VM within a year.

Workflow 3: Auto-replies that don't sound like a robot

Auto-replies have a bad reputation because most of them are terrible. The trick is to be narrow. Don't auto-reply to everything — auto-reply to specific, predictable situations.

Good candidates:

• Enquiries to a specific address (e.g. hello@yoursidehustle.co.uk) with a holding message and expected response time.
• Out-of-office that actually knows your calendar (pull from Google Calendar and mention when you're back).
• FAQ responses — if someone emails asking about pricing or shipping, reply with the answer and a link.

Build it with a Gmail Trigger filtered by to:hello@yoursidehustle.co.uk is:unread, then an IF node to check it's not from a known contact or a noreply address. Then a Gmail Send node with a template.

To keep it human, use an AI node to draft the reply and insert it into the email body. Prompt:

Write a warm, brief reply (under 80 words) to this enquiry. Sign off as 'Sam from ShedDad'. Do not promise specific dates. Enquiry: {{ $json.snippet }}

Add a delay node of a few minutes so it doesn't fire instantly — instant replies feel robotic. And always, always exclude noreply@ and no-reply@ senders or you'll end up in a loop with a ticketing system. Trust me, I've done it.

If you'd rather skip the build and get straight to the good bit, we've packaged up ready-made versions of exactly these workflows — labelling, digest and auto-reply — in n8n Starter Workflows. They're plug-and-play templates you import in minutes, from £9, and they save you the afternoon of debugging OAuth and label IDs.

Testing, safety and not annoying people

Three rules before you let any of this loose on your real inbox:

1. Test on a label, not your inbox. Create a Gmail filter that copies mail into a test label, and point your workflow at that first.
2. Add error handling. Use n8n's Continue On Fail setting and a separate error workflow that emails you if something breaks. Silent failures are the worst kind.
3. Log everything. Write each action to a Google Sheet or a local SQLite database. When something goes wrong — and it will — you'll want to know what the workflow did at 3am.

Also think about GDPR if you're handling other people's email. Auto-replying to customers means their data flows through whatever AI provider you've chosen. If that's a concern, run a local model via Ollama instead. Slower, but your data stays put.

Wrapping up

None of this is magic — it's just plumbing. Gmail trigger, a bit of logic, a Gmail action, and a schedule. The payoff is real though: an inbox that sorts itself, a digest you read in two minutes instead of doom-scrolling for twenty, and auto-replies that buy you breathing room without looking like you've checked out. Start with labelling, get comfortable, then layer on the digest and replies. Once it's running, you'll wonder why you put up with the manual version for so long.

Written by

Richard Tucker

View all posts →