从Telegram到Google Sheets的发票数据处理与OCR和Gemini AI
高级
这是一个Invoice Processing, AI Summarization领域的自动化工作流,包含 17 个节点。主要使用 Set, Telegram, GoogleDrive, HttpRequest, GoogleSheets 等节点。 使用OCR和Gemini AI从Telegram提取发票数据到Google Sheets
前置要求
- •Telegram Bot Token
- •Google Drive API 凭证
- •可能需要目标 API 的认证凭证
- •Google Sheets API 凭证
- •Google Gemini API Key
使用的节点 (17)
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "cuxPaflo88ySZROw",
"meta": {
"instanceId": "db31bea69a53eada00777682bd2f0392fe4ec4364a135252e7113d3d2d2c1eb4",
"templateCredsSetupCompleted": true
},
"name": "从 Telegram 到 Google Sheets 的发票数据处理与 OCR 和 Gemini AI",
"tags": [],
"nodes": [
{
"id": "a1331d56-97bd-4860-87b8-a34823684def",
"name": "Telegram 触发器1",
"type": "n8n-nodes-base.telegramTrigger",
"position": [
-96,
1024
],
"webhookId": "c6a9a358-6607-4e0e-8bb9-3d065f1716aa",
"parameters": {
"updates": [
"message"
],
"additionalFields": {}
},
"credentials": {
"telegramApi": {
"id": "zoS34yaqfznbZ6AL",
"name": "Telegram account"
}
},
"typeVersion": 1.1
},
{
"id": "bd2ea7b4-0d94-4db5-bd0a-4c673ce99e40",
"name": "下载文件1",
"type": "n8n-nodes-base.telegram",
"position": [
96,
1024
],
"webhookId": "ebd8e13c-36b7-4617-996b-73f2324524de",
"parameters": {
"fileId": "={{ $json.message.document.file_id }}",
"resource": "file",
"additionalFields": {}
},
"credentials": {
"telegramApi": {
"id": "zoS34yaqfznbZ6AL",
"name": "Telegram account"
}
},
"typeVersion": 1.2
},
{
"id": "f73b5682-1048-465b-85ba-c7ba3735ad58",
"name": "更新数据库1",
"type": "n8n-nodes-base.googleSheets",
"position": [
976,
1008
],
"parameters": {
"columns": {
"value": {
"Date": "={{ $json.output.invoiceDate }}",
"Notes": "={{ $json.output.notes }}",
"Due Date": "={{ $json.output.dueDate }}",
"Invoice Number": "={{ $json.output.invoiceNumber }}",
"Billing Address": "={{ $json.output.billingAddress }}",
"Total Amount ($)": "={{ $json.output.totalAmount }}"
},
"schema": [
{
"id": "Invoice Number",
"type": "string",
"display": true,
"required": false,
"displayName": "Invoice Number",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Date",
"type": "string",
"display": true,
"required": false,
"displayName": "Date",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Total Amount ($)",
"type": "string",
"display": true,
"required": false,
"displayName": "Total Amount ($)",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Billing Address",
"type": "string",
"display": true,
"required": false,
"displayName": "Billing Address",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Due Date",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "Due Date",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Notes",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "Notes",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Link",
"type": "string",
"display": true,
"removed": true,
"required": false,
"displayName": "Link",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {
"useAppend": true
},
"operation": "append",
"sheetName": {
"__rl": true,
"mode": "list",
"value": "gid=0",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/15FOh4i1wwy7zv-k4foZc8ubMkMLz_-BibPJKTZ-IziM/edit#gid=0",
"cachedResultName": "Sheet1"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1q0lbD2QTWpjQmRaRvPjLvhc_opSlOA5v9Rng8cC7XJ4",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1q0lbD2QTWpjQmRaRvPjLvhc_opSlOA5v9Rng8cC7XJ4/edit?usp=drivesdk",
"cachedResultName": "Invoice Database"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "sPZTi75OujS3qDy2",
"name": "Google Sheets account"
}
},
"typeVersion": 4.5
},
{
"id": "177b24b3-42c3-4b2e-b9d3-4e9b83ad54b7",
"name": "分析图像1",
"type": "n8n-nodes-base.httpRequest",
"position": [
400,
1024
],
"parameters": {
"url": "https://api.ocr.space/parse/image",
"method": "POST",
"options": {},
"sendBody": true,
"contentType": "multipart-form-data",
"sendHeaders": true,
"bodyParameters": {
"parameters": [
{
"name": "file",
"parameterType": "formBinaryData",
"inputDataFieldName": "data"
}
]
},
"headerParameters": {
"parameters": [
{
"name": "apikey",
"value": "your_key_here"
}
]
}
},
"typeVersion": 4.2
},
{
"id": "077028da-6643-40a7-ada4-08d76f188adf",
"name": "Set1",
"type": "n8n-nodes-base.set",
"position": [
864,
1424
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "a88c44a6-0d32-4678-947a-de5e0d217534",
"name": "Invoice Information",
"type": "string",
"value": "={{ $('Analyze Image1').item.json.ParsedResults[0].ParsedText }}"
},
{
"id": "845587cf-94fc-4d59-9f77-5ad77c4901c0",
"name": "File",
"type": "string",
"value": "={{ $('Add Invoice Image to Drive1').item.json.name }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "fe69af99-9a00-4152-a3ce-11bbcededbe3",
"name": "添加发票图片到 Drive1",
"type": "n8n-nodes-base.googleDrive",
"position": [
288,
1424
],
"parameters": {
"name": "=Invoice [{{ $now.format('MMMM-dd-yyyy')}}]",
"driveId": {
"__rl": true,
"mode": "list",
"value": "My Drive"
},
"options": {},
"folderId": {
"__rl": true,
"mode": "list",
"value": "1VdaeaE6emIxFn62qzXTiYOyC2TvvWUKE",
"cachedResultUrl": "https://drive.google.com/drive/folders/1VdaeaE6emIxFn62qzXTiYOyC2TvvWUKE",
"cachedResultName": "Invoices"
}
},
"credentials": {
"googleDriveOAuth2Api": {
"id": "jtE8vU0TUyfje3N9",
"name": "Google Drive account"
}
},
"typeVersion": 3
},
{
"id": "a229a3fb-0a65-4333-abdf-ecffabbd4311",
"name": "Telegram1",
"type": "n8n-nodes-base.telegram",
"position": [
-32,
1424
],
"webhookId": "7afd636c-26d4-4a93-ba24-ccc150bb66ff",
"parameters": {
"fileId": "={{ $('Download File1').item.json.result.file_id }}",
"resource": "file",
"additionalFields": {}
},
"credentials": {
"telegramApi": {
"id": "zoS34yaqfznbZ6AL",
"name": "Telegram account"
}
},
"typeVersion": 1.2
},
{
"id": "f25af9d9-2720-4ba4-8409-3467375bc416",
"name": "回复1",
"type": "n8n-nodes-base.telegram",
"position": [
1520,
1248
],
"webhookId": "aae2cfdf-646c-4bb4-a266-64768113acdf",
"parameters": {
"text": "={{ $json.output }}",
"chatId": "={{ $('Telegram Trigger1').item.json.message.from.id }}",
"additionalFields": {
"appendAttribution": false
}
},
"credentials": {
"telegramApi": {
"id": "zoS34yaqfznbZ6AL",
"name": "Telegram account"
}
},
"typeVersion": 1.2
},
{
"id": "69fd3fb1-f976-4107-b54c-9c253167bbc7",
"name": "发票代理1",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
1136,
1248
],
"parameters": {
"text": "=[Invoice Information]\n{{ $json['Invoice Information'] }}\n\n[File Name]\n{{ $json.File }}\n\n[Link to the Invoice Database]\n{{ $('Add Invoice Image to Drive1').item.json.webContentLink }}",
"options": {
"systemMessage": "=# System Role\nYou are an efficient invoice assistant that extracts key information from invoices and generates concise user responses.\n\n# Task Specification\nThank the user for submitting an invoice. Extract the total amount, due date, and a summary of the notes from the invoice. Inform the user that the original invoice has been added to the Google Drive, include the file name, and provide the link to the invoice database.\n\n# Specifics and Context\nStart off by thanking the user for submitting an invoice. Respond clearly and concisely to help users quickly understand their invoice details and access the database if needed.\n\n# Example\n## Input\n[Invoice Information] \nInvoice Number: INV-12345 \nDate: 2024-12-01 \nTotal Amount: 950.00 \nBilling Address: 123 Business Lane \nDue Date: 2024-12-15 \nNotes: \n- Please make payment within the due date to avoid late fees. \n- For questions about this invoice, contact billing@business.com or call (123) 456-7890. \n- Payment methods accepted: Bank transfer, credit card, or PayPal. \n- Late payments are subject to a 5% penalty fee \n\n[File Name] \nInvoice [December-05-2024] \n\n[Link to the Invoice Database] \nhttps://docs.google.com/spreadsheets/d/15FOh41iwvy7zv-k4foZc8ubMkMLz_BiBPXJTZ-IziM/edit?usp=sharing \n\n## Output\nThanks for submitting!\n\nThe total amount of the invoice is **$950.00**, and the due date is **2024-12-15**. \n\n**Notes:** \n- Please make payment on time to avoid late fees. \n- Contact billing@business.com or call (123) 456-7890 for any questions. \n- Accepted payment methods: Bank transfer, credit card, and PayPal. \n\nThe original invoice has been added to Google Drive with the file name **\"Invoice [December-05-2024]\"**. \n\nYou can access the invoice database [here](https://docs.google.com/spreadsheets/d/15FOh41iwvy7zv-k4foZc8ubMkMLz_BiBPXJTZ-IziM/edit?usp=sharing).\n"
},
"promptType": "define"
},
"typeVersion": 1.7
},
{
"id": "965f8391-dfb5-4aee-a046-fe6a54dcb914",
"name": "Google Gemini 聊天模型1",
"type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
"position": [
1072,
1472
],
"parameters": {
"options": {}
},
"credentials": {
"googlePalmApi": {
"id": "5CctkrjhvRisPmai",
"name": "Google Gemini(PaLM) Api account"
}
},
"typeVersion": 1
},
{
"id": "f8c30863-5ec3-44ea-ab7c-a40975c2371d",
"name": "AI Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
592,
1008
],
"parameters": {
"text": "={{ $json.ParsedResults[0].ParsedText }}\ntake the text from the image analyzer and put it on this form:\n invoiceNumber: \n invoiceDate: \n totalAmount: \n billingAddress: \n dueDate: \n notes: \n\nif there's no due date, just put the invoice date. and if there's no note, just put no notes",
"options": {},
"promptType": "define",
"hasOutputParser": true
},
"typeVersion": 2.2
},
{
"id": "9513502b-eab5-43a5-9ca4-a3d2495ceef3",
"name": "Google Gemini 聊天模型2",
"type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
"position": [
592,
864
],
"parameters": {
"options": {}
},
"credentials": {
"googlePalmApi": {
"id": "5CctkrjhvRisPmai",
"name": "Google Gemini(PaLM) Api account"
}
},
"typeVersion": 1
},
{
"id": "54b4fb81-272a-4d89-bf4e-ccb635e42874",
"name": "结构化输出解析器",
"type": "@n8n/n8n-nodes-langchain.outputParserStructured",
"position": [
816,
1216
],
"parameters": {
"jsonSchemaExample": "{\n\t\n \"invoiceNumber\": \"\",\n \"invoiceDate\": \"\",\n \"totalAmount\": \"\",\n \"billingAddress\": \"\",\n \"dueDate\": \"\",\n \"notes\": \"\"\n\n}"
},
"typeVersion": 1.3
},
{
"id": "0dd95784-02de-4e47-82f6-6c056480cdf7",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
144,
160
],
"parameters": {
"width": 944,
"height": 592,
"content": "# 开始之前"
},
"typeVersion": 1
},
{
"id": "e6584eb9-c6af-4c66-929f-78eaee434c12",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-768,
1168
],
"parameters": {
"color": 5,
"width": 496,
"height": 256,
"content": "## 需要编辑的内容"
},
"typeVersion": 1
},
{
"id": "a6387f1d-8e79-46a2-a132-418fbede5688",
"name": "便签2",
"type": "n8n-nodes-base.stickyNote",
"position": [
-160,
1776
],
"parameters": {
"color": 4,
"width": 816,
"height": 480,
"content": "## 如何运行"
},
"typeVersion": 1
},
{
"id": "32926f3f-3886-4676-b9b4-19f1431abfd3",
"name": "便签3",
"type": "n8n-nodes-base.stickyNote",
"position": [
928,
1776
],
"parameters": {
"color": 3,
"width": 848,
"height": 448,
"content": "## 行为和逻辑:"
},
"typeVersion": 1
}
],
"active": false,
"pinData": {
"Telegram Trigger1": [
{
"json": {
"message": {
"chat": {
"id": 5656858022,
"type": "private",
"username": "NotLuckyyyyy",
"last_name": "Luckyyy",
"first_name": "Not"
},
"date": 1759841669,
"from": {
"id": 5656858022,
"is_bot": false,
"username": "NotLuckyyyyy",
"last_name": "Luckyyy",
"first_name": "Not",
"language_code": "fr"
},
"document": {
"file_id": "BQACAgQAAxkBAAOqaOUNhYf7Fo8HG_tl7wZGHU-8OHsAArMaAALjjyhTOzuY0KjIs-c2BA",
"file_name": "Invoice - 0020 - Camillo Kessler.pdf",
"file_size": 164066,
"mime_type": "application/pdf",
"file_unique_id": "AgADsxoAAuOPKFM"
},
"message_id": 170
},
"update_id": 767479639
}
}
]
},
"settings": {
"executionOrder": "v1"
},
"versionId": "50933dd8-08c3-47b1-8f2a-2aa4acb292f9",
"connections": {
"Set1": {
"main": [
[
{
"node": "Invoice Agent1",
"type": "main",
"index": 0
}
]
]
},
"AI Agent": {
"main": [
[
{
"node": "Update Database1",
"type": "main",
"index": 0
}
]
]
},
"Telegram1": {
"main": [
[
{
"node": "Add Invoice Image to Drive1",
"type": "main",
"index": 0
}
]
]
},
"Analyze Image1": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
},
"Download File1": {
"main": [
[
{
"node": "Analyze Image1",
"type": "main",
"index": 0
}
]
]
},
"Invoice Agent1": {
"main": [
[
{
"node": "Reply1",
"type": "main",
"index": 0
}
]
]
},
"Update Database1": {
"main": [
[
{
"node": "Telegram1",
"type": "main",
"index": 0
}
]
]
},
"Telegram Trigger1": {
"main": [
[
{
"node": "Download File1",
"type": "main",
"index": 0
}
]
]
},
"Structured Output Parser": {
"ai_outputParser": [
[
{
"node": "AI Agent",
"type": "ai_outputParser",
"index": 0
}
]
]
},
"Google Gemini Chat Model1": {
"ai_languageModel": [
[
{
"node": "Invoice Agent1",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Google Gemini Chat Model2": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Add Invoice Image to Drive1": {
"main": [
[
{
"node": "Set1",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
高级 - 发票处理, AI 摘要总结
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
拍照追踪营养:Telegram 食物照片 → Gemini Vision AI → Google Sheets
拍照追踪营养:Telegram 食物照片 → Gemini Vision AI → Google Sheets
Telegram
Google Drive
Google Sheets
+7
14 节点Anir Agram
个人效率
第一轮 Telegram 和 LinkedIn 快速通道 AI 招聘助手
AI候选人筛选流程:LinkedIn到Telegram,集成Gemini与Apify
If
Set
Code
+15
55 节点Dean Pike
人力资源
使用Google Vision OCR、Telegram和Google Sheets的自动化财务报告
使用Google Vision OCR、AI和Telegram处理收据到Google表格
If
Set
Code
+12
31 节点Budi SJ
发票处理
HR简历筛选
使用Telegram、Gemini AI和Google Workspace自动化简历筛选与分析
If
Set
Merge
+9
23 节点Abdullah Alshiekh
人力资源
LinkedIn和X病毒内容自动引擎
使用AI生成和发布自动创建LinkedIn和X的病毒内容
If
Set
Wait
+26
156 节点Diptamoy Barman
内容创作
音乐生成工作流
使用 Suno API、Flux、Runway 和 Creatomate 生成 AI 歌曲和音乐视频
Set
Wait
Merge
+16
60 节点Joseph
其他