使用Gmail、AI分析和Telegram提醒处理发票和工程邮件
高级
这是一个Invoice Processing, AI Summarization领域的自动化工作流,包含 25 个节点。主要使用 Set, Code, Gmail, Merge, Filter 等节点。 使用Gmail、AI分析和Telegram提醒处理发票和工程邮件
前置要求
- •Google 账号和 Gmail API 凭证
- •Telegram Bot Token
使用的节点 (25)
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"meta": {
"instanceId": "05e517e412ebf2ee257e40e29bface724e41c0e3e3521bc8be9935c347ca5bfb",
"templateCredsSetupCompleted": true
},
"nodes": [
{
"id": "475789cb-c3cf-49d5-94d0-4f4256ab10a4",
"name": "Gmail 触发器",
"type": "n8n-nodes-base.gmailTrigger",
"position": [
-176,
880
],
"parameters": {
"simple": false,
"filters": {},
"options": {
"downloadAttachments": true,
"dataPropertyAttachmentsPrefixName": "attachment_"
},
"pollTimes": {
"item": [
{
"mode": "everyMinute"
}
]
}
},
"credentials": {
"gmailOAuth2": {
"id": "DYpY3gIwFHbrSDry",
"name": "Gmail account"
}
},
"typeVersion": 1.2
},
{
"id": "8f3068ac-1e05-442a-a43e-cc89bd2a88e7",
"name": "获取消息",
"type": "n8n-nodes-base.gmail",
"position": [
192,
880
],
"webhookId": "d3f48d97-7b4a-4486-917d-2269d2f29c51",
"parameters": {
"simple": false,
"options": {
"downloadAttachments": true,
"dataPropertyAttachmentsPrefixName": "attachment_"
},
"messageId": "={{ $('Gmail Trigger').item.json.id }}",
"operation": "get"
},
"credentials": {
"gmailOAuth2": {
"id": "DYpY3gIwFHbrSDry",
"name": "Gmail account"
}
},
"typeVersion": 2.1
},
{
"id": "f6c752e4-24ba-4e28-9c99-cef45aed9147",
"name": "AI Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
400,
1120
],
"parameters": {
"text": "=Subject:\n{{ $('Get a message').item.json.subject }}\n\nUser input : {{ $('Get a message').item.json.text }}\n\nHas Attachment: {{ $json.hasAttachment }}\n\n\n\n\n",
"options": {
"systemMessage": "=You are the personal emailing assistant for Zenith Engineering, a company that manufactures conveyors. Your role is to ensure emails are responded to professionally and categorized correctly. \n\n##Today’s date and time is: {{ $now }}\n\n##Your tasks:\n\nCategorize each email by priority.\n\nDraft polite, professional replies using templates, past messages, or context.\n\nAuto-reply to common inquiries (e.g., catalogs, pricing, lead times) using approved text.\n\nDo not make up things, if you don't know, say so.\n\nIdentify attachments (e.g., drawings, POs, invoices) and label them.\n\n##Rules:\n\nNever return empty values.\n\nDo not call tools if required data is missing.\n\nIf HasAttachment is True:\n\nMark as \"Important\"\n\nThank the sender and say it’s being reviewed.\n\nIf hasnoattachment is False or NO: Ask sender to resend the document politely.\n\n##Labels:\n\n\"Fishy\" – Spammy or irrelevant\n\n\"Important\" – Invoices, quotes, POs, attachment\n\n\"Promos\" – Product/service promotions\n\n\"Meeting\" – Calls, events, scheduling\n\n\"Check Later\" – Anything else\n\n\nResponse should be in JSON Object format.\n\nOnly return a valid JSON object with exactly two keys: \"Label\" and \"Response\". Do not include any explanation, markdown formatting, or extra text.\nHere's the structure example that you need to categorize each part of your response in:\n\n{\n\t\"Label\": \"Important\",\n\t\"Response\": \"Response\"\n}"
},
"promptType": "define",
"hasOutputParser": true
},
"typeVersion": 2
},
{
"id": "5e52c675-3d01-403e-a42e-c5b490054e56",
"name": "调试代码以查找附件",
"type": "n8n-nodes-base.code",
"position": [
160,
1120
],
"parameters": {
"jsCode": "// Initialize list to hold invoice filenames\nlet invoiceAttachments = [];\n\n// Check $binary for keys like 'attachment_0', 'attachment_1'\nif ($binary && Object.keys($binary).length > 0) {\n for (const key of Object.keys($binary)) {\n const file = $binary[key];\n\n // If filename contains 'invoice', treat it as an invoice attachment\n if (\n file.fileName &&\n /invoice/i.test(file.fileName)\n ) {\n invoiceAttachments.push(file.fileName);\n }\n }\n}\n\n// Return updated JSON with invoice detection\nreturn [\n {\n json: {\n ...$json,\n hasInvoiceAttachment: invoiceAttachments.length > 0,\n invoiceFilenames: invoiceAttachments.join(', ')\n }\n }\n];\n"
},
"typeVersion": 2
},
{
"id": "423dc208-4abc-43bc-936e-8081b7c84b06",
"name": "结构化输出解析器1",
"type": "@n8n/n8n-nodes-langchain.outputParserStructured",
"position": [
592,
1360
],
"parameters": {
"jsonSchemaExample": "{\n\t\"Label\": \"Important\",\n\t\"Response\": \"Response\"\n}"
},
"typeVersion": 1.3
},
{
"id": "6340421b-dd62-47a4-9dfc-5dd08c66b387",
"name": "OpenRouter 聊天模型1",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
"position": [
400,
1360
],
"parameters": {
"model": "google/gemini-2.5-flash-lite-preview-06-17",
"options": {}
},
"credentials": {
"openRouterApi": {
"id": "L5v5N0prxpTBJDSI",
"name": "OpenRouter account"
}
},
"typeVersion": 1
},
{
"id": "abb27cad-f021-448a-9f53-349f5766a0af",
"name": "信息提取器",
"type": "@n8n/n8n-nodes-langchain.informationExtractor",
"position": [
1632,
1296
],
"parameters": {
"text": "={{ $json.text }}",
"options": {
"systemPromptTemplate": "=You are an expert extraction algorithm.\nOnly extract relevant information from the text.\nIf you do not know the value of an attribute asked to extract, you may omit the attribute's value.\n\n\nYour job is to:\n\n# Extract key information from the invoice such as:\n - invoice_number\n - invoice_date\n - due_date (if available)\n - vendor_name\n - total_amount\n - currency (e.g., USD, IDR, etc.)\n - items (as a list of item descriptions and their amounts)\n - tax (if available)"
},
"schemaType": "manual",
"inputSchema": "{\n \"invoice_number\": \"\",\n \"invoice_date\": \"\",\n \"due_date\": \"\",\n \"vendor_name\": \"\",\n \"total_amount\": \"\",\n \"currency\": \"\",\n \"items\": [\n {\n \"description\": \"\",\n \"amount\": \"\"\n }\n ],\n \"tax\": \"\",\n \"category\": \"\"\n}"
},
"typeVersion": 1.2
},
{
"id": "b534c247-73ec-4a18-a9ef-75d9d94f3702",
"name": "拆分输出",
"type": "n8n-nodes-base.splitOut",
"position": [
528,
576
],
"parameters": {
"include": "allOtherFields",
"options": {
"includeBinary": true
},
"fieldToSplitOut": "attachments"
},
"typeVersion": 1
},
{
"id": "e03d09d3-b733-4ebb-9e6b-0e3dddd46534",
"name": "从文件提取",
"type": "n8n-nodes-base.extractFromFile",
"position": [
1104,
1296
],
"parameters": {
"options": {},
"operation": "pdf",
"binaryPropertyName": "={{ $json.attachments }}"
},
"typeVersion": 1
},
{
"id": "88c73900-f883-4fe6-a1f3-bead44b4f6e6",
"name": "编辑字段1",
"type": "n8n-nodes-base.set",
"position": [
368,
592
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "540e2d20-e09f-4174-bcef-6e89c14a02be",
"name": "attachments",
"type": "array",
"value": "={{ $('Get a message').item.binary.keys () }}"
},
{
"id": "f1efedf8-155e-4fa1-9033-28129e3bf896",
"name": "message_id",
"type": "string",
"value": "={{ $json.id }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "3be55a2e-b289-4919-80c1-927eb487fe03",
"name": "编辑字段2",
"type": "n8n-nodes-base.set",
"position": [
368,
736
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "540e2d20-e09f-4174-bcef-6e89c14a02be",
"name": "attachments_metadata",
"type": "array",
"value": "={{ $('Get a message').item.binary.values () }}"
},
{
"id": "f1efedf8-155e-4fa1-9033-28129e3bf896",
"name": "message_id",
"type": "string",
"value": "={{ $json.id }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "92542f0e-7681-4933-a11b-d4291e5338b5",
"name": "拆分输出1",
"type": "n8n-nodes-base.splitOut",
"position": [
528,
736
],
"parameters": {
"include": "allOtherFields",
"options": {
"includeBinary": true
},
"fieldToSplitOut": "attachments_metadata"
},
"typeVersion": 1
},
{
"id": "92e64272-92eb-4bcd-b61d-ba3fe610a1d5",
"name": "合并",
"type": "n8n-nodes-base.merge",
"position": [
704,
864
],
"parameters": {
"mode": "combine",
"options": {},
"combineBy": "combineByPosition"
},
"typeVersion": 3.2
},
{
"id": "fe54224c-447d-4870-a659-2bfd755bfc3e",
"name": "过滤器",
"type": "n8n-nodes-base.filter",
"position": [
928,
864
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "3e8c8981-2067-4589-a297-98180da98539",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.attachments_metadata.fileType }}",
"rightValue": "=pdf"
}
]
}
},
"typeVersion": 2.2
},
{
"id": "3864b113-2733-408b-b2cc-4c3e409cbab0",
"name": "合并1",
"type": "n8n-nodes-base.merge",
"position": [
1104,
1056
],
"parameters": {
"mode": "combine",
"options": {},
"advanced": true,
"mergeByFields": {
"values": [
{
"field1": "message_id",
"field2": "id"
}
]
}
},
"typeVersion": 3.2
},
{
"id": "44ff8834-36e3-40d5-976f-2f289f9e0474",
"name": "过滤器1",
"type": "n8n-nodes-base.filter",
"position": [
16,
880
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "4ba5f268-39bd-4fab-bd79-897522c7eb34",
"operator": {
"type": "object",
"operation": "exists",
"singleValue": true
},
"leftValue": "={{ $('Gmail Trigger').item.binary }}",
"rightValue": ""
}
]
}
},
"typeVersion": 2.2
},
{
"id": "7e1ec925-c0e1-492d-891f-81127bdcc231",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-240,
528
],
"parameters": {
"color": 2,
"width": 1632,
"height": 1008,
"content": "## 多文档提取器"
},
"typeVersion": 1
},
{
"id": "9b6c2acc-fdeb-4bed-9ac0-00092b354b74",
"name": "提取文件详情",
"type": "n8n-nodes-base.set",
"position": [
2016,
1296
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "6a37b21c-1372-43e4-b277-53377a5fd57e",
"name": "output.invoice_number",
"type": "string",
"value": "={{ $json.output.invoice_number }}"
},
{
"id": "276f7e85-cba7-43a2-8d54-9d25eb534f92",
"name": "output.invoice_date",
"type": "string",
"value": "={{ $json.output.invoice_date }}"
},
{
"id": "d0348246-509c-4fec-a6da-eed65b74d5d5",
"name": "output.vendor_name",
"type": "string",
"value": "={{ $json.output.vendor_name }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "ad2c0eb2-0691-4401-b708-76c596fc1526",
"name": "转换名称以下载文件",
"type": "n8n-nodes-base.code",
"position": [
1632,
1056
],
"parameters": {
"jsCode": "let results = [];\n\nfor (item of items) {\n for (key of Object.keys(item.binary)) {\n results.push({\n json: {\n fileName: item.binary[key].fileName\n },\n binary: {\n data: item.binary[key]\n }\n });\n }\n}\n\nreturn results;\n"
},
"typeVersion": 2
},
{
"id": "07b492c0-2c62-4d96-91b7-d63ad46baf7c",
"name": "移除重复项",
"type": "n8n-nodes-base.removeDuplicates",
"position": [
2016,
1056
],
"parameters": {
"options": {}
},
"typeVersion": 2
},
{
"id": "badba30d-fe2d-413c-a25e-3b75d13985bd",
"name": "Gemini",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
"position": [
1632,
1440
],
"parameters": {
"model": "google/gemini-2.5-flash-lite-preview-06-17",
"options": {}
},
"credentials": {
"openRouterApi": {
"id": "L5v5N0prxpTBJDSI",
"name": "OpenRouter account"
}
},
"typeVersion": 1
},
{
"id": "29edd5f6-1a03-465c-94ba-c04ca8bea09f",
"name": "便签5",
"type": "n8n-nodes-base.stickyNote",
"position": [
1472,
912
],
"parameters": {
"color": 7,
"width": 1024,
"height": 640,
"content": "## Telegram - 发票和详细信息发送至工程部门"
},
"typeVersion": 1
},
{
"id": "ef2167ee-0038-49dd-ac6b-5a1086956294",
"name": "回复同一线程",
"type": "n8n-nodes-base.gmail",
"position": [
768,
1120
],
"webhookId": "731a78d2-7a47-4ad9-9a3b-231bcf0bfe9a",
"parameters": {
"message": "={{ $json.output.Response }}",
"options": {},
"resource": "thread",
"threadId": "={{ $('Gmail Trigger').item.json.threadId }}",
"messageId": "={{ $('Gmail Trigger').item.json.id }}",
"operation": "reply"
},
"credentials": {
"gmailOAuth2": {
"id": "DYpY3gIwFHbrSDry",
"name": "Gmail account"
}
},
"typeVersion": 2.1
},
{
"id": "7f745152-b54a-4f51-ba13-b78a3cf498cd",
"name": "发送重要详情",
"type": "n8n-nodes-base.telegram",
"position": [
2240,
1296
],
"webhookId": "b347e715-39b5-4cef-a770-6b48cc9e9d1f",
"parameters": {
"text": "=Invoice Number : {{ $json.output.invoice_number }}\n\nDate : {{ $json.output.invoice_date }}\n\nFrom : {{ $json.output.vendor_name }}\n\n{{ $json.output }}",
"additionalFields": {
"appendAttribution": false
}
},
"credentials": {
"telegramApi": {
"id": "xUp4WTeylZ71Q4Io",
"name": "Telegram account"
}
},
"typeVersion": 1.2
},
{
"id": "bdfe5a8c-27c2-400d-a43f-126714240af3",
"name": "发送文档(例如 dwg 文件)",
"type": "n8n-nodes-base.telegram",
"position": [
2240,
1056
],
"webhookId": "8681d180-1d55-4b0e-a85e-9fbff1e98491",
"parameters": {
"operation": "sendDocument",
"binaryData": true,
"additionalFields": {}
},
"credentials": {
"telegramApi": {
"id": "xUp4WTeylZ71Q4Io",
"name": "Telegram account"
}
},
"typeVersion": 1.2,
"alwaysOutputData": false
}
],
"pinData": {},
"connections": {
"Merge": {
"main": [
[
{
"node": "Filter",
"type": "main",
"index": 0
}
]
]
},
"Filter": {
"main": [
[
{
"node": "Merge1",
"type": "main",
"index": 0
}
]
]
},
"Gemini": {
"ai_languageModel": [
[
{
"node": "Information Extractor",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Merge1": {
"main": [
[
{
"node": "Extract from File",
"type": "main",
"index": 0
},
{
"node": "Convert Names to download files",
"type": "main",
"index": 0
}
]
]
},
"Filter1": {
"main": [
[
{
"node": "Get a message",
"type": "main",
"index": 0
}
]
]
},
"AI Agent": {
"main": [
[
{
"node": "Reply to same thread",
"type": "main",
"index": 0
}
]
]
},
"Split Out": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 0
}
]
]
},
"Split Out1": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 1
}
]
]
},
"Edit Fields1": {
"main": [
[
{
"node": "Split Out",
"type": "main",
"index": 0
}
]
]
},
"Edit Fields2": {
"main": [
[
{
"node": "Split Out1",
"type": "main",
"index": 0
}
]
]
},
"Get a message": {
"main": [
[
{
"node": "Edit Fields1",
"type": "main",
"index": 0
},
{
"node": "Edit Fields2",
"type": "main",
"index": 0
},
{
"node": "Merge1",
"type": "main",
"index": 1
},
{
"node": "Debugged code to find attachment",
"type": "main",
"index": 0
}
]
]
},
"Gmail Trigger": {
"main": [
[
{
"node": "Filter1",
"type": "main",
"index": 0
}
]
]
},
"Extract from File": {
"main": [
[
{
"node": "Information Extractor",
"type": "main",
"index": 0
}
]
]
},
"Remove Duplicates": {
"main": [
[
{
"node": "Send a document (e.g. dwg files)",
"type": "main",
"index": 0
}
]
]
},
"Information Extractor": {
"main": [
[
{
"node": "Extracting File Details",
"type": "main",
"index": 0
}
]
]
},
"OpenRouter Chat Model1": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Extracting File Details": {
"main": [
[
{
"node": "Send important details",
"type": "main",
"index": 0
}
]
]
},
"Structured Output Parser1": {
"ai_outputParser": [
[
{
"node": "AI Agent",
"type": "ai_outputParser",
"index": 0
}
]
]
},
"Convert Names to download files": {
"main": [
[
{
"node": "Remove Duplicates",
"type": "main",
"index": 0
}
]
]
},
"Debugged code to find attachment": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
高级 - 发票处理, AI 摘要总结
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
在可视化参考库中探索n8n节点
在可视化参考库中探索n8n节点
If
Ftp
Set
+93
113 节点I versus AI
其他
灵活新闻聚合器 - 多源集成、AI分析和可设置频道
多源新闻策展系统,集成Mistral AI分析、摘要和自定义频道
If
Set
Xml
+32
120 节点Hybroht
内容创作
使用 Bright Data API 和 AI 抓取分析 Google 广告并发送邮件报告
使用 Bright Data API 和 AI 抓取分析 Google 广告并发送邮件报告
Set
Code
Gmail
+15
45 节点Zacharia Kimotho
市场调研
使用Google Vision OCR、Telegram和Google Sheets的自动化财务报告
使用Google Vision OCR、AI和Telegram处理收据到Google表格
If
Set
Code
+12
31 节点Budi SJ
发票处理
使用 Mistral AI、LinkedIn 和 Google Sheets 自动化职位搜索与简历定制
使用 Mistral AI、LinkedIn 和 Google Sheets 自动化职位搜索与简历定制
Set
Code
Html
+18
46 节点Jordan Hoyle
个人效率
我的工作流3
使用AI、Gmail、GoogleDrive和Airtable的自动简历筛选与评分
Set
Code
Merge
+10
23 节点usamaahmed
人力资源
工作流信息
难度等级
高级
节点数量25
分类2
节点类型15
作者
Limbraj More
@limbrajmoreAn investment banker from India who's recently been diving deep into the world of AI and tech. While finance was the starting point, curiosity led into exploring artificial intelligence, digital trends, and the future of innovation. Always learning, always evolving , blending my finance background with a growing passion for tech.
外部链接
在 n8n.io 查看 →
分享此工作流