FlowKit

Connecting Gmail to n8n: OAuth2, trigger, labels and drafts (complete guide)

Published 29 July 2026 · 4 min read

Gmail is both the entry point of half a small team's processes — customer requests, supplier invoices, job applications — and the place where the most time is lost to manual triage. n8n's Gmail node changes the equation: triggering on incoming messages, reading, labeling, drafting and sending, all combinable with AI. This guide covers the trickiest part (OAuth2 authentication and its infamous expiring token), the trigger and its filters, the useful operations, and the patterns that pay for the integration within the first week.

Authentication: the mandatory trip through Google Cloud

Gmail only accepts OAuth2 — no simple API key. The full journey — Google Cloud project, consent screen, OAuth client, n8n redirect URL — is detailed step by step in our guide to configuring Google OAuth2 in n8n; the essentials fit in four points:

  1. In console.cloud.google.com, create a project and enable the Gmail API (APIs & Services → Library);
  2. Configure the OAuth consent screen (External type for an @gmail.com account) and add your address as a test user;
  3. Create an OAuth client ID of type Web application, using the OAuth Redirect URL shown by the n8n credential as the authorized redirect URI;
  4. Paste the Client ID and Client Secret into a Gmail OAuth2 credential in n8n, then complete the connection flow.

The number one trap: as long as the app stays in "Testing" status, Google expires refresh tokens after 7 days — your workflow runs for a week, then the credential fails, every time. Switch the app to "In production" (the consent screen's Publish app button): for internal use with your own accounts, Google's full verification isn't needed, and the "unverified app" warning at connection time has no consequence.

The Gmail Trigger: filtered polling, and plenty enough

The Gmail Trigger polls the mailbox at a regular interval (down to every minute) and emits one item per new message matching your criteria:

  • Label: watch only Invoices or Support — Gmail's native filtering becomes the first stage of your workflow;
  • Search: the entire Gmail search bar syntax works — from:client@example.com has:attachment newer_than:2d, subject:(quote OR order);
  • Read Status: unread only, with an option to mark as read after processing;
  • Attachments: downloads attachments as binary data, ready for AI invoice extraction from PDFs or large file handling.

Filter as early as possible, on the Gmail side: a trigger that only fires on the right messages saves executions and simplifies everything downstream — the same principle as for any webhook.

The Gmail node's operations

Four resources cover the essentials:

  • Message: Send (recipients, HTML, attachments), Reply (which preserves the conversation thread), Get / Get Many, Mark as Read/Unread, Add/Remove Label, Delete;
  • Draft: Create — the node's most underrated operation, see below;
  • Label: create and list labels, to drive classification programmatically;
  • Thread: fetch a full conversation, essential for giving an AI the context of an exchange before writing the next message.

A detail that matters for AI workflows: message bodies arrive as HTML and/or text depending on options — to feed an LLM, prefer plain text or convert first, since a marketing email's HTML can triple token consumption for nothing.

Three patterns that pay for the integration

  • AI-powered triage: Gmail Trigger → classify the message (request, invoice, spam, urgent) → apply a label + route to the right channel. That's the core of our AI email triage workflow and, in its full version, of the AI Inbox Pack;
  • AI drafts reviewed by a human: rather than sending automatically, the Create Draft operation drops the AI-written reply into Gmail, attached to the conversation: review and send in one click. The full pattern — tone, customer context, guardrails — is in our guide to AI-drafted email replies;
  • Daily digest: Schedule Trigger → Get Many on important unprocessed messages → LLM summary → a single Slack message or email in the morning, instead of thirty notifications.

The problem these patterns attack has been documented for thirty years: the foundational study by Steve Whittaker and Candace Sidner, "Email overload: exploring personal information management of email" (CHI, 1996, see on Google Scholar), already showed email overflowing its communication role to become a task-management and archiving tool — jobs an inbox is structurally unsuited for. Automatic triage, filing and summarizing are the modern answer to that finding: give the inbox back its role as a stream, and hand management over to systems built for it.

Quotas and sending best practices

The Gmail API applies per-user usage quotas that are ample for reading and labeling, but sending remains bounded by the account's sending limits (higher on Google Workspace than on a free account). For marketing volume, Gmail is not the tool: keep it for transactional and individualized replies, and use a dedicated emailing service beyond that. Finally, a service account with domain-wide delegation is the clean way to automate shared mailboxes on Google Workspace — a heavier setup, worth it only for genuine multi-mailbox needs.

In short

Connecting Gmail to n8n comes down to a properly configured OAuth2 credential (app published to production, on pain of weekly expiry), a trigger filtered at the source with Gmail search syntax, and four resources — Message, Draft, Label, Thread — that cover every useful pattern. Start with automatic triage and AI drafts: they're the two automations with the most immediate return, and they take barely an hour to build once OAuth2 is in place.

FAQ

Frequently asked questions

Why does my n8n Gmail credential disconnect every 7 days?

Because your OAuth app in Google Cloud is still in "Testing" status: Google expires refresh tokens after 7 days in that mode, and n8n loses access. The fix is to switch the consent screen to "In production" (Publish app button) — for personal use with your own account, Google's full verification isn't required; the "unverified app" warning at connection time is harmless.

Is n8n's Gmail Trigger a real-time webhook?

No, it's polling: n8n checks the mailbox at a regular interval (down to every minute) with your filters — label, Gmail search query, read/unread. For virtually all email automations, that one-minute latency is painless. True real time would require Gmail's push API via Google Pub/Sub, outside the standard node's scope.

Can I use Gmail search filters in n8n?

Yes: the Gmail Trigger and the Get Many operation accept the same syntax as Gmail's search bar — from:, to:, subject:, has:attachment, newer_than:2d, labels, and combinations of them. It's the most efficient way to trigger the workflow only on relevant messages, rather than fetching everything and filtering inside n8n.

How do I get a human to validate an automatic reply before it's sent?

Use the Create Draft operation instead of Send: the AI writes, the draft appears in Gmail attached to the conversation, and a human reviews then sends in one click. It's the simplest human-in-the-loop pattern there is — no interface to build, Gmail already is the interface.

Bundle FlowKit Complet

€269