To integrate n8n with Gmail, follow these steps:
β
Step-by-Step Guide to Integrate Gmail with n8n
π§ 1. Set Up a Gmail (Google) OAuth2 Credential
Go to Google Cloud Console.
Create a new project or select an existing one.
Navigate to APIs & Services > OAuth consent screen:
Go to Credentials > Create Credentials > OAuth client ID
Application type: Web application
Authorized redirect URI (very important):
https://<your-n8n-domain>/rest/oauth2-credential/callback
If using local, it's usually http://localhost:5678/rest/oauth2-credential/callback
Copy the Client ID and Client Secret
In n8n:
Go to Credentials
Create new Gmail OAuth2 API credential
Paste Client ID and Secret
Set the appropriate scopes
Save and click Connect to authorize via Google
π₯ 2. Use Gmail Node in a Workflow
Example: Read New Emails
Create new workflow
Add Gmail Trigger node:
Example: Send Email
- Add Gmail node:
- Resource: Message
- Operation: Send
- Fields:
- To:
your_email@gmail.com
- Subject:
Test from n8n
- Message:
This is a test message
- Use same Gmail OAuth2 credential
π 3. Activate Workflow
- Click Activate in top-right of n8n to make the Gmail trigger live.
π Notes:
- Gmail API may require your app to be verified by Google for external use.
- For testing, use a Gmail account where you can authorize unverified apps.
π Bonus Tip: Filter Emails
You can use expressions like:
"from:noreply@someapp.com subject:Alert"
in the Search String field in Gmail Trigger.
Hereβs a ready-to-import n8n JSON workflow that:
- β
Watches for new emails in Gmail
- β
Sends a notification email in response (e.g., auto-reply or alert)
π₯ Gmail Integration Workflow (JSON)
{
"name": "Gmail Auto-Reply Workflow",
"nodes": [
{
"parameters": {
"resource": "message",
"operation": "watch",
"additionalFields": {}
},
"id": "Gmail Trigger",
"name": "Gmail Trigger",
"type": "n8n-nodes-base.gmailTrigger",
"typeVersion": 1,
"position": [240, 300],
"credentials": {
"gmailOAuth2Api": {
"id": "__YOUR_CREDENTIAL_ID__",
"name": "__YOUR_CREDENTIAL_NAME__"
}
}
},
{
"parameters": {
"resource": "message",
"operation": "send",
"to": "your_email@gmail.com",
"subject": "New Email Received",
"message": "You just received a new email via Gmail Trigger."
},
"id": "Send Email",
"name": "Send Email",
"type": "n8n-nodes-base.gmail",
"typeVersion": 1,
"position": [480, 300],
"credentials": {
"gmailOAuth2Api": {
"id": "__YOUR_CREDENTIAL_ID__",
"name": "__YOUR_CREDENTIAL_NAME__"
}
}
}
],
"connections": {
"Gmail Trigger": {
"main": [
[
{
"node": "Send Email",
"type": "main",
"index": 0
}
]
]
}
}
}
β
Instructions to Use
Open n8n.
Go to Workflows > Import from File or Clipboard
Paste the JSON above.
Replace: