使用AI自动标记传入的Gmail电子邮件
高级
这是一个Ticket Management, AI Summarization领域的自动化工作流,包含 17 个节点。主要使用 Gmail, Filter, Switch, GmailTrigger, Agent 等节点。 使用GPT-4o mini自动分类和标记Gmail邮件
前置要求
- •Google 账号和 Gmail API 凭证
- •OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "ggkJA0uoozwG7xjI",
"meta": {
"instanceId": "0a82a9d5784b67ad963ceff89283b2e40cb771be10fe58ba2682f3598a37c6e1",
"templateCredsSetupCompleted": true
},
"name": "使用 AI 自动标记传入的 Gmail 电子邮件",
"tags": [
{
"id": "Ii0eAkipojnzTClF",
"name": "arlindeveloper",
"createdAt": "2025-06-27T00:20:16.715Z",
"updatedAt": "2025-06-27T00:20:16.715Z"
}
],
"nodes": [
{
"id": "43213c04-af84-46b3-95a1-e1ed1112f988",
"name": "Gmail 触发器",
"type": "n8n-nodes-base.gmailTrigger",
"position": [
-260,
1640
],
"parameters": {
"simple": false,
"filters": {},
"options": {},
"pollTimes": {
"item": [
{
"mode": "everyMinute"
}
]
}
},
"credentials": {
"gmailOAuth2": {
"id": "pVkuuYNT0KTxFcw0",
"name": "Gmail account"
}
},
"typeVersion": 1.2
},
{
"id": "65924fac-5776-4e4f-928a-d1180e730a9c",
"name": "OpenAI 聊天模型2",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
300,
1880
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4o-mini",
"cachedResultName": "gpt-4o-mini"
},
"options": {}
},
"credentials": {
"openAiApi": {
"id": "wAP7QjMnHDyoGfIB",
"name": "OpenAi account"
}
},
"typeVersion": 1.2
},
{
"id": "887dac9a-7bae-4797-8967-1114660c194a",
"name": "结构化输出解析器1",
"type": "@n8n/n8n-nodes-langchain.outputParserStructured",
"position": [
560,
1880
],
"parameters": {
"jsonSchemaExample": "{\n \"email_label\": \"business\"\n}"
},
"typeVersion": 1.2
},
{
"id": "fa913085-1c4f-4d61-938c-9bbf24fe9e69",
"name": "便签 3",
"type": "n8n-nodes-base.stickyNote",
"position": [
-360,
1380
],
"parameters": {
"color": 7,
"width": 560,
"height": 700,
"content": "## 1. Gmail 触发器 + 标签检查器"
},
"typeVersion": 1
},
{
"id": "a9c899ef-a4f5-4947-9d9b-5d579ae58827",
"name": "便签11",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1020,
1380
],
"parameters": {
"width": 620,
"height": 1100,
"content": "## 使用 AI 按类别分类 Gmail 消息"
},
"typeVersion": 1
},
{
"id": "0415122e-6746-408c-a4eb-5d128c80a921",
"name": "便签12",
"type": "n8n-nodes-base.stickyNote",
"position": [
220,
1380
],
"parameters": {
"color": 7,
"width": 560,
"height": 700,
"content": "## 2. AI Agent(GPT-4o mini + 输出解析器)"
},
"typeVersion": 1
},
{
"id": "446e3625-8388-44f6-b04e-2d2483f1d4d5",
"name": "便签13",
"type": "n8n-nodes-base.stickyNote",
"position": [
800,
1380
],
"parameters": {
"color": 7,
"width": 760,
"height": 1300,
"content": "## 3. 根据 AI 输出应用标签"
},
"typeVersion": 1
},
{
"id": "4b4a928d-5305-40e5-a040-8a2e8787cf30",
"name": "提供标签 AI Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
340,
1640
],
"parameters": {
"text": "=Topic: {{ $json.subject }}\nDescription: {{ $json.text }}\nSender: {{ $json.from.text }}",
"options": {
"systemMessage": "=**Your Role**\n\nYou are an intelligent email assistant responsible for sorting incoming messages. Your task is to analyze the content, subject, and sender of each email and assign it to the appropriate category.\n\n**Categories**\n\nCategories for sorting:\n\n-Work: Emails related to jobs, coworkers, meetings, projects, or professional tasks.\n\n-Personal: Messages from friends, family, or general personal life content.\n\n-Finance: Bank emails, invoices, receipts, bills, or payment confirmations.\n\n-Shopping: Order confirmations, promotions, receipts, or product updates from stores.\n\n-Travel: Booking confirmations, tickets, hotel or car rental details, itineraries.\n\n-Newsletters: Recurring marketing or informational emails from subscriptions or blogs.\n\n-Others: Relevant emails that don’t clearly fit into any of the categories above.\n\n**Instructions**\n\n-For each email:\n\n-Analyze the content, subject, and sender\n\n-Assign it to the appropriate category\n\n-Add a label with the category\n\n-If you are unsure, do not label the message\n\n**Response Format**\n\nAlways return the result in JSON format:\n\n{\n \"email_label\": \"Shopping\"\n}\n\nIMPORTANT – the response must use the exact label format as listed (capitalized with spaces).\n"
},
"promptType": "define",
"hasOutputParser": true
},
"typeVersion": 1.8
},
{
"id": "5301b42e-ba3c-4f3c-8f84-e4f9ee4ca724",
"name": "标签检查器过滤器",
"type": "n8n-nodes-base.filter",
"position": [
-40,
1640
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "6c287523-4ae2-43c4-8f9a-faf756f01855",
"operator": {
"type": "string",
"operation": "notContains"
},
"leftValue": "={{ $json.labelIds[0] }}",
"rightValue": "Label"
}
]
}
},
"typeVersion": 2.2
},
{
"id": "3ccb8cd6-a329-4507-8158-cbc81b2d31da",
"name": "Switch",
"type": "n8n-nodes-base.switch",
"position": [
840,
1940
],
"parameters": {
"rules": {
"values": [
{
"outputKey": "Work",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "10893f03-231e-4dba-bfdf-69530f908b4d",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.output.email_label }}",
"rightValue": "Work"
}
]
},
"renameOutput": true
},
{
"outputKey": "Personal",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "23e430c2-ac8b-4fb5-bb5a-1fafb9e41b09",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.output.email_label }}",
"rightValue": "Personal"
}
]
},
"renameOutput": true
},
{
"outputKey": "Finance",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "53698e8e-f038-405d-a1d3-274dba7fb2a2",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.output.email_label }}",
"rightValue": "Finance"
}
]
},
"renameOutput": true
},
{
"outputKey": "Shopping",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "b3b7ffc6-d046-402f-8c9d-2e19d00b49a7",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.output.email_label }}",
"rightValue": "Shopping"
}
]
},
"renameOutput": true
},
{
"outputKey": "Travel",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "4e0a670b-4017-4d83-b01a-78a79c55daf2",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.output.email_label }}",
"rightValue": "Travel"
}
]
},
"renameOutput": true
},
{
"outputKey": "Newsletters",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "f0079792-cf4b-4c3e-8aed-48e2dddb4e05",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.output.email_label }}",
"rightValue": "Newsletters"
}
]
},
"renameOutput": true
},
{
"outputKey": "Others",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "a0c39fdd-3312-4a34-8cd4-41a1a10f9149",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.output.email_label }}",
"rightValue": "Others"
}
]
},
"renameOutput": true
}
]
},
"options": {}
},
"typeVersion": 3.2
},
{
"id": "70f0255c-de96-44a0-bcd0-748c9f6e4fe4",
"name": "工作",
"type": "n8n-nodes-base.gmail",
"position": [
1320,
1560
],
"webhookId": "265d6794-4bc1-44e5-b7b0-3a327c860235",
"parameters": {
"messageId": "={{ $('Gmail Trigger').item.json.id }}",
"operation": "addLabels"
},
"credentials": {
"gmailOAuth2": {
"id": "pVkuuYNT0KTxFcw0",
"name": "Gmail account"
}
},
"typeVersion": 2.1
},
{
"id": "525f3f9f-9bc7-40f1-b6a5-8c3edd75025f",
"name": "个人",
"type": "n8n-nodes-base.gmail",
"position": [
1320,
1720
],
"webhookId": "d63928b3-89bb-4549-b241-8a5462db0116",
"parameters": {
"messageId": "={{ $('Gmail Trigger').item.json.id }}",
"operation": "addLabels"
},
"credentials": {
"gmailOAuth2": {
"id": "pVkuuYNT0KTxFcw0",
"name": "Gmail account"
}
},
"typeVersion": 2.1
},
{
"id": "84059ca7-f0cb-4582-bfb7-75f2678c1dae",
"name": "财务",
"type": "n8n-nodes-base.gmail",
"position": [
1320,
1880
],
"webhookId": "e35bc26e-3b63-471a-8c82-909ccc4aac6c",
"parameters": {
"messageId": "={{ $('Gmail Trigger').item.json.id }}",
"operation": "addLabels"
},
"credentials": {
"gmailOAuth2": {
"id": "pVkuuYNT0KTxFcw0",
"name": "Gmail account"
}
},
"typeVersion": 2.1
},
{
"id": "eb7f8180-c834-4f2a-b102-7e5bbacaca3b",
"name": "购物",
"type": "n8n-nodes-base.gmail",
"position": [
1160,
2020
],
"webhookId": "29f83d35-3ad1-4e5b-9359-8b9b2e83ed80",
"parameters": {
"messageId": "={{ $('Gmail Trigger').item.json.id }}",
"operation": "addLabels"
},
"credentials": {
"gmailOAuth2": {
"id": "pVkuuYNT0KTxFcw0",
"name": "Gmail account"
}
},
"typeVersion": 2.1
},
{
"id": "12ba969b-d0aa-475c-ab5e-e4151f8df96e",
"name": "旅行",
"type": "n8n-nodes-base.gmail",
"position": [
1320,
2140
],
"webhookId": "4513f916-1685-4733-8fa6-6373a90abc5e",
"parameters": {
"messageId": "={{ $('Gmail Trigger').item.json.id }}",
"operation": "addLabels"
},
"credentials": {
"gmailOAuth2": {
"id": "pVkuuYNT0KTxFcw0",
"name": "Gmail account"
}
},
"typeVersion": 2.1
},
{
"id": "41bebc40-ba6a-448e-8e28-d74b9ed73de6",
"name": "新闻通讯",
"type": "n8n-nodes-base.gmail",
"position": [
1320,
2320
],
"webhookId": "523b3148-4ff3-4bf5-be9b-31a4b7739b3c",
"parameters": {
"messageId": "={{ $('Gmail Trigger').item.json.id }}",
"operation": "addLabels"
},
"credentials": {
"gmailOAuth2": {
"id": "pVkuuYNT0KTxFcw0",
"name": "Gmail account"
}
},
"typeVersion": 2.1
},
{
"id": "9b3690d5-419c-4b4f-9e86-8720a94818d9",
"name": "其他",
"type": "n8n-nodes-base.gmail",
"position": [
1320,
2500
],
"webhookId": "b20366d0-4de9-4c99-a577-a14bfff50faf",
"parameters": {
"messageId": "={{ $('Gmail Trigger').item.json.id }}",
"operation": "addLabels"
},
"credentials": {
"gmailOAuth2": {
"id": "pVkuuYNT0KTxFcw0",
"name": "Gmail account"
}
},
"typeVersion": 2.1
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "551de827-cf86-472f-935e-99539be78588",
"connections": {
"Switch": {
"main": [
[
{
"node": "Work",
"type": "main",
"index": 0
}
],
[
{
"node": "Personal",
"type": "main",
"index": 0
}
],
[
{
"node": "Finance",
"type": "main",
"index": 0
}
],
[
{
"node": "Shopping",
"type": "main",
"index": 0
}
],
[
{
"node": "travel",
"type": "main",
"index": 0
}
],
[
{
"node": "Newsletters",
"type": "main",
"index": 0
}
],
[
{
"node": "Others",
"type": "main",
"index": 0
}
]
]
},
"Gmail Trigger": {
"main": [
[
{
"node": "Label Checker Filter",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model2": {
"ai_languageModel": [
[
{
"node": "Give a Label AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Label Checker Filter": {
"main": [
[
{
"node": "Give a Label AI Agent",
"type": "main",
"index": 0
}
]
]
},
"Give a Label AI Agent": {
"main": [
[
{
"node": "Switch",
"type": "main",
"index": 0
}
]
]
},
"Structured Output Parser1": {
"ai_outputParser": [
[
{
"node": "Give a Label AI Agent",
"type": "ai_outputParser",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
高级 - 工单管理, AI 摘要总结
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
📨 使用GPT-4o mini自动分类和标记现有Gmail邮件
📨 使用GPT-4o mini自动分类和标记现有Gmail邮件
Gmail
Filter
Switch
+5
18 节点Arlin Perez
个人效率
SmartSupport流程:从邮件到Jira自动处理IT请求,附带Slack通知
通过AI解决方案和Slack提醒将邮件自动转换为Jira工单
If
Set
Jira
+10
25 节点Trung Tran
工单管理
使用 GPT-5、gotoHuman 和人工审核从 Gmail 自动回复并创建 Linear 工单
使用 GPT-5、gotoHuman 和人工审核从 Gmail 自动回复并创建 Linear 工单
Set
Code
Gmail
+13
37 节点gotoHuman
工单管理
AI 客户支持分流与摘要系统
使用GPT-4o、Slack和CRM集成自动处理客户支持
If
Set
Code
+10
32 节点NodeAlchemy
工单管理
具有 AI 分类、Gmail 草稿和 Slack 通知的智能电子邮件助手
使用 OpenAI 分类、Gmail 草稿和 Slack 提醒实现邮件管理自动化
Set
Code
Gmail
+6
16 节点Fabian ZNTL
工单管理
使用GPT、Google日历和Supabase的自动邮件管理系统
使用GPT、Google日历和Supabase的自动邮件管理系统
If
Code
Gmail
+15
42 节点Abdul Mir
工单管理
工作流信息
难度等级
高级
节点数量17
分类2
节点类型8
作者
Arlin Perez
@arlindeveloper👋 Hi! I'm Arlin - a QA Engineer with 2 years of experience and a background in Dart & Flutter for mobile app development. ⚙️ I'm passionate about automation and love building efficient workflows using n8n. 📬 Reach out on LinkedIn for any help with custom workflows
外部链接
在 n8n.io 查看 →
分享此工作流