This workflow corresponds to n8n.io template #5475 — we link there as the canonical source.
This workflow follows the Agent → Gmail 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 →
{
"id": "FSJP3VvgYM0hlloV",
"name": "Intelligent Email Assistant with AI Classification, Gmail Drafts, and Slack Notifications",
"tags": [
{
"id": "grLYSyd5iJcUTmvb",
"name": "ZenAgent Labs",
"createdAt": "2025-06-29T14:28:06.655Z",
"updatedAt": "2025-06-29T14:28:06.655Z"
}
],
"nodes": [
{
"id": "e777600d-4456-4bcd-b356-231a340e8da7",
"name": "Workflow Description",
"type": "n8n-nodes-base.stickyNote",
"position": [
-700,
140
],
"parameters": {
"width": 550,
"height": 1300,
"content": "## Intelligent Email Assistant with AI Classification, Gmail Drafts, and Slack Notifications\n\n**Created by [ZenAgent Labs](https://zenagentlabs.com)**\n\n\n\n### What it does\nThis workflow automatically processes incoming emails with intelligent AI classification, creating draft responses and sending Slack notifications based on email content.\n\n### How it works\n1. **Monitors emails** with the 'AI-Agent' label\n2. **AI classification** into categories: Inquiry, Support, Newsletter, Action Item\n3. **Adds appropriate labels** to emails automatically\n4. **Creates draft replies** for Support and Inquiry emails\n5. **Sends Slack notifications** for Action Items and Newsletter summaries\n\n### Setup Requirements\n- Gmail OAuth2 credentials configured\n- OpenAI API credentials (or other AI provider)\n- Slack OAuth2 credentials (if notifications desired)\n- Gmail labels created (see setup instructions below)\n\n### How to customize\n- Modify classification categories in the AI Agent\n- Adjust label mappings in the Parse Classification node\n- Customize draft response templates\n- Configure different Slack channels for different email types"
},
"typeVersion": 1
},
{
"id": "5825d614-da89-4262-810b-074f5a788ac4",
"name": "Gmail Setup Instructions",
"type": "n8n-nodes-base.stickyNote",
"position": [
0,
680
],
"parameters": {
"width": 380,
"height": 580,
"content": "## Gmail Label Setup Instructions\n\n**IMPORTANT:** You need to create these Gmail labels first:\n\n1. **Primary Label:** 'AI-Agent' (trigger label)\n2. **Classification Labels:**\n - 'Inquiry' \n - 'Support'\n - 'Newsletter'\n - 'Action-Item'\n\n**How to get Label IDs:**\n1. Run the Gmail Trigger node once\n2. Check the node output for available labels\n3. Copy the Label IDs and update the Parse Classification code\n4. Replace the Label IDs in the labelMapping object\n\n**Label Mapping (update these after you run the gmail node for the first time!):**\n- Inquiry: Label_123456789\n- Action-Item: Label_123456789\n- Support: Label_123456789\n- Newsletter: Label_123456789"
},
"typeVersion": 1
},
{
"id": "6a4ce1eb-3e14-4f7b-8dd2-884858e9edd3",
"name": "Gmail Trigger - AI Agent Label",
"type": "n8n-nodes-base.gmailTrigger",
"position": [
520,
660
],
"parameters": {
"simple": false,
"filters": {
"labelIds": []
},
"options": {},
"pollTimes": {
"item": [
{
"mode": "everyMinute"
}
]
}
},
"credentials": {
"gmailOAuth2": {
"name": "<your credential>"
}
},
"typeVersion": 1
},
{
"id": "575d0664-15f9-4c1a-bb85-702aa7406f02",
"name": "Extract Email Data",
"type": "n8n-nodes-base.set",
"position": [
740,
660
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "email-id",
"name": "emailId",
"type": "string",
"value": "={{ $json.id }}"
},
{
"id": "email-subject",
"name": "subject",
"type": "string",
"value": "={{ $json.subject }}"
},
{
"id": "email-from",
"name": "sender",
"type": "string",
"value": "={{ $json.from }}"
},
{
"id": "email-body",
"name": "content",
"type": "string",
"value": "={{ $json.text || $json.html }}"
},
{
"id": "timestamp",
"name": "receivedAt",
"type": "string",
"value": "={{ $json.date }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "9dc28e85-da76-4a56-bab7-2449eeeabd5a",
"name": "AI Agent - Email Classifier",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
960,
660
],
"parameters": {
"text": "=Email to analyze:\nFrom: {{ $json.sender }}\nSubject: {{ $json.subject }}\nContent: {{ $json.content }}",
"options": {
"systemMessage": "=You are an AI assistant for email classification. Your task is to analyze incoming emails and categorize them into one of the following categories:\n\n1. **Inquiry** - Requests from partners, prospects, or your network\n2. **Support** - Customer support requests, complaints, or help requests\n3. **Newsletter** - Marketing emails, newsletters, or promotional content\n4. **Actionpoint** - Emails requiring immediate action or follow-up tasks\n\nAnalyze the email content including:\n- Sender information\n- Subject line\n- Email content\n- Tone and urgency\n\nRespond with a JSON object in exactly this format:\n{\n \"category\": \"[One of: Inquiry, Support, Newsletter, Actionpoint]\",\n \"confidence\": [0.0-1.0],\n \"reasoning\": \"Brief explanation of why this category was chosen\",\n \"suggestedResponse\": \"Only for Inquiry and Support emails: A professional, friendly draft response in English\",\n \"summary\": \"Only for Newsletter emails: A summary of essential information. Particularly interesting and noteworthy for me are infos about AI agents and AI automation\"\n}\n\n"
},
"promptType": "define"
},
"typeVersion": 1.7
},
{
"id": "32502ca5-832f-4bf6-85b8-18452071d589",
"name": "OpenAI Chat Model",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
920,
920
],
"parameters": {
"model": "o3",
"options": {
"responseFormat": "json_object"
}
},
"typeVersion": 1
},
{
"id": "73c4e031-badb-4562-b791-4843c4b12cf9",
"name": "Parse AI Classification",
"type": "n8n-nodes-base.code",
"position": [
1280,
660
],
"parameters": {
"jsCode": "// Parse AI Agent output and prepare for routing\nconst aiOutput = $input.first().json.output;\nlet classification;\n\ntry {\n // Parse JSON string output from AI Agent\n classification = JSON.parse(aiOutput);\n} catch (error) {\n // Fallback if parsing fails\n classification = {\n category: \"Support\",\n confidence: 0.5,\n reasoning: \"AI response could not be parsed, defaulting to Support\",\n suggestedResponse: \"\"\n };\n}\n\n// Map categories to Gmail Label IDs\n// IMPORTANT: Update these Label IDs with your actual Gmail label IDs\nconst labelMapping = {\n \"Inquiry\": \"Label_123456789\",\n \"Actionpoint\": \"Label_123456789\", \n \"Support\": \"Label_123456789\",\n \"Newsletter\": \"Label_123456789\"\n};\n\n// Combine with original email data and add label ID\nreturn {\n json: {\n ...classification,\n labelId: labelMapping[classification.category] || labelMapping[\"Support\"], // Fallback to Support\n emailId: $('Extract Email Data').first().json.emailId,\n subject: $('Extract Email Data').first().json.subject,\n sender: $('Extract Email Data').first().json.sender,\n content: $('Extract Email Data').first().json.content,\n receivedAt: $('Extract Email Data').first().json.receivedAt\n }\n};"
},
"typeVersion": 2
},
{
"id": "858a4fbf-7ba3-497b-955c-20be5d6148c0",
"name": "AI Classification Info",
"type": "n8n-nodes-base.stickyNote",
"position": [
920,
140
],
"parameters": {
"width": 380,
"height": 380,
"content": "## AI Classification Logic\n\nThe AI analyzes emails based on:\n- **Sender domain** and content\n- **Keywords** in subject/content\n- **Tone** and urgency indicators\n- **Request patterns**\n\nConfidence values help with accuracy control.\n\n**Classification Categories:**\n- **Inquiry:** Partner/prospect requests\n- **Support:** Customer help requests\n- **Newsletter:** Marketing/promotional content\n- **Actionpoint:** Urgent tasks requiring action"
},
"typeVersion": 1
},
{
"id": "cfa9478c-ed03-4c78-b910-be6e48528888",
"name": "Add Classification Label",
"type": "n8n-nodes-base.gmail",
"position": [
1480,
660
],
"parameters": {
"labelIds": "={{ $json.labelId }}",
"messageId": "={{ $('Gmail Trigger - AI Agent Label').item.json.id }}",
"operation": "addLabels"
},
"credentials": {
"gmailOAuth2": {
"name": "<your credential>"
}
},
"typeVersion": 2.1
},
{
"id": "30ca3a6d-775d-485c-b978-3b902d94bda4",
"name": "Route by Category",
"type": "n8n-nodes-base.switch",
"position": [
1680,
660
],
"parameters": {
"rules": {
"values": [
{
"outputKey": "Draft",
"conditions": {
"options": {
"version": 1,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "bcdd0c26-f15f-495d-851f-428448a4809d",
"operator": {
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $('Parse AI Classification').item.json.category }}",
"rightValue": "=Support"
}
]
},
"renameOutput": true
},
{
"outputKey": "Draft",
"conditions": {
"options": {
"version": 1,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "1e4a4ac3-9a17-4431-ba3c-57143c1c3d4f",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $('Parse AI Classification').item.json.category }}",
"rightValue": "Inquiry"
}
]
},
"renameOutput": true
},
{
"outputKey": "Newsletter",
"conditions": {
"options": {
"version": 1,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "92882b71-a38c-456d-a767-9db4920c95a5",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $('Parse AI Classification').item.json.category }}",
"rightValue": "Newsletter"
}
]
},
"renameOutput": true
},
{
"outputKey": "Actionpoint",
"conditions": {
"options": {
"version": 1,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "3e4709bf-e84e-4963-af62-2b49f2147ca3",
"operator": {
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $('Parse AI Classification').item.json.category }}",
"rightValue": "Actionpoint"
}
]
},
"renameOutput": true
}
]
},
"options": {
"fallbackOutput": "none"
}
},
"typeVersion": 3
},
{
"id": "2bb9e810-b62b-43b5-9018-8a4ee43da90e",
"name": "Success Actions Info",
"type": "n8n-nodes-base.stickyNote",
"position": [
2440,
280
],
"parameters": {
"color": 4,
"width": 320,
"height": 280,
"content": "## Workflow Actions Summary\n\n\u2705 **Inquiry/Support emails** \u2192 Draft responses created\n\u2705 **Action Items** \u2192 Slack notifications sent\n\u2705 **Newsletters** \u2192 Slack summaries sent\n\u2705 **All emails** \u2192 Automatically labeled\n\n### Extension Possibilities:\n- Log to spreadsheet/database\n- Create tickets in support system\n- Send webhooks to external systems\n- Custom notification channels\n- Integration with CRM systems"
},
"typeVersion": 1
},
{
"id": "713a3bc5-8e0f-46f4-ad9b-87d7adc07dbd",
"name": "Error Handling Info",
"type": "n8n-nodes-base.stickyNote",
"position": [
2440,
600
],
"parameters": {
"color": 5,
"width": 320,
"height": 240,
"content": "## Error Handling & Monitoring\n\n### Current Features:\n- Fallback classification to 'Support'\n- JSON parsing error handling\n- Confidence scoring for accuracy\n\n### Enhancement Options:\n- Error notifications via Slack/email\n- Retry logic for failed classifications\n- Logging of failed attempts\n- Performance monitoring dashboard\n- Manual review queue for low-confidence items"
},
"typeVersion": 1
},
{
"id": "ba402d17-fb77-419e-87f2-f00414cf0892",
"name": "Create Draft Response",
"type": "n8n-nodes-base.gmail",
"position": [
2080,
460
],
"parameters": {
"message": "={{ $('Parse AI Classification').item.json.suggestedResponse }}",
"options": {
"threadId": "={{ $('Gmail Trigger - AI Agent Label').item.json.threadId }}"
},
"subject": "=Re: {{ $json.subject }}",
"resource": "draft"
},
"credentials": {
"gmailOAuth2": {
"name": "<your credential>"
}
},
"typeVersion": 2.1
},
{
"id": "59934725-d2f3-4faf-a9db-8a4187a81081",
"name": "Send Action Item Slack Alert",
"type": "n8n-nodes-base.slack",
"position": [
2080,
840
],
"parameters": {
"operation": "postMessage"
},
"typeVersion": 2.2
},
{
"id": "78cce31c-12b8-4c89-b362-07f92be4b3a9",
"name": "Send Newsletter Summary to Slack",
"type": "n8n-nodes-base.slack",
"position": [
2080,
660
],
"parameters": {
"operation": "postMessage"
},
"typeVersion": 2.3
},
{
"id": "f19d4daa-ff84-4421-8170-c7c9c86321f2",
"name": "Slack Setup Instructions",
"type": "n8n-nodes-base.stickyNote",
"position": [
1940,
20
],
"parameters": {
"width": 380,
"height": 360,
"content": "## Slack Integration Setup\n\n### Required Configuration:\n1. **Create Slack App** at api.slack.com\n2. **Add OAuth Scopes:**\n - `chat:write`\n - `channels:read`\n - `users:read`\n\n3. **Create Channels:**\n - `#action-items` (for urgent emails)\n - `#newsletters` (for newsletter summaries)\n\n4. **Customize Message Format:**\n - Edit the text templates in Slack nodes\n - Add mentions (@channel, @here)\n - Include custom formatting/emojis\n\n5. **Optional:** Configure different channels per email type"
},
"typeVersion": 1
}
],
"active": false,
"settings": {
"executionOrder": "v1"
},
"versionId": "60db44aa-f739-4a39-a086-f0726955927a",
"connections": {
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Agent - Email Classifier",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Route by Category": {
"main": [
[
{
"node": "Create Draft Response",
"type": "main",
"index": 0
}
],
[
{
"node": "Create Draft Response",
"type": "main",
"index": 0
}
],
[
{
"node": "Send Newsletter Summary to Slack",
"type": "main",
"index": 0
}
],
[
{
"node": "Send Action Item Slack Alert",
"type": "main",
"index": 0
}
]
]
},
"Extract Email Data": {
"main": [
[
{
"node": "AI Agent - Email Classifier",
"type": "main",
"index": 0
}
]
]
},
"Parse AI Classification": {
"main": [
[
{
"node": "Add Classification Label",
"type": "main",
"index": 0
}
]
]
},
"Add Classification Label": {
"main": [
[
{
"node": "Route by Category",
"type": "main",
"index": 0
}
]
]
},
"AI Agent - Email Classifier": {
"main": [
[
{
"node": "Parse AI Classification",
"type": "main",
"index": 0
}
]
]
},
"Gmail Trigger - AI Agent Label": {
"main": [
[
{
"node": "Extract Email Data",
"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.
gmailOAuth2
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
This workflow automatically processes incoming emails with intelligent AI classification, creating draft responses and sending Slack notifications based on email content. Monitors emails with the 'AI-Agent' label AI classification into categories: Inquiry, Support, Newsletter,…
Source: https://n8n.io/workflows/5475/ — 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.
Streamline customer support with a real-time, AI-powered answer engine that detects incoming support emails, classifies intent, identifies the customer’s GEO region, and generates a tailored reply rea
Monitors your AP inbox for incoming invoices, extracts structured data with AI, runs duplicate and vendor history checks against Supabase, then scores each invoice for fraud risk — routing suspicious
Gmail users report spending significant time manually sorting email, so this tool helps alleviate that burden. Gmail Trigger monitors unread emails every 2 minutes Once an email arrives, the content i
Email-Triage. Uses lmChatOpenAi, outputParserStructured, agent, toolWorkflow. Event-driven trigger; 27 nodes.
[](https://youtu.be/nC2mSry3xFo)