AI邮件助手:使用ChatGPT摘要和Slack摘要优先处理Gmail
高级
这是一个Ticket Management, AI Summarization领域的自动化工作流,包含 16 个节点。主要使用 If, Code, Wait, Gmail, Slack 等节点。 使用Gmail、GPT-4o和Slack紧急通知的自动邮件分诊
前置要求
- •Google 账号和 Gmail API 凭证
- •Slack Bot Token 或 Webhook URL
- •Google Sheets API 凭证
- •OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "Yg8U1sA0hSJJ6p3D",
"meta": {
"instanceId": "2fcc626393a7afeed212c73b14008aa85fc99b8f4571e296293edf751709d402",
"templateId": "5446",
"templateCredsSetupCompleted": true
},
"name": "AI 邮件助手:使用 ChatGPT 摘要和 Slack 摘要优先处理 Gmail",
"tags": [],
"nodes": [
{
"id": "19658d53-51a2-4566-a57e-da51db7b68d1",
"name": "计划触发器1",
"type": "n8n-nodes-base.scheduleTrigger",
"position": [
-800,
1344
],
"parameters": {
"rule": {
"interval": [
{
"field": "hours",
"hoursInterval": 4
}
]
}
},
"typeVersion": 1.2
},
{
"id": "5379bec6-cb2c-4974-ae39-f35871d797ab",
"name": "获取多条消息",
"type": "n8n-nodes-base.gmail",
"position": [
-400,
1344
],
"webhookId": "94dba404-f0c9-424f-a0ea-0f2971d4b767",
"parameters": {
"filters": {
"receivedAfter": "={{ new Date(Date.now() - 4 * 60 * 60 * 1000).toISOString() }}"
},
"operation": "getAll",
"returnAll": true
},
"credentials": {
"gmailOAuth2": {
"id": "0W0TEFPGobwblJ15",
"name": "Gmail account"
}
},
"executeOnce": true,
"typeVersion": 2.1
},
{
"id": "f25dadff-b33b-4be1-aac3-1c695b39ef93",
"name": "获取多个标签",
"type": "n8n-nodes-base.gmail",
"position": [
-608,
1344
],
"webhookId": "9c79ec9c-9a3d-4935-aa50-39ee95a3fc96",
"parameters": {
"resource": "label",
"returnAll": true
},
"credentials": {
"gmailOAuth2": {
"id": "0W0TEFPGobwblJ15",
"name": "Gmail account"
}
},
"typeVersion": 2.1
},
{
"id": "8508ce2a-7394-4ed4-88a1-31f1e21963dd",
"name": "向模型发送消息1",
"type": "@n8n/n8n-nodes-langchain.openAi",
"position": [
-208,
1344
],
"parameters": {
"modelId": {
"__rl": true,
"mode": "list",
"value": "gpt-4o-mini",
"cachedResultName": "GPT-4O-MINI"
},
"options": {},
"messages": {
"values": [
{
"content": "=You're an email assistant for a busy startup founder. Classify the email content into the following fields and return **only raw JSON** (no markdown):\n\n{\n \"summary\": [Short summary of the email in 1 sentence],\n \"urgency\": [High, Medium, Low],\n \"category\": [Investor, Customer, Support, Spam, Other],\n \"intent\": [\"To respond\", \"Awaiting reply\", \"FYI\", \"Notification\", \"Meeting update\", \"Marketing\"]\n}\n\nThe descriptions of the intents are as follows:\n1. To respond: Emails you need to respond to\n\n2.FYI: Emails that don't require your response, but are important\n\n3. Notification: Automated updates from tools you use or Team chats in tools like Google Docs or Microsoft Office\n\n4. Meeting update: Calendar updates from Zoom, Google Meet, etc\n\n5. Awaiting reply: Emails you're expecting a reply to\n\n6. Actioned: Email threads that have been resolved\n\n7. Marketing: Marketing or cold emails\n\nAnalyze the following email:\n\nSubject: {{ $json.Subject }}\nBody: {{ $json.snippet }}\n\nReturn only valid JSON with no extra formatting.\n"
}
]
}
},
"credentials": {
"openAiApi": {
"id": "rQWxiEOrSM4mtAcq",
"name": "OpenAi account"
}
},
"typeVersion": 1.8
},
{
"id": "e24a7261-6f06-4c2e-949b-37f3b4b78347",
"name": "条件判断1",
"type": "n8n-nodes-base.if",
"position": [
416,
1344
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "or",
"conditions": [
{
"id": "1ec24de2-2e64-4386-aa00-62603a63aef5",
"operator": {
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.urgency }}",
"rightValue": "High"
}
]
}
},
"typeVersion": 2.2
},
{
"id": "892e956a-c199-42fa-a20c-d7302f0e515b",
"name": "发送消息2",
"type": "n8n-nodes-base.slack",
"position": [
624,
1248
],
"webhookId": "8d75cfb9-ac55-4745-b37d-013995518ff1",
"parameters": {
"text": "=*Siddhant, Important Email Detected* \nFrom: {{ $('Get many messages').item.json.From }}\n*Summary:* {{ $('Calculate Intent').item.json.summary }} \n*Urgency:* {{ $('Calculate Intent').item.json.urgency }} , *Category:* {{ $('Calculate Intent').item.json.category }}, *Intent:* {{ $('Calculate Intent').item.json.intent }}",
"select": "channel",
"channelId": {
"__rl": true,
"mode": "list",
"value": "C0981ERQ2SD",
"cachedResultName": "jarvis"
},
"otherOptions": {},
"authentication": "oAuth2"
},
"credentials": {
"slackOAuth2Api": {
"id": "pdmwBc22r7St3rs7",
"name": "Slack account"
}
},
"typeVersion": 2.3
},
{
"id": "bd4eb9b3-93a1-4a89-8926-892b75cda489",
"name": "为消息添加标签2",
"type": "n8n-nodes-base.gmail",
"position": [
624,
1424
],
"webhookId": "2e09aafe-567b-4205-8905-bc0cafee56cb",
"parameters": {
"labelIds": "={{ $json.label_id }}",
"messageId": "={{ $('Get many messages').item.json.id }}",
"operation": "addLabels"
},
"credentials": {
"gmailOAuth2": {
"id": "0W0TEFPGobwblJ15",
"name": "Gmail account"
}
},
"typeVersion": 2.1
},
{
"id": "aeb25e82-853f-4138-a587-354e6153bb07",
"name": "为消息添加标签3",
"type": "n8n-nodes-base.gmail",
"position": [
880,
1248
],
"webhookId": "2e09aafe-567b-4205-8905-bc0cafee56cb",
"parameters": {
"labelIds": "={{ $('Calculate Intent').item.json.label_id }}",
"messageId": "={{ $('Get many messages').item.json.id }}",
"operation": "addLabels"
},
"credentials": {
"gmailOAuth2": {
"id": "0W0TEFPGobwblJ15",
"name": "Gmail account"
}
},
"typeVersion": 2.1
},
{
"id": "601a7bea-42cb-44c2-9196-8304ef472f28",
"name": "发送消息3",
"type": "n8n-nodes-base.slack",
"position": [
464,
1680
],
"webhookId": "8d75cfb9-ac55-4745-b37d-013995518ff1",
"parameters": {
"text": "=🧠 *Inbox Assistant – Daily Digest* \n📅 *{{ $now.format(\"DD : HH:mm\") }}* \n━━━━━━━━━━━━━━━━━━━\n\n{{ $json.text }}\n",
"select": "channel",
"channelId": {
"__rl": true,
"mode": "list",
"value": "C0981ERQ2SD",
"cachedResultName": "jarvis"
},
"otherOptions": {},
"authentication": "oAuth2"
},
"credentials": {
"slackOAuth2Api": {
"id": "pdmwBc22r7St3rs7",
"name": "Slack account"
}
},
"typeVersion": 2.3
},
{
"id": "cd80d190-f7de-4931-8b06-62cbe4957a47",
"name": "计算意图",
"type": "n8n-nodes-base.code",
"position": [
176,
1344
],
"parameters": {
"mode": "runOnceForEachItem",
"jsCode": "let raw = $json.message?.content || $json.message || \"\";\n\n// Remove triple backticks (```json ... ```)\nraw = raw.replace(/```json|```/g, '').trim();\n\n// Fix smart quotes and other formatting problems\nraw = raw.replace(/[“”]/g, '\"').replace(/[‘’]/g, \"'\");\n\ntry {\n const parsed = JSON.parse(raw);\n\n\n return {\n summary: parsed.summary || \"No summary provided\",\n urgency: parsed.urgency || \"Unknown\",\n category: parsed.category || \"Unknown\",\n intent: parsed.intent || \"Unknown\",\n messgae_id: $('Get many messages').item.json.id,\n label_id: $(\"Get many labels\").all().find((item) => item.json.name === `AI Agent/${parsed.intent}`).json.id\n };\n} catch (err) {\n return {\n summary: \"⚠️ Failed to parse GPT output\",\n urgency: \"Unknown\",\n category: \"Unknown\",\n intent: \"Unknown\",\n error: err.message,\n original: raw\n };\n}\n"
},
"typeVersion": 2
},
{
"id": "a3acbae8-087a-47c5-9eb6-90a69ccedf8e",
"name": "在表格中添加行1",
"type": "n8n-nodes-base.googleSheets",
"position": [
1152,
1248
],
"parameters": {
"columns": {
"value": {
"From": "={{ $('Get many messages').item.json.From }}",
"Intent": "={{ $('Calculate Intent').item.json.intent }}",
"Summary": "={{ $('Calculate Intent').item.json.summary }}",
"Urgency": "={{ $('Calculate Intent').item.json.urgency }}",
"Category": "={{ $('Calculate Intent').item.json.category }}",
"TimeStamp": "={{ $now }}"
},
"schema": [
{
"id": "From",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "From",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Summary",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "Summary",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Intent",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "Intent",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Category",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "Category",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "TimeStamp",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "TimeStamp",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Urgency",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "Urgency",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [
"id"
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {},
"operation": "append",
"sheetName": {
"__rl": true,
"mode": "list",
"value": "gid=0",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1YYOaQw07tTObBbY0GyP3zULru6cs15MF7PPWby8pZXs/edit#gid=0",
"cachedResultName": "Sheet1"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1YYOaQw07tTObBbY0GyP3zULru6cs15MF7PPWby8pZXs",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1YYOaQw07tTObBbY0GyP3zULru6cs15MF7PPWby8pZXs/edit?usp=drivesdk",
"cachedResultName": "N8N - Emails"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "I429Zmc6KE4KsQWs",
"name": "Google Sheets account"
}
},
"typeVersion": 4.6
},
{
"id": "ab2a0b67-a248-42ea-b18c-81b658aaf9fa",
"name": "在工作表2中追加行",
"type": "n8n-nodes-base.googleSheets",
"position": [
896,
1424
],
"parameters": {
"columns": {
"value": {
"From": "={{ $('Get many messages').item.json.From }}",
"Intent": "={{ $('Calculate Intent').item.json.intent }}",
"Summary": "={{ $('Calculate Intent').item.json.summary }}",
"Urgency": "={{ $('Calculate Intent').item.json.urgency }}",
"Category": "={{ $('Calculate Intent').item.json.category }}",
"TimeStamp": "={{ $now }}"
},
"schema": [
{
"id": "From",
"type": "string",
"display": true,
"required": false,
"displayName": "From",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Summary",
"type": "string",
"display": true,
"required": false,
"displayName": "Summary",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Intent",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "Intent",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Category",
"type": "string",
"display": true,
"required": false,
"displayName": "Category",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "TimeStamp",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "TimeStamp",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Urgency",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "Urgency",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {},
"operation": "append",
"sheetName": {
"__rl": true,
"mode": "list",
"value": 215199590,
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1YYOaQw07tTObBbY0GyP3zULru6cs15MF7PPWby8pZXs/edit#gid=215199590",
"cachedResultName": "Sheet2"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1YYOaQw07tTObBbY0GyP3zULru6cs15MF7PPWby8pZXs",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1YYOaQw07tTObBbY0GyP3zULru6cs15MF7PPWby8pZXs/edit?usp=drivesdk",
"cachedResultName": "N8N - Emails"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "I429Zmc6KE4KsQWs",
"name": "Google Sheets account"
}
},
"typeVersion": 4.6
},
{
"id": "c361b887-c8e0-4644-96df-ce6cf8b35ef2",
"name": "从表格获取行2",
"type": "n8n-nodes-base.googleSheets",
"position": [
-320,
1680
],
"parameters": {
"options": {},
"sheetName": {
"__rl": true,
"mode": "list",
"value": 215199590,
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1YYOaQw07tTObBbY0GyP3zULru6cs15MF7PPWby8pZXs/edit#gid=215199590",
"cachedResultName": "Sheet2"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1YYOaQw07tTObBbY0GyP3zULru6cs15MF7PPWby8pZXs",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1YYOaQw07tTObBbY0GyP3zULru6cs15MF7PPWby8pZXs/edit?usp=drivesdk",
"cachedResultName": "N8N - Emails"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "I429Zmc6KE4KsQWs",
"name": "Google Sheets account"
}
},
"executeOnce": true,
"typeVersion": 4.6,
"alwaysOutputData": true
},
{
"id": "a534c64b-b747-44b5-8f03-483c6408dd02",
"name": "过滤时间戳",
"type": "n8n-nodes-base.code",
"position": [
-48,
1680
],
"parameters": {
"jsCode": "const HOURS = 0.5; // hours window\nconst now = new Date();\n\nreturn items.filter(item => {\n const timestamp = item.json.TimeStamp || item.json.timestamp || \"\";\n const urgency = (item.json.Urgency || item.json.urgency || \"\").toLowerCase();\n\n if (!timestamp) return false;\n\n const itemDate = new Date(timestamp);\n const hoursDiff = Math.abs((now - itemDate) / 36e5); // 36e5 = 60*60*1000\n\n console.log(hoursDiff)\n\n return hoursDiff <= HOURS && (urgency === \"low\" || urgency === \"medium\");\n});"
},
"typeVersion": 2
},
{
"id": "4d788dea-84fc-41e4-a7a7-880a58b68bbf",
"name": "每日摘要准备",
"type": "n8n-nodes-base.code",
"position": [
240,
1680
],
"parameters": {
"jsCode": "let text = ``;\n\nconst medium = [];\nconst low = [];\n\nitems.forEach(item => {\n const urgency = (item.json.Urgency || \"\").toLowerCase();\n const intent = (item.json.Intent || \"\").toLowerCase();\n if (urgency === \"medium\") {\n medium.push(item);\n } else if (\n urgency === \"low\" &&\n intent !== \"Marketing\"\n ) {\n low.push(item);\n }\n});\n\nif (medium.length === 0 && low.length === 0) {\n text += \"_No important messages today._\";\n} else {\n if (medium.length > 0) {\n text += \"*Medium Urgency:*\\n\";\n medium.forEach((item, index) => {\n text += `*${index + 1}.* ${item.json.Summary || \"No summary\"}\\nFrom: ${item.json.From || \"Unknown\"}\\nUrgency: ${item.json.Urgency || \"Unknown\"}, Category: ${item.json.Category || \"Unknown\"}, Intent: ${item.json.Intent || \"N/A\"}\\n\\n`;\n });\n }\n if (low.length > 0) {\n text += \"*Low Urgency:*\\n\";\n low.forEach((item, index) => {\n text += `*${index + 1}.* ${item.json.Summary || \"No summary\"}\\nFrom: ${item.json.From || \"Unknown\"}, Intent: ${item.json.Intent || \"N/A\"}\\n\\n`;\n });\n }\n}\n\nreturn [{ json: { text } }];"
},
"typeVersion": 2
},
{
"id": "6dddd9fa-fd59-4df0-9741-fea2382bb982",
"name": "等待",
"type": "n8n-nodes-base.wait",
"position": [
-560,
1680
],
"webhookId": "25c19479-3952-45f3-9d3b-4d141c81974d",
"parameters": {
"amount": 30
},
"typeVersion": 1.1
},
{
"id": "7e0d1871-1844-4d85-b512-6cb3fec2a5c1",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1520,
1200
],
"parameters": {
"width": 640,
"height": 736,
"content": "✅ 使用步骤"
},
"typeVersion": 1
}
],
"active": true,
"pinData": {},
"settings": {},
"versionId": "0ff6e2d1-0134-4838-99aa-ce3ff6044d1a",
"connections": {
"If1": {
"main": [
[
{
"node": "Send a message2",
"type": "main",
"index": 0
}
],
[
{
"node": "Add label to message2",
"type": "main",
"index": 0
}
]
]
},
"Wait": {
"main": [
[
{
"node": "Get row(s) from sheet2",
"type": "main",
"index": 0
}
]
]
},
"Get many labels": {
"main": [
[
{
"node": "Get many messages",
"type": "main",
"index": 0
}
]
]
},
"Send a message2": {
"main": [
[
{
"node": "Add label to message3",
"type": "main",
"index": 0
}
]
]
},
"Calculate Intent": {
"main": [
[
{
"node": "If1",
"type": "main",
"index": 0
}
]
]
},
"Filter timestamp": {
"main": [
[
{
"node": "Daily Digest Preparation",
"type": "main",
"index": 0
}
]
]
},
"Message a model1": {
"main": [
[
{
"node": "Calculate Intent",
"type": "main",
"index": 0
}
]
]
},
"Get many messages": {
"main": [
[
{
"node": "Message a model1",
"type": "main",
"index": 0
}
]
]
},
"Schedule Trigger1": {
"main": [
[
{
"node": "Get many labels",
"type": "main",
"index": 0
}
]
]
},
"Append row in sheet2": {
"main": [
[
{
"node": "Wait",
"type": "main",
"index": 0
}
]
]
},
"Add label to message2": {
"main": [
[
{
"node": "Append row in sheet2",
"type": "main",
"index": 0
}
]
]
},
"Add label to message3": {
"main": [
[
{
"node": "Append row in sheet1",
"type": "main",
"index": 0
}
]
]
},
"Get row(s) from sheet2": {
"main": [
[
{
"node": "Filter timestamp",
"type": "main",
"index": 0
}
]
]
},
"Daily Digest Preparation": {
"main": [
[
{
"node": "Send a message3",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
高级 - 工单管理, AI 摘要总结
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
收件箱助手
AI邮件助手:通过ChatGPT摘要和Slack摘要优先处理Gmail邮件
If
Code
Gmail
+5
14 节点Darsheel
工单管理
使用 AI 分诊自动化 Google Forms 的客户支持回复
使用GPT-4o-mini AI分诊的自动化Google Forms和Gmail客户支持
If
Set
Code
+7
22 节点Daiki Takayama
工单管理
主动智能客户支持中心
使用GPT-4、Gmail和Trello的自动邮件支持分诊
If
Code
Gmail
+6
14 节点Marth
工单管理
基于GPT-4的智能招聘与候选人互动系统
基于GPT-4的AI招聘系统,用于简历筛选与自动外联
If
Code
Wait
+8
30 节点Marth
人力资源
AI 客户支持分流与摘要系统
使用GPT-4o、Slack和CRM集成自动处理客户支持
If
Set
Code
+10
32 节点NodeAlchemy
工单管理
我的工作流程 2
使用ScrapeGraphAI、Google表格和Slack提醒构建支持工单分析仪表板
If
Code
Slack
+5
15 节点vinci-king-01
工单管理