AI Gmail管理器
高级
这是一个Personal Productivity、AI Summarization领域的自动化工作流,包含 19 个节点。主要使用 If、Gmail、GmailTool、GmailTrigger、Agent 等节点。 基于Gemini的智能Gmail收件箱管理:自动标签和草稿回复
前置要求
- •Google 账号和 Gmail API 凭证
- •Google Gemini API Key
使用的节点 (19 个)
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "xgrbRGmOiwsrm54g",
"meta": {
"instanceId": "1338ae0c1684553d97353e0b9ff6e2af1a34b1745411ed0c59c1f0452e37244d",
"templateCredsSetupCompleted": true
},
"name": "AI Gmail管理器",
"tags": [],
"nodes": [
{
"id": "9f9eac49-b13b-47d2-9801-3c46c11cddc2",
"name": "Gmail 触发器",
"type": "n8n-nodes-base.gmailTrigger",
"position": [
0,
-208
],
"parameters": {
"filters": {},
"pollTimes": {
"item": [
{
"mode": "everyMinute"
}
]
}
},
"credentials": {
"gmailOAuth2": {
"id": "zUaPoJi0uzMTnUY5",
"name": "GoogleAuth"
}
},
"typeVersion": 1.3
},
{
"id": "a66eeb1f-57ee-4b43-9aea-6abeb47c9a1c",
"name": "多表:您可以连接多个表以实现有组织的数据结构",
"type": "@n8n/n8n-nodes-langchain.outputParserStructured",
"position": [
832,
16
],
"parameters": {
"jsonSchemaExample": "{\n \"label\": \"Label name\",\n \"labelID\": \"Label ID\",\n \"id\": \"Email message ID\",\n \"requiresResponse\": true\n}"
},
"typeVersion": 1.3
},
{
"id": "f3d14e47-7403-481f-a15d-87adf9713bdb",
"name": "移除标签",
"type": "n8n-nodes-base.gmail",
"position": [
224,
-208
],
"webhookId": "61056e45-2bed-4c44-8280-6a1c181acebf",
"parameters": {
"labelIds": [
"YELLOW_STAR",
"INBOX",
"IMPORTANT",
"CATEGORY_UPDATES",
"CATEGORY_SOCIAL",
"CATEGORY_PROMOTIONS",
"CATEGORY_PERSONAL",
"CATEGORY_FORUMS"
],
"messageId": "={{ $json.id }}",
"operation": "removeLabels"
},
"credentials": {
"gmailOAuth2": {
"id": "zUaPoJi0uzMTnUY5",
"name": "GoogleAuth"
}
},
"typeVersion": 2.1
},
{
"id": "1883ad7e-1712-4f95-9164-8b1742d08343",
"name": "添加标签",
"type": "n8n-nodes-base.gmail",
"position": [
1264,
-112
],
"webhookId": "3c8bde38-def9-4eca-b854-6965c9df84d8",
"parameters": {
"labelIds": "={{ $json.output.labelID }}",
"messageId": "={{ $('Gmail Trigger').item.json.id }}",
"operation": "addLabels"
},
"credentials": {
"gmailOAuth2": {
"id": "zUaPoJi0uzMTnUY5",
"name": "GoogleAuth"
}
},
"typeVersion": 2.1
},
{
"id": "a4c1fbf6-4111-4d97-9ea3-8963f48b1648",
"name": "移至垃圾邮件",
"type": "n8n-nodes-base.gmail",
"position": [
1264,
-304
],
"webhookId": "ba54fb47-43a2-4fe8-9436-92d44b720a40",
"parameters": {
"labelIds": [
"TRASH"
],
"messageId": "={{ $('Gmail Trigger').item.json.id }}",
"operation": "addLabels"
},
"credentials": {
"gmailOAuth2": {
"id": "zUaPoJi0uzMTnUY5",
"name": "GoogleAuth"
}
},
"typeVersion": 2.1
},
{
"id": "94a9bed2-df2c-4e55-87ed-5aa495a9f0ea",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
464,
-544
],
"parameters": {
"color": 7,
"width": 544,
"height": 720,
"content": "## 分类邮件"
},
"typeVersion": 1
},
{
"id": "96e9fbad-4274-4649-8f71-1a97bba948df",
"name": "GetThread",
"type": "n8n-nodes-base.gmailTool",
"position": [
576,
16
],
"webhookId": "f2d16335-4c75-4d6f-8594-03f59f7fc932",
"parameters": {
"filters": {
"q": "=from:{{ $('Gmail Trigger').item.json.From }}"
},
"operation": "getAll",
"returnAll": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Return_All', ``, 'boolean') }}"
},
"credentials": {
"gmailOAuth2": {
"id": "zUaPoJi0uzMTnUY5",
"name": "GoogleAuth"
}
},
"typeVersion": 2.1
},
{
"id": "335c960f-eedc-4d90-9fd6-6e174fdcd0a8",
"name": "CheckSent",
"type": "n8n-nodes-base.gmailTool",
"position": [
704,
16
],
"webhookId": "d76d71b1-9351-4f14-90d7-6635de065068",
"parameters": {
"filters": {
"q": "=to:{{ $('Gmail Trigger').item.json.From }}"
},
"operation": "getAll",
"returnAll": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Return_All', ``, 'boolean') }}"
},
"credentials": {
"gmailOAuth2": {
"id": "zUaPoJi0uzMTnUY5",
"name": "GoogleAuth"
}
},
"typeVersion": 2.1
},
{
"id": "9db911b8-430c-41a8-8dd2-09f446526358",
"name": "Gemini",
"type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
"position": [
1296,
208
],
"parameters": {
"options": {}
},
"credentials": {
"googlePalmApi": {
"id": "eQiUuaFUQ4qSNdZB",
"name": "GeminiAuth"
}
},
"typeVersion": 1
},
{
"id": "390214f0-5930-4655-a2c4-b0a814652388",
"name": "IF 删除",
"type": "n8n-nodes-base.if",
"position": [
1040,
-208
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "dac0c540-5afe-4df3-b20b-8526effbe68b",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.output.label }}",
"rightValue": "DELETE"
}
]
}
},
"typeVersion": 2.2
},
{
"id": "fdf0e08d-5184-4ae4-aa5e-ed8dc1bd1f00",
"name": "IF 回复",
"type": "n8n-nodes-base.if",
"position": [
1488,
-112
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "63984b31-4839-46d1-9c3e-0bf2a966e126",
"operator": {
"type": "boolean",
"operation": "true",
"singleValue": true
},
"leftValue": "={{ $('AI Email Classifier').item.json.output.requiresResponse }}",
"rightValue": "true"
}
]
}
},
"typeVersion": 2.2
},
{
"id": "4ad414d5-1f4d-42e6-9ee4-c6e3f3b348d4",
"name": "创建草稿",
"type": "n8n-nodes-base.gmail",
"position": [
2176,
-112
],
"webhookId": "21d08e97-ffd6-41f8-91d3-683d112be28a",
"parameters": {
"message": "={{ $json.output.draft }}",
"options": {
"sendTo": "={{ $('Gmail Trigger').item.json.From }}",
"threadId": "={{ $('Gmail Trigger').item.json.threadId }}"
},
"subject": "=Re: {{ $('Gmail Trigger').item.json.Subject }}",
"resource": "draft"
},
"credentials": {
"gmailOAuth2": {
"id": "zUaPoJi0uzMTnUY5",
"name": "GoogleAuth"
}
},
"typeVersion": 2.1
},
{
"id": "242f05bd-60e6-4e78-87c3-a4c96647ce18",
"name": "GetThread1",
"type": "n8n-nodes-base.gmailTool",
"position": [
1712,
112
],
"webhookId": "f2d16335-4c75-4d6f-8594-03f59f7fc932",
"parameters": {
"filters": {
"q": "=from:{{ $('Gmail Trigger').item.json.From }}"
},
"operation": "getAll",
"returnAll": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Return_All', ``, 'boolean') }}"
},
"credentials": {
"gmailOAuth2": {
"id": "zUaPoJi0uzMTnUY5",
"name": "GoogleAuth"
}
},
"typeVersion": 2.1
},
{
"id": "8df829c7-fb54-41fd-bd6e-dc3e6f35ddbf",
"name": "CheckCalendar",
"type": "n8n-nodes-base.googleCalendarTool",
"position": [
1840,
112
],
"parameters": {
"options": {
"timezone": {
"__rl": true,
"mode": "list",
"value": "[YOUR OWN TIMEZEONE HERE]",
"cachedResultName": "[YOUR OWN TIMEZONE HERE]"
}
},
"timeMax": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('End_Time', ``, 'string') }}",
"timeMin": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Start_Time', ``, 'string') }}",
"calendar": {
"__rl": true,
"mode": "list",
"value": "[YOUR OWN EMAIL HERE]",
"cachedResultName": "Google"
},
"resource": "calendar"
},
"credentials": {
"googleCalendarOAuth2Api": {
"id": "zqtSZV07a6uCDQUk",
"name": "Google Calendar account"
}
},
"typeVersion": 1.3
},
{
"id": "7d87941c-a1d7-4476-ba1d-ad60a08c08ad",
"name": "Structured Output Parser1",
"type": "@n8n/n8n-nodes-langchain.outputParserStructured",
"position": [
1984,
112
],
"parameters": {
"jsonSchemaExample": "{\n \"draft\": \"string\",\n \"notes\": \"string\"\n}"
},
"typeVersion": 1.3
},
{
"id": "cf93dee2-2c6c-4d01-ab7c-442bd32a1d7b",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
1680,
-400
],
"parameters": {
"color": 7,
"width": 608,
"height": 656,
"content": "## 起草回复"
},
"typeVersion": 1
},
{
"id": "e44b892d-b865-4fd2-86f7-6750f621fef4",
"name": "AI 邮件分类器",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
568,
-208
],
"parameters": {
"text": "=Objective:\nAnalyze the provided email and classify it with the most appropriate label. Respond strictly in JSON (schema: label, labelID, id, requiresResponse).\nOnly output JSON — no explanations. You have access to Gmail tools to gather context and should use them when necessary.\n\nTool Access:\n- GetThread: use this to fetch all messages in the same Gmail thread using the provided threadId. This lets you review past exchanges for context.\n- CheckSent: use this to check if there are any emails previously sent by me to this sender (helps identify ongoing conversations).\n\n\nYour email (for context): [INPUT YOUR EMAIL HERE]\n\nInput Email Data (from n8n JSON item for the current email):\nSender Email: {{ $('Gmail Trigger').item.json.from }}\nSubject: {{ $('Gmail Trigger').item.json.subject }}\nSnippet: {{ $('Gmail Trigger').item.json.snippet }}\nDate: {{ $('Gmail Trigger').item.json.internalDate }}\nEmail ID: {{ $('Gmail Trigger').item.json.id }}\nThread ID: {{ $('Gmail Trigger').item.json.threadId }}\nExisting Gmail Labels: {{ $json.labelIds.join(', ') }}\n\nLabeling Rules:\n\n[01] [INPUTE LABEL 1] (labelID: [INPUT LABEL 1's ID]) → [INPUT: Types of emails that should be part of Label 1, e.g. vendor emails for ecommerce business].\n[02] [INPUT LABEL 2] (labelID: [INPUT LABEL 2's ID]) → [INPUT: Types of emails that should be part of Label 2].\n\nDELETE (does NOT have a LabelID)→ Emails that do not fit any SAVE rules.\n\nBehavior Rules:\n1. Before classifying, use GetThread with the provided threadId to see if this is a reply or part of an existing conversation.\n2. Use CheckSent to confirm whether I’ve interacted with this sender before — this can help detect ongoing conversations.\n3. If this email requires a reply (scheduling, questions directed to me, next-step confirmations that request action), set requiresResponse to true and do NOT write the draft here — only set the flag. The actual draft will be created by a separate drafting node.\n4. Else set requiresResponse to false.\n\nOutput Format (strict JSON):\n{\n \"label\": \"Label name\",\n \"labelID\": \"Label ID\",\n \"id\": \"Email message ID\",\n \"requiresResponse\": true or false\n}\n\nAdditional Guidance:\n\n-Only return one label per email.\n-Do not include any text outside of the JSON object.",
"options": {},
"promptType": "define",
"hasOutputParser": true
},
"typeVersion": 3
},
{
"id": "db5ab5f9-320c-4b89-ba46-5ea013109f64",
"name": "AI草稿制作器",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
1768,
-112
],
"parameters": {
"text": "=Objective:\nCreate a concise, friendly, and professional reply draft for the provided email thread. Do NOT send the message — only generate the draft text.\n\nTool Access:\n- GetThread1: use this to fetch the full thread using the threadId below, if more context is needed.\n- CheckCalendar: use this to find available time slots within the next 7 days (local time: [INPUT YOUR LOCAL TZ]) if scheduling is requested.\n\nContext:\n- My email: [INPUT YOUR EMAIL HERE]\n- Recipient (original sender): {{ $('Gmail Trigger').item.json.From }}\n- Original subject: {{ $('Gmail Trigger').item.json.Subject }}\n- Thread ID: {{ $('Gmail Trigger').item.json.threadId }}\n- Snippet: {{ $('Gmail Trigger').item.json.snippet }}\n- Full thread: use GetThread if additional context is required.\n\nDrafting Rules:\n1. Detect the sender’s language. If they wrote in English, reply in English; if Spanish, reply in Spanish; if French, reply in French. If unclear, default to English.\n2. Tone: friendly, professional, natural.\n3. Length: keep it short (3–6 sentences).\n4. If scheduling is requested:\n - Use CheckCalendar to propose 2–3 available time slots in the next 7 days (local time).\n - Format times like: “Tuesday, May 12 at 15:00 CEST”.\n - Make time zone clear ([INPUT YOUR LOCAL TIMEZONE]).\n5. For confirmations/info requests: answer directly and clearly.\n6. For document requests: say you will attach them and include: “[Attach documents]”.\n7. Start with a greeting: “Hi [Name],” (adapted to language).\n8. End with: “Best, [INPUT YOUR NAME/YOUR BUSINESS' NAME]” or the equivalent in that language.\n9. Never include internal notes in the email body. Put any short reviewer guidance in `notes`.\n\nOutput Format (JSON):\n{\n \"draft\": \"email body here\",\n \"notes\": \"short reasoning or summary\"\n}\n",
"options": {},
"promptType": "define",
"hasOutputParser": true
},
"typeVersion": 3
},
{
"id": "739c6768-6fa3-45fe-ab51-84b07da6e6a0",
"name": "便签2",
"type": "n8n-nodes-base.stickyNote",
"position": [
-592,
-448
],
"parameters": {
"width": 544,
"height": 608,
"content": "# AI Gmail管理器"
},
"typeVersion": 1
}
],
"active": true,
"pinData": {},
"settings": {
"callerPolicy": "workflowsFromSameOwner",
"errorWorkflow": "2wvl7ae8yQzVXgvA",
"availableInMCP": false,
"executionOrder": "v1",
"timeSavedPerExecution": 5
},
"versionId": "f8cb4394-0baf-4c9d-95e4-aaec8335e3cd",
"connections": {
"Gemini": {
"ai_languageModel": [
[
{
"node": "AI Email Classifier",
"type": "ai_languageModel",
"index": 0
},
{
"node": "AI Draft Maker",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"AddLabel": {
"main": [
[
{
"node": "IF Response",
"type": "main",
"index": 0
}
]
]
},
"CheckSent": {
"ai_tool": [
[
{
"node": "AI Email Classifier",
"type": "ai_tool",
"index": 0
}
]
]
},
"GetThread": {
"ai_tool": [
[
{
"node": "AI Email Classifier",
"type": "ai_tool",
"index": 0
}
]
]
},
"IF Delete": {
"main": [
[
{
"node": "TrashMessage",
"type": "main",
"index": 0
}
],
[
{
"node": "AddLabel",
"type": "main",
"index": 0
}
]
]
},
"GetThread1": {
"ai_tool": [
[
{
"node": "AI Draft Maker",
"type": "ai_tool",
"index": 0
}
]
]
},
"IF Response": {
"main": [
[
{
"node": "AI Draft Maker",
"type": "main",
"index": 0
}
]
]
},
"RemoveLabel": {
"main": [
[
{
"node": "AI Email Classifier",
"type": "main",
"index": 0
}
]
]
},
"CheckCalendar": {
"ai_tool": [
[
{
"node": "AI Draft Maker",
"type": "ai_tool",
"index": 0
}
]
]
},
"Gmail Trigger": {
"main": [
[
{
"node": "RemoveLabel",
"type": "main",
"index": 0
}
]
]
},
"AI Draft Maker": {
"main": [
[
{
"node": "Create a draft",
"type": "main",
"index": 0
}
]
]
},
"AI Email Classifier": {
"main": [
[
{
"node": "IF Delete",
"type": "main",
"index": 0
}
]
]
},
"Structured Output Parser": {
"ai_outputParser": [
[
{
"node": "AI Email Classifier",
"type": "ai_outputParser",
"index": 0
}
]
]
},
"Structured Output Parser1": {
"ai_outputParser": [
[
{
"node": "AI Draft Maker",
"type": "ai_outputParser",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
这是一个高级难度的工作流,适用于Personal Productivity、AI Summarization等场景。适合高级用户,包含 16+ 个节点的复杂工作流
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
在可视化参考库中探索n8n节点
在可视化参考库中探索n8n节点
If
Ftp
Set
+93
113 节点I versus AI
Other
AI邮件分诊与GPT-4警报系统及Telegram通知
AI邮件分诊与GPT-4警报系统及Telegram通知
If
Set
Gmail
+22
104 节点Peter Joslyn
Support
邮件转WhatsApp - AI多账户桥接
AI驱动的邮件转发至WhatsApp,集成Gmail、Outlook和Google Gemini
Code
Gmail
Http Request
+6
22 节点iTzJok3r
Personal Productivity
使用GPT-4整理Gmail并通过Telegram和WhatsApp发送紧急通知
通过GPT-4整理Gmail,并使用Telegram和WhatsApp发送紧急通知
If
Code
Wait
+14
28 节点Iniyavan JC
Ticket Management
一体化智能体
个人AI智能体
If
Gmail
Telegram
+13
30 节点Rakin Jakaria
AI Chatbot
基于Google Gemini的智能LinkedIn职位筛选,含简历匹配和Google地图
基于Google Gemini的智能LinkedIn职位筛选,含简历匹配和Google地图
If
Set
Supabase
+10
26 节点Atta
Personal Productivity
工作流信息
难度等级
高级
节点数量19
分类2
节点类型9
作者
Salvador
@svdroBusiness Analyst passionate about automation. I help teams and productivity enthusiasts streamline workflows, eliminate manual tasks, and scale their operations using n8n and smart process design.
外部链接
在 n8n.io 上查看 →
分享此工作流