Gmail n8n integrationAutomate Gmail with n8n.
Every new email can start a workflow. The Gmail n8n integration exposes 26 operations across 4 resources: messages, labels, drafts and threads. The Gmail Trigger listens to a single event, Message Received, and checks the mailbox at the interval you set. For anyone wiring an inbox into n8n.
Verified Trustpilot reviews · AI, automation & growth agency
What can the Gmail n8n integration actually do?
The Gmail n8n integration links a Gmail mailbox to n8n through two nodes. The Gmail node runs 26 operations on four resources: Message, Label, Draft and Thread. The Gmail Trigger starts a workflow when a new message shows up, which is the event n8n listens for. Both nodes share the same Google credential, created once in the Credentials menu and reused in every workflow. Nothing to install: the nodes ship with n8n, on n8n Cloud and on a self-hosted instance alike.
Sorting an inbox without opening it is where most teams start. The Gmail Trigger fires on messageReceived, a Search filter keeps only the mail worth acting on, then message.addLabels files the message and message.markAsRead takes it out of the unread pile. A short branch pushes the summary to Slack, so nobody reopens Gmail just to check what arrived.
Answering is the second job, and it splits in two. draft.create writes the reply into the Drafts folder and stops there, which leaves a person in charge of the send button. Once the workflow has earned some trust, message.reply posts the answer straight into the existing conversation, and message.sendAndWait holds the execution until someone approves from inside the email itself.
Reporting closes the loop. message.getAll with Return All turned on, plus a Received After date, pulls a whole period out of the mailbox and hands it to Google Sheets for counting. A digest of what came in overnight can land on Telegram instead, for people who never open a spreadsheet.
The node stays inside those four resources. Anything the Gmail API offers beyond them belongs to the HTTP Request node, which calls any endpoint and reuses the same Google credential through predefined authentication. Better to reach for it early than to bend a Gmail operation into something it does not do.
Two limits shape every design. The trigger polls, so a message reaches the workflow after a delay equal to the poll interval, and the node fetches 10 emails per poll by default, 50 at most, queueing the rest for the next cycle. The Delete operation on a message is permanent and cannot be undone, which is why the Thread resource keeps a Trash operation for anything recoverable. If the platform choice is still open, the n8n review lays out the criteria, and the n8n training walks through building these flows end to end.
How do you connect Gmail to n8n?
- 01
Create the Google credential in n8n
Open the Credentials menu and create a Google credential for Gmail. On n8n Cloud, Managed OAuth2 does the work: click Sign in with Google on the credential screen and nothing else needs configuring in the Google Cloud Console. Self-hosted instances do not get Managed OAuth2, so the dropdown on that same screen switches the authentication type to Custom OAuth2, which needs a Client ID and a Client Secret from Google.
- 02
Build the OAuth client in Google Cloud
Create a Google Cloud project, then enable the Gmail API under APIs & Services > Library. Configure the OAuth consent screen with an App name, a User support email and an Audience: Internal for your Workspace, External for any Google account. Under Branding, add the authorized domain,
n8n.cloudon n8n Cloud or your instance domain when self-hosting. Then create an OAuth client ID, type Web application. - 03
Paste the redirect URL, then the keys
Copy the OAuth Redirect URL shown in the n8n credential and paste it into Authorized redirect URIs in Google. A local instance works too: Google accepts localhost, so a URL like
http://localhost:5678/rest/oauth2-credential/callbackis valid without a public domain or an SSL certificate. Create the client, then copy the Client ID and Client Secret back into n8n to finish the credential.
What starts a Gmail workflow?
Gmail Trigger is the node that starts a workflow when something happens in Gmail. It listens to 1 events, listed below by family. Pick one or several, activate the workflow: n8n registers the webhook on your Gmail account.
What you see in n8n
Every event, by family
One row per object, one chip per action. The event to tick in the node is object.action; hover a chip to read exactly when it fires.
message.*1Configuration notes
01Gmail Trigger
The Gmail Trigger starts a workflow from the mailbox itself, with nothing to register on the Google side. It queries the Gmail API at the interval you set and emits one item per new message found.
Key parameters
- Poll Times: the Mode decides how often the check runs, once a minute at the fastest. The delay before a message reaches the workflow equals that interval, so pick it against how urgent the mail really is.
- Simplify: on by default, it returns message IDs, labels and the From, To, CC, BCC and Subject headers. Turn it off for the raw data.
- Max Emails per Poll: 10 by default, 50 at the top. Anything above the limit waits in the queue and comes through on the next poll cycle.
02Message Received
Message Received is the one event the trigger exposes, and every Gmail workflow starts there. The filters decide which messages wake the workflow, and they matter more than the event itself.
Key parameters
- Search: the syntax of the Gmail search box,
from:for instance, so the run only starts for a subset of the mailbox. - Label Names or IDs: only messages carrying the selected labels. The dropdown fills from the credential, or an expression passes the IDs.
- Read Status: Unread emails only by default, Read emails only, or both.
- Sender: an address, or part of a sender name.
- Include Spam and Trash and Include Drafts: left off, the workflow sees delivered mail and nothing else.
What the Gmail node does, operation by operation
The Gmail node exposes 26 operations across 4 resources. For each one: the node as you configure it in n8n, the required fields, and our field notes.
| Resource | Create | Get | Get Many | Delete | Add Label | Mark as Read | Mark as Unread | Remove Label | Reply | Send | Send and Wait for Response | Trash | Untrash |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Message | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | |||
| Label | ✓ | ✓ | ✓ | ✓ | |||||||||
| Draft | ✓ | ✓ | ✓ | ✓ | |||||||||
| Thread | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
Operations index
Message
10 operationsAdd label to message
message.addLabelsWhat you see in n8n
Notes & use cases
Puts one or more existing labels on a single message, which is the filing a human would have done by dragging it.
Key parameters
- Message ID: the Gmail identifier of the message, in the shape of
172ce2c4a72cc243, usually carried over from the previous node with an expression, the{{ $json.id }}syntax that picks a field off the incoming item. - Label Names or IDs: pick the labels in the dropdown, which loads from the credential, or specify their IDs with an expression.
Delete a message
message.deleteWhat you see in n8n
Notes & use cases
Erases a message immediately and permanently. Gmail does not move it to the trash, and no later operation brings it back.
Key parameters
- Message ID: the identifier of the message to remove. Run a Get with that ID first if there is any doubt it exists, because a wrong one ends the execution on
Bad request - please check your parameters.
Get a message
message.getWhat you see in n8n
Notes & use cases
Reads a single message back into the workflow, with its headers and, on demand, its attachments.
Key parameters
- Message ID: the message to retrieve.
- Simplify: on, the node returns message IDs, labels and the From, To, CC, BCC and Subject headers; off, the full raw payload.
- Download Attachments: the files come back as binary properties, named from Attachment Prefix plus an index starting at 0, so
attachment_producesattachment_0.
Get many messages
message.getAllWhat you see in n8n
Notes & use cases
Lists messages and narrows them down before they enter the workflow, which makes it the reporting operation of the node.
Key parameters
- Return All: on, n8n walks every page of the API; off, Limit caps how many messages come back.
- Search: the Gmail search box syntax,
has:attachmentfor example. - Received After and Received Before: a date picker, or an expression holding an ISO string or a timestamp in milliseconds.
- Read Status, Sender, Label Names or IDs: the same filters as the trigger, applied on demand.
Mark a message as read
message.markAsReadWhat you see in n8n
Notes & use cases
Flips a message to read without anyone opening Gmail. It belongs at the end of a branch, as the signal that the workflow has done its part.
Key parameters
- Message ID: the message the workflow just handled.
Mark a message as unread
message.markAsUnreadWhat you see in n8n
Notes & use cases
Sends a message back to the unread pile, where a human will see it. The mirror image of the operation above, and it exists for the cases automation should not close.
Key parameters
- Message ID: the message to hand back to a person.
Remove label from message
message.removeLabelsWhat you see in n8n
Notes & use cases
Takes labels off a message, which keeps a mailbox from filling up with tags that meant something two steps ago.
Key parameters
- Message ID: the message to clean up.
- Label Names or IDs: the labels to take off, chosen in the dropdown or passed as IDs with an expression.
Reply to a message
message.replyWhat you see in n8n
Notes & use cases
Answers inside the existing conversation, so the thread stays in one piece in the recipient's mailbox.
Key parameters
- Message ID: the message being answered.
- Email Type: Text or HTML, and Message holds the body.
- Reply to Sender Only: on, the answer goes to the sender; off, to the whole list of recipients.
- Append n8n Attribution: on by default, it adds the sentence about the email being sent automatically with n8n. Turn it off for customer-facing mail.
Send a message
message.sendWhat you see in n8n
Notes & use cases
Starts a new email from the connected mailbox, outside any existing thread.
Key parameters
- To: one address, or several separated by commas.
- Subject, Message and Email Type: the header line, the body, and Text or HTML.
- Sender Name: the name recipients see in their inbox, which rarely matches the mailbox address.
- CC, BCC, Send Replies To and Attachments: the usual extras, plus files taken from a field of the incoming item.
Send message and wait for response
message.sendAndWaitWhat you see in n8n
Notes & use cases
Sends an email, then pauses the execution until the recipient answers. This is how a human decision gets into an otherwise automatic run.
Key parameters
- Response Type: Approval, where the reader answers from the message; Free Text, for an open reply through a form; Custom Form, for a form you design.
- Type of Approval: Approve Only, or Approve and Disapprove for two buttons.
- Limit Wait Time: caps how long the node waits before the execution resumes on its own.
Label
4 operationsCreate a label
label.createWhat you see in n8n
Notes & use cases
Creates a label in the mailbox, the filing unit Gmail uses in place of folders.
Key parameters
- Name: the display name, something like
invoices. - Label List Visibility: Show, Hide, or Show If Unread in the label list of the Gmail web interface.
- Message List Visibility: Show or Hide messages carrying that label in the message list.
Delete a label
label.deleteWhat you see in n8n
Notes & use cases
Removes a label from the mailbox. Worth a second look before running it on a schedule.
Key parameters
- Label ID: the ID of the label, not the name shown in Gmail. A Get Many on labels gives the matching IDs, and an ID that does not exist ends the run on
Bad request - please check your parameters.
Get a label info
label.getWhat you see in n8n
Notes & use cases
Returns the detail of one label. Small operation, mostly used as a safety check.
Key parameters
- Label ID: the ID of the label to look up.
Get many labels
label.getAllWhat you see in n8n
Notes & use cases
Lists the labels of the mailbox with their IDs, which is the quickest way to find the values every other label operation expects.
Key parameters
- Return All: on, every label comes back; off, Limit sets the maximum number returned.
Draft
4 operationsCreate a draft
draft.createWhat you see in n8n
Notes & use cases
Writes an email into the Drafts folder and stops there. Nothing leaves the mailbox until a person clicks send. That makes it the safest way to automate a reply.
Key parameters
- Subject, Message and Email Type: the draft content, in Text or HTML.
- To Email: optional, so a draft can wait without a recipient.
- Thread ID: attaches the draft to an existing conversation, as in
18cc573e2431878f. - From Alias Name or ID: the alias the draft goes out from, chosen in the dropdown that loads from the credential, or set with an expression.
Delete a draft
draft.deleteWhat you see in n8n
Notes & use cases
Throws away a draft the workflow no longer needs. Housekeeping, but it keeps the Drafts folder from becoming a graveyard.
Key parameters
- Draft ID: the identifier of the draft, which looks like
r-3254521568507167962and has nothing in common with a message ID.
Get a draft
draft.getWhat you see in n8n
Notes & use cases
Reads one draft back, attachments included when the workflow asks for them.
Key parameters
- Draft ID: the draft to retrieve.
- Download Attachments: the files arrive as binary data, named from Attachment Prefix plus an index that starts at 0.
Get many drafts
draft.getAllWhat you see in n8n
Notes & use cases
Lists the drafts sitting in the mailbox, with the same paging logic as the message operations.
Key parameters
- Return All: on, every draft comes back; off, Limit stops the list.
- Include Spam and Trash: on, drafts filed in Spam and Trash count too.
- Download Attachments and Attachment Prefix: the same binary naming as the single Get.
Thread
8 operationsAdd label to thread
thread.addLabelsWhat you see in n8n
Notes & use cases
Labels applied here cover the whole conversation, not just the message that arrived last.
Key parameters
- Thread ID: the Gmail identifier of the conversation, a string like
172ce2c4a72cc243, usually carried over as{{ $json.threadId }}from the previous node. - Label Names or IDs: pick them from the list n8n reads out of the connected account, or pass label IDs through an expression when an earlier step decides which one applies.
Delete a thread
thread.deleteWhat you see in n8n
Notes & use cases
Nothing survives this one: the thread and all its messages go immediately and permanently, and the action cannot be undone. When a way back matters, Trash does the same job without burning the bridge.
Key parameters
- Thread ID: the identifier of the conversation the node operates on, so a wrong value wipes the wrong exchange. Reading the thread first and passing its ID forward is the safe pattern.
Get a thread
thread.getWhat you see in n8n
Notes & use cases
Fetching one conversation gives the workflow its messages in a single item, and Simplify decides how heavy that item gets.
Key parameters
- Thread ID: the identifier of the conversation to retrieve.
- Simplify: on by default, it returns a simplified version instead of the raw data, so message IDs, labels and the headers From, To, CC, BCC and Subject. Turn it off for the raw response.
- Return Only Messages: found under Options, it keeps only the messages of the thread in the output.
Get many threads
thread.getAllWhat you see in n8n
Notes & use cases
When a workflow needs a batch of conversations rather than one, this operation lists them and sends one item per thread down the branch.
Key parameters
- Return All and Limit: with Return All on, n8n walks the pages of the Gmail API to the end; off, Limit caps how many threads come back.
- Search: the same syntax as the Gmail search box,
has:attachmentfor example, so a query tested by hand is reusable as is. - Read Status: unread threads only, read only, or both.
- Received After and Received Before: inside an expression, a date in ISO format or a timestamp in milliseconds.
Remove label from thread
thread.removeLabelsWhat you see in n8n
Notes & use cases
Tagging is only half the loop. This operation strips labels off a conversation once its state changes, which keeps a filtered Gmail view from filling up with threads nobody has to look at anymore.
Key parameters
- Thread ID: the conversation losing the label, taken from the trigger or from a listing step upstream.
- Label Names or IDs: the labels to take off, chosen in the dropdown or given as IDs through an expression; several can go at once.
Reply to a message
thread.replyWhat you see in n8n
Notes & use cases
A reply sent from here stays inside the existing conversation instead of opening a new one, as recipients expect when the exchange already has a history.
Key parameters
- Thread ID: the conversation the answer belongs to.
- Email Type: Text or HTML, depending on whether the body carries markup.
- Message: the body itself, written in the expression editor when it mixes fixed wording and data from earlier nodes.
- Reply to Sender Only: in Options, it answers the sender alone, while Reply to Recipients Only leaves the sender out; CC, BCC, Sender Name and Attachments sit in the same collection.
Trash a thread
thread.trashWhat you see in n8n
Notes & use cases
Trash moves the conversation and all its messages out of the inbox while keeping them recoverable, which makes it the operation to reach for when a sorting rule might be wrong.
Key parameters
- Thread ID: the conversation to move to the trash, fed by any step upstream that returns a thread.
Untrash a thread
thread.untrashWhat you see in n8n
Notes & use cases
Sometimes the rule that trashed a conversation was too eager. This operation recovers the thread and all its messages from the trash and puts them back in the mailbox.
Key parameters
- Thread ID: the identifier of the conversation to recover, which is a good reason to store it somewhere when a workflow trashes threads on its own.
Need help automating Gmail with n8n?
A person reads every message.


