智能邮件分类
高级
这是一个Ticket Management, Multimodal AI领域的自动化工作流,包含 26 个节点。主要使用 Gmail, WhatsApp, GmailTrigger, OpenAi, LmChatOpenAi 等节点。 基于GPT和WhatsApp提醒的Gmail自动分类与回复系统
前置要求
- •Google 账号和 Gmail API 凭证
- •OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "j52UGeF9akxXBKRK",
"meta": {
"instanceId": "41a93cc6f329d5755684ac69c9a86d5c75d7dc780eea0b60d82055e6149e455f",
"templateCredsSetupCompleted": true
},
"name": "智能邮件分类",
"tags": [],
"nodes": [
{
"id": "9ae4ac61-98dd-425d-8ec3-85b0ad0da7c5",
"name": "Gmail 触发器",
"type": "n8n-nodes-base.gmailTrigger",
"position": [
-1184,
-496
],
"parameters": {
"filters": {},
"pollTimes": {
"item": [
{
"mode": "everyMinute"
}
]
}
},
"credentials": {
"gmailOAuth2": {
"id": "52mNI7KwytiCFBmo",
"name": "Gmail account 2"
}
},
"typeVersion": 1.2
},
{
"id": "a1a5959c-52fa-417c-8024-1512909e9fae",
"name": "OpenAI 聊天模型",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
-896,
-240
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4.1-mini"
},
"options": {}
},
"credentials": {
"openAiApi": {
"id": "LNuj9b67Zq2tZww5",
"name": "OpenAi account"
}
},
"typeVersion": 1.2
},
{
"id": "7d84dcde-f724-4b08-88db-c463791f76ca",
"name": "高优先级邮件",
"type": "n8n-nodes-base.gmail",
"position": [
-224,
-1024
],
"webhookId": "6e9c3f6d-f508-4668-97f9-704a5173e8fa",
"parameters": {
"labelIds": [
"Label_7974018348016773078"
],
"messageId": "={{ $('Gmail Trigger').item.json.id }}",
"operation": "addLabels"
},
"credentials": {
"gmailOAuth2": {
"id": "52mNI7KwytiCFBmo",
"name": "Gmail account 2"
}
},
"typeVersion": 2.1
},
{
"id": "aaac9866-4d4b-4c88-97c7-a8d15b20837d",
"name": "客户支持邮件",
"type": "n8n-nodes-base.gmail",
"position": [
-208,
-752
],
"webhookId": "6e9c3f6d-f508-4668-97f9-704a5173e8fa",
"parameters": {
"labelIds": [
"Label_7432353852807721490"
],
"messageId": "={{ $('Gmail Trigger').item.json.id }}",
"operation": "addLabels"
},
"credentials": {
"gmailOAuth2": {
"id": "52mNI7KwytiCFBmo",
"name": "Gmail account 2"
}
},
"typeVersion": 2.1
},
{
"id": "0f5b6666-002a-4090-94ad-dfb5f6e8247d",
"name": "推广邮件",
"type": "n8n-nodes-base.gmail",
"position": [
-208,
-528
],
"webhookId": "6e9c3f6d-f508-4668-97f9-704a5173e8fa",
"parameters": {
"labelIds": [
"Label_7974018348016773078"
],
"messageId": "={{ $('Gmail Trigger').item.json.id }}",
"operation": "addLabels"
},
"credentials": {
"gmailOAuth2": {
"id": "52mNI7KwytiCFBmo",
"name": "Gmail account 2"
}
},
"typeVersion": 2.1
},
{
"id": "9a886ba2-5721-4fdc-ad4e-7770803d61a6",
"name": "财务/账单邮件",
"type": "n8n-nodes-base.gmail",
"position": [
-96,
-208
],
"webhookId": "6e9c3f6d-f508-4668-97f9-704a5173e8fa",
"parameters": {
"labelIds": [
"Label_487984775758613877"
],
"messageId": "={{ $('Gmail Trigger').item.json.id }}",
"operation": "addLabels"
},
"credentials": {
"gmailOAuth2": {
"id": "52mNI7KwytiCFBmo",
"name": "Gmail account 2"
}
},
"typeVersion": 2.1
},
{
"id": "45f1546d-b619-42f5-a4ce-ee3bc3309886",
"name": "随机(一般/其他)邮件",
"type": "n8n-nodes-base.gmail",
"position": [
-240,
64
],
"webhookId": "6e9c3f6d-f508-4668-97f9-704a5173e8fa",
"parameters": {
"labelIds": [
"Label_4854753170056793401"
],
"messageId": "={{ $('Gmail Trigger').item.json.id }}",
"operation": "addLabels"
},
"credentials": {
"gmailOAuth2": {
"id": "52mNI7KwytiCFBmo",
"name": "Gmail account 2"
}
},
"typeVersion": 2.1
},
{
"id": "a0862448-5ccf-45a7-9522-d42e902ab00c",
"name": "邮件分类器",
"type": "@n8n/n8n-nodes-langchain.textClassifier",
"position": [
-992,
-560
],
"parameters": {
"options": {},
"inputText": "={{ $json.snippet }}",
"categories": {
"categories": [
{
"category": "High Priority",
"description": "Definition: Emails requiring immediate attention or action, often time-sensitive or involving urgent issues. Examples: System outages, legal alerts, executive requests, critical deadlines, crisis management."
},
{
"category": "Customer Support",
"description": "Definition: Emails related to addressing customer issues, questions, feedback, or service requests. Examples: Complaint resolution, troubleshooting help, account inquiries, service feedback."
},
{
"category": "Promotion",
"description": "Definition: Marketing or sales emails designed to promote a product, service, event, or offer. Examples: Newsletters, discounts, product launches, affiliate promotions."
},
{
"category": "Finance/Billing",
"description": "Definition: Emails involving monetary matters, budgets, transactions, invoices, or financial reporting. Examples: Invoices, salary slips, payment confirmations, expense reports, tax documents."
},
{
"category": "Random (General/Other)",
"description": "Definition: Emails that don’t clearly fall into the above categories — often personal, spammy, or unrelated to business operations. Examples: Internal memos without urgency, jokes, general announcements, social invites."
}
]
}
},
"typeVersion": 1.1
},
{
"id": "73d29ab2-c4a7-4ad0-8082-87df29ab1a63",
"name": "创建草稿",
"type": "@n8n/n8n-nodes-langchain.openAi",
"position": [
0,
-1024
],
"parameters": {
"modelId": {
"__rl": true,
"mode": "list",
"value": "gpt-4.1-mini",
"cachedResultName": "GPT-4.1-MINI"
},
"options": {},
"messages": {
"values": [
{
"content": "=You are an Executive Assistant responsible for drafting accurate, clear, and professional responses to urgent and high-priority inquiries.\n\nHere is the incoming email you are responding to:\n{{ $('Gmail Trigger').item.json.snippet }}\n\nYour task:\n1. Read and understand the email content carefully.\n2. Identify the main issue, request, or concern.\n3. Provide a concise and effective response that directly addresses the matter.\n4. Maintain a professional and respectful tone.\n5. If additional action is needed, include a short next-steps section in the reply.\n\nOutput format (return exactly in this structure):\nSubject: [A short and relevant subject line]\nMessage: [Your full, well-formatted email reply]\n"
}
]
},
"jsonOutput": true
},
"credentials": {
"openAiApi": {
"id": "LNuj9b67Zq2tZww5",
"name": "OpenAi account"
}
},
"typeVersion": 1.8
},
{
"id": "e062bfb5-9e68-461c-9064-13896f1d1986",
"name": "草稿邮件",
"type": "n8n-nodes-base.gmail",
"position": [
400,
-1024
],
"webhookId": "49848a5a-a4de-4b3a-9a10-235c0b33ab71",
"parameters": {
"message": "={{ $json.message.content.Message }}",
"options": {},
"subject": "={{ $json.message.content.Subject }}",
"resource": "draft"
},
"credentials": {
"gmailOAuth2": {
"id": "52mNI7KwytiCFBmo",
"name": "Gmail account 2"
}
},
"typeVersion": 2.1
},
{
"id": "bff31bfe-2dfe-4cca-ae8c-442c840c5497",
"name": "创建邮件",
"type": "@n8n/n8n-nodes-langchain.openAi",
"position": [
16,
-752
],
"parameters": {
"modelId": {
"__rl": true,
"mode": "list",
"value": "gpt-4.1-mini",
"cachedResultName": "GPT-4.1-MINI"
},
"options": {},
"messages": {
"values": [
{
"content": "=You are an Executive Assistant responsible for drafting professional, accurate, and empathetic responses to all customer support inquiries.\n\nHere is the incoming email you are responding to:\n{{ $('Gmail Trigger').item.json.snippet }}\n\nYour task:\n1. Read and understand the customer’s inquiry fully.\n2. Identify the customer's name from the email content, and address them by name at the start of the reply.\n3. Provide a clear, concise, and helpful response that answers all questions or concerns raised in the email.\n4. Maintain a polite, friendly, and professional tone throughout.\n5. Avoid unnecessary filler words; focus on solving the customer's issue efficiently.\n6. End the email with:\nBest regards,\n[YOUR_NAME]\n\n(Replace [YOUR_NAME] with the actual sender’s name configured in the workflow.)\n\n"
}
]
}
},
"credentials": {
"openAiApi": {
"id": "LNuj9b67Zq2tZww5",
"name": "OpenAi account"
}
},
"typeVersion": 1.8
},
{
"id": "953f9d91-dc32-493b-8e0f-ed3447874396",
"name": "自动回复",
"type": "n8n-nodes-base.gmail",
"position": [
416,
-752
],
"webhookId": "b1cc850c-209d-4c6a-89d2-8517849c091d",
"parameters": {
"message": "={{ $json.message.content }}",
"options": {},
"emailType": "text",
"messageId": "={{ $('Gmail Trigger').item.json.id }}",
"operation": "reply"
},
"credentials": {
"gmailOAuth2": {
"id": "52mNI7KwytiCFBmo",
"name": "Gmail account 2"
}
},
"typeVersion": 2.1
},
{
"id": "0685ef61-fa4f-46a1-960f-822611e55cde",
"name": "财务部门",
"type": "@n8n/n8n-nodes-langchain.openAi",
"position": [
128,
-208
],
"parameters": {
"modelId": {
"__rl": true,
"mode": "list",
"value": "gpt-4.1-mini",
"cachedResultName": "GPT-4.1-MINI"
},
"options": {},
"messages": {
"values": [
{
"content": "=You are an Executive Assistant responsible for handling finance-related inquiries and preparing concise summaries for the finance department.\n\nHere is the incoming email you are responding to:\n{{ $('Gmail Trigger').item.json.snippet }}\n\nYour task:\n1. Read and fully understand the email content.\n2. Identify the key financial topic or request (e.g., invoice, payment confirmation, budget query, expense report, tax document).\n3. Summarize the essential details clearly and accurately.\n4. Keep the summary professional and free of unnecessary information.\n5. Ensure the tone remains formal and business-appropriate.\n\nOutput format (return exactly in this structure):\nSubject: [A short and relevant subject line]\nText: [A clear and concise summary of the finance-related email]\n"
}
]
},
"jsonOutput": true
},
"credentials": {
"openAiApi": {
"id": "LNuj9b67Zq2tZww5",
"name": "OpenAi account"
}
},
"typeVersion": 1.8
},
{
"id": "c8997eff-cc00-4dc6-9d92-378bc2d0ba64",
"name": "总结推广内容",
"type": "@n8n/n8n-nodes-langchain.openAi",
"position": [
16,
-528
],
"parameters": {
"modelId": {
"__rl": true,
"mode": "list",
"value": "gpt-4.1-mini",
"cachedResultName": "GPT-4.1-MINI"
},
"options": {},
"messages": {
"values": [
{
"content": "=You are an Executive Assistant responsible for summarizing all incoming promotional emails.\n\nHere is the incoming email you are responding to:\n{{ $('Gmail Trigger').item.json.snippet }}\n\nYour task:\n1. Read and understand the promotional email content.\n2. Identify the key offer, product, service, event, or deal being promoted.\n3. Include important details such as:\n - Offer type (discount, launch, announcement, etc.)\n - Expiry date or deadline (if mentioned)\n - Any special conditions or requirements\n4. Exclude unnecessary or repetitive marketing language.\n5. Keep the summary clear, concise, and actionable.\n\nOutput format:\nSummary: [A short, well-structured summary of the promotional email]\n"
}
]
}
},
"credentials": {
"openAiApi": {
"id": "LNuj9b67Zq2tZww5",
"name": "OpenAi account"
}
},
"typeVersion": 1.8
},
{
"id": "90ea2e06-083e-45ec-bd41-cbd59ce650fa",
"name": "高优先级警报",
"type": "n8n-nodes-base.whatsApp",
"position": [
624,
-1024
],
"webhookId": "6a129da8-0dbf-4bd7-a1ad-8af3f54368ec",
"parameters": {
"textBody": "=High priority email Alert!!!\n{{ $('Gmail Trigger').item.json.snippet }}\n\nI have created a Draft of the replying email:\n{{ $('Creating a Draft').item.json.message.content.Message }}",
"operation": "send",
"phoneNumberId": "=",
"additionalFields": {},
"recipientPhoneNumber": "[YOUR_WHATSAPP_NUMBER]"
},
"credentials": {
"whatsAppApi": {
"id": "FhsL97tKAVtEydZF",
"name": "WhatsApp account"
}
},
"typeVersion": 1
},
{
"id": "ff9a200a-90bf-49b7-8b00-acdbaf320ced",
"name": "确认",
"type": "n8n-nodes-base.whatsApp",
"position": [
640,
-752
],
"webhookId": "6a129da8-0dbf-4bd7-a1ad-8af3f54368ec",
"parameters": {
"textBody": "=Customer Support Related Inquiries\n{{ $('Gmail Trigger').item.json.snippet }}\n\nReplied email:{{ $('Create Email').item.json.message.content }}",
"operation": "send",
"phoneNumberId": "=",
"additionalFields": {},
"recipientPhoneNumber": "[YOUR_WHATSAPP_NUMBER]"
},
"credentials": {
"whatsAppApi": {
"id": "FhsL97tKAVtEydZF",
"name": "WhatsApp account"
}
},
"typeVersion": 1
},
{
"id": "f912992f-ddbf-48d7-a9dc-2115c9f0f910",
"name": "推广警报",
"type": "n8n-nodes-base.whatsApp",
"position": [
416,
-528
],
"webhookId": "6a129da8-0dbf-4bd7-a1ad-8af3f54368ec",
"parameters": {
"textBody": "=Promotional related Email Trigger\n{{ $('Gmail Trigger').item.json.snippet }}\n\n",
"operation": "send",
"phoneNumberId": "=",
"additionalFields": {},
"recipientPhoneNumber": "[YOUR_WHATSAPP_NUMBER]"
},
"credentials": {
"whatsAppApi": {
"id": "FhsL97tKAVtEydZF",
"name": "WhatsApp account"
}
},
"typeVersion": 1
},
{
"id": "1c4b6a73-c41c-41b4-ba3b-c3a8b8064181",
"name": "财务警报",
"type": "n8n-nodes-base.whatsApp",
"position": [
752,
-208
],
"webhookId": "6a129da8-0dbf-4bd7-a1ad-8af3f54368ec",
"parameters": {
"textBody": "= You received a Finance related inquires:{{ $('Gmail Trigger').item.json.snippet }}\n\nI have notified this to your finance department with this Reply email:{{ $('Finance Department').item.json.message.content.Email }}",
"operation": "send",
"phoneNumberId": "=",
"additionalFields": {},
"recipientPhoneNumber": "[YOUR_WHATSAPP_NUMBER]"
},
"credentials": {
"whatsAppApi": {
"id": "FhsL97tKAVtEydZF",
"name": "WhatsApp account"
}
},
"typeVersion": 1
},
{
"id": "f8c045af-ddd7-496a-9dea-c187661c2857",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1264,
-640
],
"parameters": {
"color": 4,
"height": 352,
"content": "当 Gmail 收到新邮件时启动工作流。"
},
"typeVersion": 1
},
{
"id": "677541d5-fab0-4afa-bf22-62ee20aef21d",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1008,
-816
],
"parameters": {
"width": 320,
"height": 688,
"content": "使用 OpenAI 将传入邮件分类为以下 5 个类别之一:"
},
"typeVersion": 1
},
{
"id": "e0d6aa89-5dd9-4c3f-9299-94b41541b632",
"name": "便签2",
"type": "n8n-nodes-base.stickyNote",
"position": [
-384,
-1136
],
"parameters": {
"color": 3,
"width": 1264,
"height": 272,
"content": "在 Gmail 中添加“高优先级”标签"
},
"typeVersion": 1
},
{
"id": "18b64002-7d5a-4ab7-9367-33891861eadb",
"name": "便签3",
"type": "n8n-nodes-base.stickyNote",
"position": [
-384,
-848
],
"parameters": {
"color": 2,
"width": 1280,
"height": 256,
"content": "在 Gmail 中添加“客户支持”标签"
},
"typeVersion": 1
},
{
"id": "2671b41b-5b64-443c-9c59-a885576de663",
"name": "便签4",
"type": "n8n-nodes-base.stickyNote",
"position": [
-384,
-576
],
"parameters": {
"color": 5,
"width": 1296,
"height": 240,
"content": "将邮件标记为“推广”"
},
"typeVersion": 1
},
{
"id": "5b73ffab-3eeb-4c3c-9f1b-5075fb632318",
"name": "便签5",
"type": "n8n-nodes-base.stickyNote",
"position": [
-384,
-320
],
"parameters": {
"color": 7,
"width": 1264,
"height": 304,
"content": "将邮件标记为“财务/账单”"
},
"typeVersion": 1
},
{
"id": "2ed87858-1ea0-40c5-bf7c-d10819df49e1",
"name": "便签6",
"type": "n8n-nodes-base.stickyNote",
"position": [
-384,
-48
],
"parameters": {
"color": 4,
"width": 432,
"height": 288,
"content": "将未分类邮件标记为“随机”"
},
"typeVersion": 1
},
{
"id": "fd867ca9-939b-457d-b673-c01d03e9a22d",
"name": "发送至财务部门",
"type": "n8n-nodes-base.gmail",
"position": [
528,
-208
],
"webhookId": "1dcded01-5b09-4e84-b49c-dc617c267fe4",
"parameters": {
"sendTo": "[YOUR_GMAIL_ADDRESS]",
"message": "={{ $json.message.content.Text }}",
"options": {},
"subject": "={{ $json.message.content.Subject }}",
"emailType": "text"
},
"credentials": {
"gmailOAuth2": {
"id": "52mNI7KwytiCFBmo",
"name": "Gmail account 2"
}
},
"typeVersion": 2.1
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "c9891c26-481f-41b8-a0f2-3d1938671fc6",
"connections": {
"Auto Reply": {
"main": [
[
{
"node": "Confirmation",
"type": "main",
"index": 0
}
]
]
},
"Draft email": {
"main": [
[
{
"node": "High Priority Alert",
"type": "main",
"index": 0
}
]
]
},
"Create Email": {
"main": [
[
{
"node": "Auto Reply",
"type": "main",
"index": 0
}
]
]
},
"Gmail Trigger": {
"main": [
[
{
"node": "Email Classifier",
"type": "main",
"index": 0
}
]
]
},
"Promotion Email": {
"main": [
[
{
"node": "Summarize Promotions",
"type": "main",
"index": 0
}
]
]
},
"Creating a Draft": {
"main": [
[
{
"node": "Draft email",
"type": "main",
"index": 0
}
]
]
},
"Email Classifier": {
"main": [
[
{
"node": "High Priority Email",
"type": "main",
"index": 0
}
],
[
{
"node": "Customer Support Email",
"type": "main",
"index": 0
}
],
[
{
"node": "Promotion Email",
"type": "main",
"index": 0
}
],
[
{
"node": "Finance/Billing Email",
"type": "main",
"index": 0
}
],
[
{
"node": "Random (General/Other) Email",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "Email Classifier",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Finance Department": {
"main": [
[
{
"node": "Send to Finance Department",
"type": "main",
"index": 0
}
]
]
},
"High Priority Email": {
"main": [
[
{
"node": "Creating a Draft",
"type": "main",
"index": 0
}
]
]
},
"Summarize Promotions": {
"main": [
[
{
"node": "Promotional Alert",
"type": "main",
"index": 0
}
]
]
},
"Finance/Billing Email": {
"main": [
[
{
"node": "Finance Department",
"type": "main",
"index": 0
}
]
]
},
"Customer Support Email": {
"main": [
[
{
"node": "Create Email",
"type": "main",
"index": 0
}
]
]
},
"Send to Finance Department": {
"main": [
[
{
"node": "Finance Alert",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
高级 - 工单管理, 多模态 AI
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
基于 Gmail 和 GPT 的 AI 驱动邮件分类与自动回复系统
使用 GPT-4.1-mini 分类和 Gmail 自动回复实现邮件分拣自动化
If
Set
Gmail
+8
24 节点Giovanni Beggiato
工单管理
使用GPT-4整理Gmail并通过Telegram和WhatsApp发送紧急通知
通过GPT-4整理Gmail,并使用Telegram和WhatsApp发送紧急通知
If
Code
Wait
+14
28 节点Iniyavan JC
工单管理
基于AI的邮件收件箱管理器,集成GPT-4、Gmail和Slack
基于AI的邮件收件箱管理器,集成GPT-4、Gmail和Slack
If
Gmail
Slack
+5
22 节点Muhammad Bello
工单管理
AI驱动的邮件分诊与自动回复系统,集成OpenAI代理和Gmail
AI驱动的邮件分诊与自动回复系统,集成OpenAI代理和Gmail
If
Set
Gmail
+20
68 节点Abdullahi Ahmed
内容创作
基于AI的WhatsApp客户服务(GPT-4、智能路由与知识库)
基于AI的WhatsApp客户服务(GPT-4、智能路由与知识库)
Set
Gmail
Merge
+19
45 节点Paul
AI 聊天机器人
使用GPT-5、知识检索和文档上下文自动化HighLevel CRM
通过GPT-5、知识检索和文档上下文自动化HighLevel CRM
Set
Gmail
Slack
+25
55 节点Paul
客户关系管理