This workflow corresponds to n8n.io template #7262 — we link there as the canonical source.
This workflow follows the Gmail → Google Sheets recipe pattern — see all workflows that pair these two integrations.
The workflow JSON
Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →
{
"nodes": [
{
"id": "759d4f88-c6de-4cee-af9a-628102d93200",
"name": "\ud83d\udce7 Gmail Webhook Trigger",
"type": "n8n-nodes-base.webhook",
"notes": "\ud83d\udd27 SETUP REQUIRED:\n1. Copy webhook URL after saving\n2. Configure Gmail webhook in Google Cloud Console\n3. Set up Gmail push notifications\n4. Test with sample email",
"position": [
-800,
464
],
"parameters": {
"path": "gmail-webhook",
"options": {},
"httpMethod": "POST",
"responseMode": "responseNode"
},
"typeVersion": 1
},
{
"id": "000229fb-153f-4db4-ad19-cda7b78f3b57",
"name": "\ud83d\udce9 Get Email Details",
"type": "n8n-nodes-base.gmail",
"notes": "\ud83d\udd27 SETUP REQUIRED:\n1. Create Gmail OAuth2 credentials\n2. Add scopes: gmail.readonly, gmail.modify\n3. Authorize the connection\n4. Test connection",
"position": [
-576,
464
],
"parameters": {
"messageId": "={{ $json.message.data.messageId }}",
"operation": "get"
},
"credentials": {
"gmailOAuth2": {
"name": "<your credential>"
}
},
"typeVersion": 2
},
{
"id": "daf62cc0-3dc9-4b67-801b-3c48eeb3d4df",
"name": "\ud83e\udd16 AI Email Analyzer",
"type": "n8n-nodes-base.openAi",
"notes": "\ud83d\udd27 SETUP REQUIRED:\n1. Get OpenAI API key\n2. Add to credentials\n3. Choose model (gpt-4 recommended)\n4. Adjust temperature for consistency\n5. Test with sample emails",
"position": [
-368,
464
],
"parameters": {
"model": "gpt-4",
"prompt": "=Analyze this email and provide a JSON response with the following structure:\n{\n \"category\": \"urgent|important|promotional|spam|personal|work\",\n \"sentiment\": \"positive|negative|neutral\",\n \"priority\": \"high|medium|low\",\n \"action_needed\": \"reply|forward|archive|delete|flag\",\n \"summary\": \"brief summary in 1-2 sentences\",\n \"suggested_response\": \"suggested response if reply needed\",\n \"keywords\": [\"array\", \"of\", \"relevant\", \"keywords\"]\n}\n\nEmail details:\nFrom: {{ $node['\ud83d\udce9 Get Email Details'].json.payload.headers.find(h => h.name === 'From').value }}\nSubject: {{ $node['\ud83d\udce9 Get Email Details'].json.payload.headers.find(h => h.name === 'Subject').value }}\nBody: {{ $node['\ud83d\udce9 Get Email Details'].json.snippet }}",
"options": {
"maxTokens": 1000,
"temperature": 0.3
},
"requestOptions": {}
},
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
},
"typeVersion": 1
},
{
"id": "cf1eba5b-6645-4b21-b5bb-d8cb4ae5015e",
"name": "\ud83d\udea6 Priority Router",
"type": "n8n-nodes-base.if",
"notes": "\ud83d\udcdd POST-IT NOTE:\nRoutes emails based on AI analysis\n- High priority \u2192 Immediate notification\n- Medium/Low \u2192 Standard processing\n- Customize conditions as needed",
"position": [
-144,
464
],
"parameters": {
"options": {},
"conditions": {
"options": {
"leftValue": "",
"caseSensitive": false,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"operator": {
"type": "string",
"operation": "equals"
},
"leftValue": "={{ JSON.parse($json.choices[0].message.content).priority }}",
"rightValue": "high"
}
]
}
},
"typeVersion": 2
},
{
"id": "cbb52bdb-1065-4d4f-b09f-08e9367940f4",
"name": "\ud83d\udea8 High Priority Alert",
"type": "n8n-nodes-base.gmail",
"notes": "\ud83d\udd27 SETUP REQUIRED:\n1. Update notification email address\n2. Customize alert message\n3. Consider using Slack/Teams instead\n4. Test notification delivery",
"position": [
80,
352
],
"parameters": {
"message": "=High priority email received:\n\nFrom: {{ $node['\ud83d\udce9 Get Email Details'].json.payload.headers.find(h => h.name === 'From').value }}\nSubject: {{ $node['\ud83d\udce9 Get Email Details'].json.payload.headers.find(h => h.name === 'Subject').value }}\n\nAI Summary: {{ JSON.parse($node['\ud83e\udd16 AI Email Analyzer'].json.choices[0].message.content).summary }}\n\nSuggested Action: {{ JSON.parse($node['\ud83e\udd16 AI Email Analyzer'].json.choices[0].message.content).action_needed }}\n\nView in Gmail: https://mail.google.com/mail/u/0/#inbox/{{ $node['\ud83d\udce9 Get Email Details'].json.id }}",
"options": {},
"subject": "\ud83d\udea8 High Priority Email Alert"
},
"credentials": {
"gmailOAuth2": {
"name": "<your credential>"
}
},
"typeVersion": 2
},
{
"id": "b77a498a-001c-4029-a60a-1307dafa27fc",
"name": "\ud83d\udee1\ufe0f Spam Detector",
"type": "n8n-nodes-base.if",
"notes": "\ud83d\udcdd POST-IT NOTE:\nDetects spam emails\n- Auto-delete or move to spam\n- Log spam attempts\n- Update spam filters",
"position": [
80,
560
],
"parameters": {
"options": {},
"conditions": {
"options": {
"leftValue": "",
"caseSensitive": false,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"operator": {
"type": "string",
"operation": "equals"
},
"leftValue": "={{ JSON.parse($node['\ud83e\udd16 AI Email Analyzer'].json.choices[0].message.content).category }}",
"rightValue": "spam"
}
]
}
},
"typeVersion": 2
},
{
"id": "1b7b3f23-01cb-42c0-8985-79696d0a38b2",
"name": "\ud83d\uddd1\ufe0f Move to Spam",
"type": "n8n-nodes-base.gmail",
"notes": "\ud83d\udcdd POST-IT NOTE:\nMoves spam to spam folder\n- Removes from inbox\n- Adds spam label\n- Consider auto-delete after time",
"position": [
304,
656
],
"parameters": {
"operation": "modify"
},
"typeVersion": 2
},
{
"id": "63ae92b9-71c5-41e9-82f7-606985a1e4f3",
"name": "\ud83d\udcac Auto-Reply Detector",
"type": "n8n-nodes-base.if",
"notes": "\ud83d\udcdd POST-IT NOTE:\nDetects emails needing replies\n- AI suggests response\n- Option for auto-send or draft\n- Customize reply rules",
"position": [
304,
480
],
"parameters": {
"options": {},
"conditions": {
"options": {
"leftValue": "",
"caseSensitive": false,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"operator": {
"type": "string",
"operation": "equals"
},
"leftValue": "={{ JSON.parse($node['\ud83e\udd16 AI Email Analyzer'].json.choices[0].message.content).action_needed }}",
"rightValue": "reply"
}
]
}
},
"typeVersion": 2
},
{
"id": "778961c6-43d4-4624-abdb-3d6bebcf6249",
"name": "\ud83d\udcdd Create Reply Draft",
"type": "n8n-nodes-base.gmail",
"notes": "\ud83d\udcdd POST-IT NOTE:\nCreates AI-generated reply draft\n- Review before sending\n- Customize response style\n- Option to auto-send for simple cases",
"position": [
528,
352
],
"parameters": {
"message": "={{ JSON.parse($node['\ud83e\udd16 AI Email Analyzer'].json.choices[0].message.content).suggested_response }}\n\n---\nThis is an AI-generated draft. Please review before sending.",
"options": {},
"subject": "=Re: {{ $node['\ud83d\udce9 Get Email Details'].json.payload.headers.find(h => h.name === 'Subject').value }}",
"resource": "draft"
},
"typeVersion": 2
},
{
"id": "4a6f205f-80e6-42fc-be48-a672b76163ee",
"name": "\ud83c\udff7\ufe0f Categorize Email",
"type": "n8n-nodes-base.gmail",
"notes": "\ud83d\udd27 SETUP REQUIRED:\n1. Create Gmail labels:\n - URGENT, IMPORTANT\n - PROMOTIONAL, PERSONAL\n - WORK, PROJECTS\n2. Customize categories\n3. Set up label colors",
"position": [
528,
560
],
"parameters": {
"operation": "modify"
},
"typeVersion": 2
},
{
"id": "9be9a801-9b54-45f2-a820-4a35dc7915bb",
"name": "\ud83d\udcca Log to Spreadsheet",
"type": "n8n-nodes-base.googleSheets",
"notes": "\ud83d\udd27 SETUP REQUIRED:\n1. Create Google Sheets log\n2. Add headers: timestamp, messageId, from, subject, category, priority, sentiment, action_taken, ai_summary\n3. Share sheet with service account\n4. Update spreadsheet ID",
"position": [
752,
464
],
"parameters": {
"resource": "spreadsheet",
"operation": "appendOrUpdate"
},
"typeVersion": 4
},
{
"id": "0f78144e-bb3a-4065-b15e-3294750b13b7",
"name": "\u2705 Webhook Response",
"type": "n8n-nodes-base.respondToWebhook",
"notes": "\ud83d\udcdd POST-IT NOTE:\nSends response back to Gmail\n- Confirms processing\n- Includes analysis results\n- Required for webhook completion",
"position": [
960,
464
],
"parameters": {
"options": {},
"respondWith": "json",
"responseBody": {
"details": {
"category": "={{ JSON.parse($node['\ud83e\udd16 AI Email Analyzer'].json.choices[0].message.content).category }}",
"priority": "={{ JSON.parse($node['\ud83e\udd16 AI Email Analyzer'].json.choices[0].message.content).priority }}",
"messageId": "={{ $node['\ud83d\udce9 Get Email Details'].json.id }}",
"action_taken": "={{ JSON.parse($node['\ud83e\udd16 AI Email Analyzer'].json.choices[0].message.content).action_needed }}"
},
"message": "Email processed successfully",
"success": true
}
},
"typeVersion": 1
},
{
"id": "fe23603a-8174-48ee-8ebf-3cabf507ecd7",
"name": "Sticky Note9",
"type": "n8n-nodes-base.stickyNote",
"position": [
-768,
-320
],
"parameters": {
"color": 3,
"width": 576,
"height": 560,
"content": "## Need a tailor-made workflow? Tell me about your business and get a free proposal:\n\n**[Start here \u2192 Custom Automation Form](https://taskmorphr.com/contact)**\n\n---\n## \ud83d\udcc8 Cost-Savings Snapshot \nCurious what automation could save you? \nRun the 60-second calculator:\n\n**[ROI / Cost Comparison](https://taskmorphr.com/cost-comparison)**\n\n---\n### \u2709\ufe0f Reach me directly \n`paul@taskmorphr.com`"
},
"typeVersion": 1
},
{
"id": "4ca8fea5-6f43-41f9-9e68-e2dca7f73d8e",
"name": "Sticky Note10",
"type": "n8n-nodes-base.stickyNote",
"position": [
-464,
64
],
"parameters": {
"color": 3,
"width": 224,
"height": 128,
"content": "### \ud83d\udee0\ufe0f Build it yourself \nBrowse every ready-made workflow: \n[Full Template Pack \u2014 coming soon](https://n8n.io/creators/diagopl/)\n"
},
"typeVersion": 1
},
{
"id": "f2cbe293-04fa-48c4-8849-4637063becf3",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1776,
-304
],
"parameters": {
"width": 848,
"height": 2272,
"content": "# Gmail AI Email Manager - Setup Guide\n\n## \ud83c\udfaf Workflow Overview\n\nThis workflow will create an intelligent Gmail email manager that can:\n- Monitor incoming emails via webhook\n- Analyze email content using AI\n- Categorize emails automatically\n- Generate smart responses\n- Take actions based on email content\n- Send notifications for important emails\n\n## \ud83d\udccb Pre-Setup Checklist\n\nBefore we build the workflow, let me gather the necessary information and validate our approach.\n\n### Phase 1: Discovery & Planning\n- [ ] Search for Gmail nodes\n- [ ] Find AI analysis nodes\n- [ ] Identify webhook trigger options\n- [ ] Check notification nodes\n\n### Phase 2: Configuration Requirements\n- [ ] Gmail API credentials\n- [ ] AI service (OpenAI/Claude) API key\n- [ ] Webhook URL setup\n- [ ] Email classification rules\n\n## \ud83d\udd27 Setup Instructions\n\n### Step 1: Gmail API Setup\n1. Go to Google Cloud Console\n2. Create new project or select existing\n3. Enable Gmail API\n4. Create OAuth 2.0 credentials\n5. Add authorized redirect URI: `https://your-n8n-instance.com/rest/oauth2-credential/callback`\n\n### Step 2: AI Service Setup\nChoose one of the following:\n- **OpenAI**: Get API key from platform.openai.com\n- **Claude**: Get API key from console.anthropic.com\n- **Local AI**: Set up Ollama or similar\n\n### Step 3: n8n Credentials\n1. Gmail OAuth2: Add client ID, secret, and scopes\n2. AI Service: Add API key\n3. Webhook: Configure webhook URL\n\n# Gmail AI Email Manager - Setup Guide\n\n## \ud83d\udd27 Quick Setup Checklist\n\n### 1. Google Cloud Console\n- [ ] Enable Gmail API\n- [ ] Create OAuth2 credentials \n- [ ] Add redirect URI: `https://your-n8n.com/rest/oauth2-credential/callback`\n- [ ] Set up Gmail push notifications with Pub/Sub\n\n### 2. API Keys\n- [ ] Get OpenAI API key from platform.openai.com\n- [ ] Create Google Sheets for logging (optional)\n\n### 3. n8n Credentials\n- [ ] **Gmail OAuth2**: Client ID, Secret, Scopes: `gmail.readonly,gmail.modify,gmail.compose`\n- [ ] **OpenAI API**: Your API key\n\n### 4. Gmail Labels (Create these)\n- [ ] URGENT (red) \n- [ ] IMPORTANT (orange)\n- [ ] PROMOTIONAL (purple)\n- [ ] PERSONAL (green) \n- [ ] WORK (blue)\n- [ ] SPAM (gray)\n\n### 5. Update Workflow Values\n- [ ] High Priority Alert: Change notification email\n- [ ] Spreadsheet Log: Update sheet ID (if using)\n- [ ] Webhook: Copy URL after saving workflow\n\n### 6. Test\n- [ ] Save & activate workflow\n- [ ] Send test email to Gmail\n- [ ] Check execution log\n- [ ] Verify auto-categorization works\n\n**That's it! Your AI email manager is ready! \ud83d\ude80**"
},
"typeVersion": 1
}
],
"connections": {
"\ud83d\uddd1\ufe0f Move to Spam": {
"main": [
[
{
"node": "\ud83d\udcca Log to Spreadsheet",
"type": "main",
"index": 0
}
]
]
},
"\ud83d\udea6 Priority Router": {
"main": [
[
{
"node": "\ud83d\udea8 High Priority Alert",
"type": "main",
"index": 0
}
],
[
{
"node": "\ud83d\udee1\ufe0f Spam Detector",
"type": "main",
"index": 0
}
]
]
},
"\ud83d\udee1\ufe0f Spam Detector": {
"main": [
[
{
"node": "\ud83d\uddd1\ufe0f Move to Spam",
"type": "main",
"index": 0
}
],
[
{
"node": "\ud83d\udcac Auto-Reply Detector",
"type": "main",
"index": 0
}
]
]
},
"\ud83d\udce9 Get Email Details": {
"main": [
[
{
"node": "\ud83e\udd16 AI Email Analyzer",
"type": "main",
"index": 0
}
]
]
},
"\ud83e\udd16 AI Email Analyzer": {
"main": [
[
{
"node": "\ud83d\udea6 Priority Router",
"type": "main",
"index": 0
}
]
]
},
"\ud83d\udcca Log to Spreadsheet": {
"main": [
[
{
"node": "\u2705 Webhook Response",
"type": "main",
"index": 0
}
]
]
},
"\ud83d\udcdd Create Reply Draft": {
"main": [
[
{
"node": "\ud83c\udff7\ufe0f Categorize Email",
"type": "main",
"index": 0
}
]
]
},
"\ud83c\udff7\ufe0f Categorize Email": {
"main": [
[
{
"node": "\ud83d\udcca Log to Spreadsheet",
"type": "main",
"index": 0
}
]
]
},
"\ud83d\udcac Auto-Reply Detector": {
"main": [
[
{
"node": "\ud83d\udcdd Create Reply Draft",
"type": "main",
"index": 0
}
],
[
{
"node": "\ud83c\udff7\ufe0f Categorize Email",
"type": "main",
"index": 0
}
]
]
},
"\ud83d\udea8 High Priority Alert": {
"main": [
[
{
"node": "\ud83c\udff7\ufe0f Categorize Email",
"type": "main",
"index": 0
}
]
]
},
"\ud83d\udce7 Gmail Webhook Trigger": {
"main": [
[
{
"node": "\ud83d\udce9 Get Email Details",
"type": "main",
"index": 0
}
]
]
}
}
}
Credentials you'll need
Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.
gmailOAuth2openAiApi
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
This workflow will create an intelligent Gmail email manager that can: Monitor incoming emails via webhook Analyze email content using AI Categorize emails automatically Generate smart responses Take actions based on email content Send notifications for important emails
Source: https://n8n.io/workflows/7262/ — original creator credit. Request a take-down →
Related workflows
Workflows that share integrations, category, or trigger type with this one. All free to copy and import.
Instantly map all internal URLs, perform AI-powered (ChatGPT) analysis, and deliver results in HTML via webhook, Google Sheets, or email. All from your own n8n instance!
Watch on Youtube▶️
This is for creators who run Patreon and/or Kofi pages, support donations and want to automate their communication process.
Imagine your recruitment process transformed into a sleek, efficient, AI-powered assembly line for talent. That's exactly what this system creates. It automates the heavy lifting, allowing your human
Transform customer feedback into actionable insights automatically with AI analysis, professional PDF reports, personalized emails, and real-time team notifications. Overview Features Demo Prerequisit