标记接收邮件,构建知识图谱,通过Telegram通知
高级
这是一个Other, AI, IT Ops领域的自动化工作流,包含 28 个节点。主要使用 Code, Wait, Gmail, Telegram, Aggregate 等节点,结合人工智能技术实现智能自动化。 使用Gemini AI自动化Gmail标记并构建InfraNodus知识图谱,通过Telegram发送提醒
前置要求
- •Google 账号和 Gmail API 凭证
- •Telegram Bot Token
- •可能需要目标 API 的认证凭证
- •OpenAI API Key
- •Google Gemini API Key
使用的节点 (28)
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "kuHROEwShNrG11Ea",
"meta": {
"instanceId": "2a26454b0172ffcb8d70ba77c235b1209f92cd71bf06c79ba609c7173b416d68"
},
"name": "标记接收邮件,构建知识图谱,通过Telegram通知",
"tags": [
{
"id": "sJk9cUvmMU8FkJXv",
"name": "AI",
"createdAt": "2025-05-20T13:16:15.636Z",
"updatedAt": "2025-05-20T13:16:15.636Z"
},
{
"id": "E52i6BJ7Ht6yF3OB",
"name": "Productivity",
"createdAt": "2025-06-04T10:29:27.533Z",
"updatedAt": "2025-06-04T10:29:27.533Z"
},
{
"id": "66wgFoDi9Xjl74M3",
"name": "Support",
"createdAt": "2025-05-21T17:06:32.355Z",
"updatedAt": "2025-05-21T17:06:32.355Z"
}
],
"nodes": [
{
"id": "ba46bc4c-7f6b-4482-ae2b-f1621695a0d4",
"name": "Gmail 触发器",
"type": "n8n-nodes-base.gmailTrigger",
"position": [
100,
1100
],
"parameters": {
"simple": false,
"filters": {
"q": "-from:me"
},
"options": {},
"pollTimes": {
"item": [
{
"mode": "everyMinute"
}
]
}
},
"credentials": {
"gmailOAuth2": {
"id": "w7b4H8WpgY9Oit56",
"name": "Gmail supadelicious"
}
},
"typeVersion": 1
},
{
"id": "e8be32bf-2bb6-491a-8aba-a62efad5398d",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
0,
900
],
"parameters": {
"width": 304.10628068244364,
"height": 394.42512272977456,
"content": "## 1. 当新邮件到达您的Gmail收件箱时,触发此工作流"
},
"typeVersion": 1
},
{
"id": "43f13337-45f6-4485-b8b0-ec868340b168",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
360,
900
],
"parameters": {
"width": 456,
"height": 697,
"content": "## 2. 按主题分类邮件"
},
"typeVersion": 1
},
{
"id": "996d2cdd-a6b8-4e93-9d7a-4d6a63120107",
"name": "便签3",
"type": "n8n-nodes-base.stickyNote",
"position": [
880,
900
],
"parameters": {
"width": 786,
"height": 1315,
"content": "## 3. 使用适当标签标记邮件"
},
"typeVersion": 1
},
{
"id": "8b3d7ee8-7ef7-498a-a975-b578778f77d0",
"name": "OpenAI 聊天模型",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"disabled": true,
"position": [
600,
1420
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4o",
"cachedResultName": "gpt-4o"
},
"options": {}
},
"typeVersion": 1.2
},
{
"id": "911e7892-5219-47b0-84d7-cc931b3b1cf9",
"name": "便签4",
"type": "n8n-nodes-base.stickyNote",
"position": [
2260,
1600
],
"parameters": {
"width": 366,
"height": 555,
"content": "## 可选:8. 通过Telegram通知"
},
"typeVersion": 1
},
{
"id": "bd63f009-14b4-46c8-b7d7-c17eba11ea71",
"name": "标记为商务",
"type": "n8n-nodes-base.gmail",
"position": [
1120,
1200
],
"webhookId": "58a51fb3-8280-4d3b-89b9-43120784be6e",
"parameters": {
"labelIds": [
"Label_3466297294634862775"
],
"messageId": "={{ $('Gmail Trigger').item.json.id }}",
"operation": "addLabels"
},
"credentials": {
"gmailOAuth2": {
"id": "w7b4H8WpgY9Oit56",
"name": "Gmail supadelicious"
}
},
"typeVersion": 2.1
},
{
"id": "0a887766-6e31-4719-878b-1df06aa537be",
"name": "标记为个人",
"type": "n8n-nodes-base.gmail",
"position": [
1120,
1440
],
"webhookId": "77edaf02-0efa-48b6-a496-a7a7ba04fefd",
"parameters": {
"labelIds": [
"Label_8982059712942854310"
],
"messageId": "={{ $('Gmail Trigger').item.json.id }}",
"operation": "addLabels"
},
"credentials": {
"gmailOAuth2": {
"id": "w7b4H8WpgY9Oit56",
"name": "Gmail supadelicious"
}
},
"typeVersion": 2.1
},
{
"id": "aa488bb4-8987-40b1-982f-d062e895dceb",
"name": "标记为紧急",
"type": "n8n-nodes-base.gmail",
"position": [
1120,
1860
],
"webhookId": "b148860f-9ed8-481d-8fe7-5a3679061de4",
"parameters": {
"labelIds": [
"Label_7826865676723242579"
],
"messageId": "={{ $('Gmail Trigger').item.json.id }}",
"operation": "addLabels"
},
"credentials": {
"gmailOAuth2": {
"id": "w7b4H8WpgY9Oit56",
"name": "Gmail supadelicious"
}
},
"typeVersion": 2.1
},
{
"id": "92180fdf-18c2-49d9-92ce-99fb0e0bffd7",
"name": "标记为约会",
"type": "n8n-nodes-base.gmail",
"position": [
1120,
1660
],
"webhookId": "2ab15b88-54de-4260-954c-05ac0c17a99f",
"parameters": {
"labelIds": [
"Label_912815023264112825"
],
"messageId": "={{ $('Gmail Trigger').item.json.id }}",
"operation": "addLabels"
},
"credentials": {
"gmailOAuth2": {
"id": "w7b4H8WpgY9Oit56",
"name": "Gmail supadelicious"
}
},
"typeVersion": 2.1
},
{
"id": "65a404c8-b96c-4388-9b11-80c947c1ce88",
"name": "聚合",
"type": "n8n-nodes-base.aggregate",
"position": [
1800,
1920
],
"parameters": {
"options": {},
"aggregate": "aggregateAllItemData"
},
"executeOnce": true,
"typeVersion": 1
},
{
"id": "3bbfb056-e76c-4321-91a1-364460b28f34",
"name": "InfraNodus保存到图谱",
"type": "n8n-nodes-base.httpRequest",
"notes": "// optional context setting to save a social knowledge graph\n{{{ \"partOfSpeechToProcess\":\"HASHTAGS_AND_WORDS\", \"doubleSquarebracketsProcessing\":\"PROCESS_AS_MENTIONS\"} }}",
"position": [
2360,
1240
],
"parameters": {
"url": "https://infranodus.com/api/v1/graphAndStatements?doNotSave=false&includeGraph=false&includeGraphSummary=true&includeStatements=false",
"method": "POST",
"options": {},
"sendBody": true,
"authentication": "genericCredentialType",
"bodyParameters": {
"parameters": [
{
"name": "name",
"value": "gmail_business"
},
{
"name": "statements",
"value": "={{ $json.statements }}"
},
{
"name": "contextSettings",
"value": "={{{ \"partOfSpeechToProcess\":\"HASHTAGS_AND_WORDS\", \"doubleSquarebracketsProcessing\":\"EXCLUDE\", \"mentionsProcessing\":\"EXCLUDE\"} }}"
}
]
},
"genericAuthType": "httpBearerAuth"
},
"credentials": {
"httpBearerAuth": {
"id": "FPDx6PA5CtzGEIQc",
"name": "InfraNodus DeeMeeTree API Key"
}
},
"notesInFlow": true,
"typeVersion": 4.2
},
{
"id": "4b0620da-8be4-4cd1-883d-08ec95d9cf5d",
"name": "便签5",
"type": "n8n-nodes-base.stickyNote",
"position": [
1740,
900
],
"parameters": {
"width": 886,
"height": 515,
"content": "## 4. 将带有\"商务\"标签(或您选择的标签)的邮件保存到特定的[InfraNodus](https://infranodus.com)知识图谱中"
},
"typeVersion": 1
},
{
"id": "a7361550-2fc9-4e71-b9b5-d4bbe678335a",
"name": "等待",
"type": "n8n-nodes-base.wait",
"position": [
2800,
1240
],
"webhookId": "19682910-00a9-4ccf-8182-9aaf53e000fd",
"parameters": {},
"typeVersion": 1.1
},
{
"id": "a0b4cb24-513e-4e51-8673-472a38cb2836",
"name": "清理HTML并组织成陈述",
"type": "n8n-nodes-base.code",
"position": [
1840,
1240
],
"parameters": {
"jsCode": "\nlet statements = []\nfor (const item of $input.all()) {\n\n const emailOrigin = $('Gmail Trigger').first().json.from.value[0].name\n const cleanTextContent = removeHtmlCssScript($('Gmail Trigger').first().json.text)\n statements.push('[[' + emailOrigin + ']] ' + '[' + $('Gmail Trigger').first().json.date?.split('T')[0] + '] ' + cleanTextContent)\n\n}\n\nreturn { statements: statements }\n\nfunction removeHtmlCssScript(text) {\n if (!text || typeof text !== 'string') {\n return '';\n }\n \n let cleanText = text;\n \n // Remove script tags and their content (case insensitive)\n cleanText = cleanText.replace(/<script[^>]*>[\\s\\S]*?<\\/script>/gi, '');\n \n // Remove style tags and their content (case insensitive)\n cleanText = cleanText.replace(/<style[^>]*>[\\s\\S]*?<\\/style>/gi, '');\n \n // Remove HTML comments\n cleanText = cleanText.replace(/<!--[\\s\\S]*?-->/g, '');\n \n // Remove all remaining HTML tags\n cleanText = cleanText.replace(/<[^>]*>/g, '');\n \n // Decode common HTML entities\n const htmlEntities = {\n '&': '&',\n '<': '<',\n '>': '>',\n '"': '\"',\n ''': \"'\",\n ' ': ' ',\n '©': '©',\n '®': '®',\n '™': '™'\n };\n \n Object.keys(htmlEntities).forEach(entity => {\n const regex = new RegExp(entity, 'g');\n cleanText = cleanText.replace(regex, htmlEntities[entity]);\n });\n \n // Clean up extra whitespace\n cleanText = cleanText.replace(/\\s+/g, ' ').trim();\n \n return cleanText;\n}"
},
"typeVersion": 2
},
{
"id": "d55f464d-0d0f-4f17-9abb-948d43565309",
"name": "InfraNodus问题生成器",
"type": "n8n-nodes-base.httpRequest",
"position": [
3180,
1240
],
"parameters": {
"url": "https://infranodus.com/api/v1/graphAndAdvice?doNotSave=true&optimize=gap&includeGraph=false&includeGraphSummary=true",
"method": "POST",
"options": {},
"sendBody": true,
"authentication": "genericCredentialType",
"bodyParameters": {
"parameters": [
{
"name": "aiTopics",
"value": "true"
},
{
"name": "requestMode",
"value": "question"
},
{
"name": "name",
"value": "gmail_business"
}
]
},
"genericAuthType": "httpBearerAuth"
},
"credentials": {
"httpBearerAuth": {
"id": "FPDx6PA5CtzGEIQc",
"name": "InfraNodus DeeMeeTree API Key"
}
},
"typeVersion": 4.2
},
{
"id": "fbdca5de-9e84-4563-ad88-09130e260e5a",
"name": "便签6",
"type": "n8n-nodes-base.stickyNote",
"position": [
2720,
900
],
"parameters": {
"width": 686,
"height": 515,
"content": "## 可选:5. 在收到该邮件后,基于图谱生成有趣洞察问题"
},
"typeVersion": 1
},
{
"id": "cd621b22-b5d3-44af-9bed-ef83784140fb",
"name": "获取Gmail中的标签名称",
"type": "n8n-nodes-base.gmail",
"position": [
2020,
1920
],
"webhookId": "884bace4-da36-4eb1-9d4f-628a68305921",
"parameters": {
"labelId": "={{ $json.data[0].labelIds.find(label => label.includes('Label')) }}",
"resource": "label",
"operation": "get"
},
"credentials": {
"gmailOAuth2": {
"id": "w7b4H8WpgY9Oit56",
"name": "Gmail supadelicious"
}
},
"typeVersion": 2.1
},
{
"id": "2fb4e4fa-cd1b-4dd4-a12e-16af50bf1561",
"name": "便签7",
"type": "n8n-nodes-base.stickyNote",
"position": [
3500,
900
],
"parameters": {
"width": 686,
"height": 515,
"content": "## 6. 可选:将新洞察问题发送到Telegram聊天"
},
"typeVersion": 1
},
{
"id": "9ed340b9-a9ee-4844-af29-95d70e9f095d",
"name": "发送洞察到Telegram",
"type": "n8n-nodes-base.telegram",
"onError": "continueRegularOutput",
"position": [
3760,
1240
],
"webhookId": "763a4e22-fc79-4c83-88b0-caa263aa5bf5",
"parameters": {
"text": "=💭 Question: {{ $json.aiAdvice[0].text }} \nMore at [https://infranodus.com/your_user_name/gmail_business/edit](https://infranodus.com/your_user_name/gmail_business/edit)",
"chatId": "",
"additionalFields": {
"appendAttribution": false
}
},
"credentials": {
"telegramApi": {
"id": "jaBITBhfModUjHo9",
"name": "Telegram apartment notifications"
}
},
"retryOnFail": true,
"typeVersion": 1.2
},
{
"id": "e11bc8c5-be6d-4208-a6d8-e6f7f3f0aac5",
"name": "通过Telegram发送通知",
"type": "n8n-nodes-base.telegram",
"position": [
2480,
1920
],
"webhookId": "a067ddab-b70a-432a-85da-96e3f72a6ba3",
"parameters": {
"text": "=📬 Important email / Label: {{ $('Get Label\\'s Name in Gmail').item.json.name }} / Preview: \n{{ $('Gmail Trigger').item.json.subject }}: {{ $json.snippet }}\nRead more at https://mail.google.com/mail/u/0/#inbox/{{ $('Gmail Trigger').item.json.threadId }}",
"chatId": "",
"additionalFields": {
"appendAttribution": false
}
},
"credentials": {
"telegramApi": {
"id": "jaBITBhfModUjHo9",
"name": "Telegram apartment notifications"
}
},
"typeVersion": 1.2
},
{
"id": "bc44b63e-f26e-4431-a9b9-f222cbf1c0cb",
"name": "标记为发票",
"type": "n8n-nodes-base.gmail",
"position": [
1120,
2060
],
"webhookId": "f9f2477f-a8ff-41c3-bf93-95e6db3c4727",
"parameters": {
"labelIds": [
"Label_961995338561265835"
],
"messageId": "={{ $('Gmail Trigger').item.json.id }}",
"operation": "addLabels"
},
"credentials": {
"gmailOAuth2": {
"id": "w7b4H8WpgY9Oit56",
"name": "Gmail supadelicious"
}
},
"typeVersion": 2.1
},
{
"id": "831683f8-1f8e-4007-bc18-2592df639b47",
"name": "Google Gemini 聊天模型",
"type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
"position": [
420,
1420
],
"parameters": {
"options": {},
"modelName": "models/gemini-2.5-flash-preview-04-17"
},
"credentials": {
"googlePalmApi": {
"id": "ivswOFTY8MYDbj5b",
"name": "Google Gemini(PaLM) Api account"
}
},
"typeVersion": 1
},
{
"id": "e10e2405-8c6d-4a55-bb20-bd0b87d0d767",
"name": "获取邮件摘要",
"type": "n8n-nodes-base.gmail",
"position": [
2320,
1920
],
"webhookId": "93862f7b-cfd9-4349-80b2-1de84ab98e0d",
"parameters": {
"messageId": "={{ $('Gmail Trigger').item.json.id }}",
"operation": "get"
},
"credentials": {
"gmailOAuth2": {
"id": "w7b4H8WpgY9Oit56",
"name": "Gmail supadelicious"
}
},
"typeVersion": 2.1
},
{
"id": "53f9d6db-e981-4e6e-8a59-c8fc67821dbc",
"name": "便签8",
"type": "n8n-nodes-base.stickyNote",
"position": [
0,
0
],
"parameters": {
"color": 6,
"width": 824,
"height": 874,
"content": "# 使用AI标记接收邮件,为选定类别构建知识图谱,然后通过Telegram通知包含该类所有邮件的洞察"
},
"typeVersion": 1
},
{
"id": "64f8c1b0-9194-4aed-8822-0173f93e41d3",
"name": "便签9",
"type": "n8n-nodes-base.stickyNote",
"position": [
880,
0
],
"parameters": {
"color": 5,
"width": 524,
"height": 574,
"content": "## 设置指南"
},
"typeVersion": 1
},
{
"id": "fc23ec5f-7bc5-487f-8a3f-1b84846e9af8",
"name": "便签 10",
"type": "n8n-nodes-base.stickyNote",
"position": [
1720,
1600
],
"parameters": {
"width": 466,
"height": 555,
"content": "## 可选:7. 选择您希望立即收到通知的邮件"
},
"typeVersion": 1
},
{
"id": "fc1d740a-8163-4c62-ba00-3737c292fa47",
"name": "文本分类器",
"type": "@n8n/n8n-nodes-langchain.textClassifier",
"position": [
420,
1220
],
"parameters": {
"options": {
"multiClass": true
},
"inputText": "=Subject: {{ $json.subject }}\nMessage:\n{{ $json.text }} ",
"categories": {
"categories": [
{
"category": "Business",
"description": "Business-related messages, including interesting offers, personalized partnership requests or opportunities. Avoid automated messages."
},
{
"category": "Personal",
"description": "Personal emails that are addressed to me directly, from friends, acquaintances, or very personal tone, not spam Avoid automated messages."
},
{
"category": "Appointments",
"description": "Important appointments and scheduled arrangements that should be in a calendar."
},
{
"category": "Urgent",
"description": "Things that should be attended urgently, avoid automated messages."
},
{
"category": "Invoices",
"description": "Emails that contain an invoice with a payment amount"
}
]
}
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "cbebe7e2-cba3-4f86-9361-74ea100639b0",
"connections": {
"Wait": {
"main": [
[
{
"node": "InfraNodus Question Generator",
"type": "main",
"index": 0
}
]
]
},
"Aggregate": {
"main": [
[
{
"node": "Get Label's Name in Gmail",
"type": "main",
"index": 0
}
]
]
},
"Gmail Trigger": {
"main": [
[
{
"node": "Text Classifier",
"type": "main",
"index": 0
}
]
]
},
"Label as Urgent": {
"main": [
[
{
"node": "Aggregate",
"type": "main",
"index": 0
}
]
]
},
"Text Classifier": {
"main": [
[
{
"node": "Label as Business",
"type": "main",
"index": 0
}
],
[
{
"node": "Label as Personal",
"type": "main",
"index": 0
}
],
[
{
"node": "Label as Appointments",
"type": "main",
"index": 0
}
],
[
{
"node": "Label as Urgent",
"type": "main",
"index": 0
}
],
[
{
"node": "Label as Invoices",
"type": "main",
"index": 0
}
]
]
},
"Label as Business": {
"main": [
[
{
"node": "Clean html and organize into statements",
"type": "main",
"index": 0
}
]
]
},
"Label as Personal": {
"main": [
[
{
"node": "Aggregate",
"type": "main",
"index": 0
}
]
]
},
"Get Email's snippet": {
"main": [
[
{
"node": "Send Notification via Telegram",
"type": "main",
"index": 0
}
]
]
},
"Label as Appointments": {
"main": [
[
{
"node": "Aggregate",
"type": "main",
"index": 0
}
]
]
},
"Google Gemini Chat Model": {
"ai_languageModel": [
[
{
"node": "Text Classifier",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"InfraNodus Save to Graph": {
"main": [
[
{
"node": "Wait",
"type": "main",
"index": 0
}
]
]
},
"Get Label's Name in Gmail": {
"main": [
[
{
"node": "Get Email's snippet",
"type": "main",
"index": 0
}
]
]
},
"InfraNodus Question Generator": {
"main": [
[
{
"node": "Send Insight to Telegram",
"type": "main",
"index": 0
}
]
]
},
"Clean html and organize into statements": {
"main": [
[
{
"node": "InfraNodus Save to Graph",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
高级 - 其他, 人工智能, IT 运维
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
为您的电子邮件生成可视化摘要和知识图谱洞察
为您的电子邮件生成可视化摘要和知识图谱洞察
If
Set
Code
+13
38 节点InfraNodus
其他
AI邮件分诊与GPT-4警报系统及Telegram通知
AI邮件分诊与GPT-4警报系统及Telegram通知
If
Set
Gmail
+22
104 节点Peter Joslyn
客户支持
在可视化参考库中探索n8n节点
在可视化参考库中探索n8n节点
If
Ftp
Set
+93
113 节点I versus AI
其他
🌍 AI WhatsApp翻译器 + 语音转录器与HubSpot集成
基于OpenAI Whisper和GPT-4的多语言WhatsApp翻译器,集成HubSpot
If
N8n
Set
+18
107 节点Amanda Benks
其他
MailChimp自动化
基于AI的餐厅通讯生成器,集成Mailchimp和Telegram审批
If
Set
Code
+16
43 节点Femi Ad
人工智能
✨🔪 基于Llama Parse的高级AI文档解析与文本提取
✨🔪 基于Llama Parse的高级AI文档解析与文本提取
If
Set
Gmail
+14
54 节点Joseph LePage
构建模块
工作流信息
难度等级
高级
节点数量28
分类3
节点类型11
作者
InfraNodus
@infranodusI'm Dmitry, the founder of InfraNodus — an AI text network analysis tool. I'm passionate about networks and data visualization and its ability to reveal what everyone else is missing and to highlight different perspectives. I'm sharing the n8n templates that make use of this unique capability of InfraNodus for multiple scenarios.
外部链接
在 n8n.io 查看 →
分享此工作流