通过Telegram机器人实现的多平台存储AI驱动收据追踪器
中级
这是一个Miscellaneous, AI Summarization, Multimodal AI领域的自动化工作流,包含 14 个节点。主要使用 Notion, Switch, Function, Telegram, GoogleDrive 等节点。 通过Telegram机器人使用GPT-4、OCR、Google Sheets和Notion提取和存储收据数据
前置要求
- •Notion API Key
- •Telegram Bot Token
- •Google Drive API 凭证
- •可能需要目标 API 的认证凭证
- •Google Sheets API 凭证
- •OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "YGDpr1ZwlWwPwpsD",
"meta": {
"instanceId": "d226d4f84a040d022e5981c2ad7340a0fd39f59c8ca44d7b13a48fbd5f93342f"
},
"name": "通过 Telegram 机器人实现的多平台存储 AI 驱动收据追踪器",
"tags": [],
"nodes": [
{
"id": "1ab8188b-b92f-4e84-9d49-1baf01e999cc",
"name": "Telegram 机器人触发器",
"type": "n8n-nodes-base.telegramTrigger",
"position": [
-512,
160
],
"webhookId": "003163f1-4653-4a49-a57a-fd04d78b2d62",
"parameters": {
"updates": [
"message"
],
"additionalFields": {}
},
"credentials": {
"telegramApi": {
"id": "telegram_bot_credentials",
"name": "telegram_bot_credentials"
}
},
"typeVersion": 1.2
},
{
"id": "50cecf34-87c8-4fa6-9599-30f656a4b593",
"name": "消息类型路由器",
"type": "n8n-nodes-base.switch",
"position": [
-272,
160
],
"parameters": {
"rules": {
"values": [
{
"conditions": {
"options": {
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"operator": {
"type": "string",
"operation": "exists"
},
"leftValue": "={{ $json.message.photo }}",
"rightValue": ""
}
]
}
},
{
"conditions": {
"options": {
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"operator": {
"type": "string",
"operation": "exists"
},
"leftValue": "={{ $json.message.text }}",
"rightValue": ""
}
]
}
}
]
},
"options": {}
},
"typeVersion": 3.2
},
{
"id": "32cc964e-d4b2-4072-b3d2-3d41c3f2925f",
"name": "下载 Telegram 图片",
"type": "n8n-nodes-base.telegram",
"position": [
0,
0
],
"webhookId": "59d7a7bc-efca-458a-a8b4-a2d59aad70a4",
"parameters": {
"fileId": "={{ $json.message.photo[$json.message.photo.length - 1].file_id }}",
"resource": "file",
"additionalFields": {}
},
"credentials": {
"telegramApi": {
"id": "telegram_bot_credentials",
"name": "telegram_bot_credentials"
}
},
"typeVersion": 1.2
},
{
"id": "e4c88939-58a3-4dea-b754-d6e542edd530",
"name": "OCR 收据处理",
"type": "n8n-nodes-base.httpRequest",
"position": [
176,
80
],
"parameters": {
"url": "https://api.ocr.space/parse/image",
"method": "POST",
"options": {},
"sendBody": true,
"sendHeaders": true,
"bodyParameters": {
"parameters": [
{
"name": "url",
"value": "https://api.telegram.org/file/bot{{ $credentials.telegramApi.accessToken }}/{{ $('Download Telegram Image').item.json.file_path }}"
},
{
"name": "language",
"value": "eng"
},
{
"name": "detectOrientation",
"value": "true"
},
{
"name": "isTable",
"value": "true"
}
]
},
"headerParameters": {
"parameters": [
{
"name": "apikey",
"value": "={{ $credentials.ocrSpaceApi.apiKey }}"
}
]
}
},
"credentials": {
"ocrSpaceApi": {
"id": "ocr_space_credentials",
"name": "OCR Space API"
}
},
"typeVersion": 4.2
},
{
"id": "3ae3a207-260f-440f-a06d-956aeb675244",
"name": "处理文本消息",
"type": "n8n-nodes-base.function",
"position": [
0,
272
],
"parameters": {
"functionCode": "// Handle text messages - could be manual transaction entry\nconst text = $input.first().json.message.text;\n\n// Simple text parsing for manual entries like: \"McDonald's $12.50 lunch food\"\nconst parts = text.split(' ');\nif (parts.length >= 3) {\n const vendor = parts[0];\n const amountMatch = text.match(/\\$?([0-9]+\\.?[0-9]*)/); \n const amount = amountMatch ? parseFloat(amountMatch[1]) : 0;\n\n return {\n json: {\n ParsedResults: [{\n ParsedText: `Vendor: ${vendor}\\nAmount: $${amount}\\nDate: ${new Date().toISOString().split('T')[0]}\\nType: purchase`\n }]\n }\n };\n} else {\n throw new Error('Invalid text format. Use: \"Vendor $amount description\"');\n}"
},
"typeVersion": 1
},
{
"id": "0d04b8c2-27c7-45a4-9175-43705b0bf9cd",
"name": "AI 购买数据提取器",
"type": "@n8n/n8n-nodes-langchain.openAi",
"position": [
320,
208
],
"parameters": {
"modelId": {
"__rl": true,
"mode": "list",
"value": "gpt-4"
},
"options": {
"maxTokens": 500,
"temperature": 0.1
},
"messages": {
"values": [
{
"role": "user",
"content": "You are an expert receipt and transaction data extractor. Extract transaction data from the provided text and return ONLY a JSON object with these exact fields:\n\n{\n \"vendor\": \"vendor/store name\",\n \"amount\": \"numeric amount (without currency symbol)\",\n \"currency\": \"USD\",\n \"date\": \"YYYY-MM-DD format\",\n \"transaction_type\": \"purchase/refund/payment\",\n \"category\": \"food/shopping/transport/entertainment/other\"\n}\n\nInput text: {{ $json.ParsedResults[0].ParsedText || $json.message.text }}\n\nReturn only the JSON object, no additional text or explanation."
}
]
}
},
"credentials": {
"openAiApi": {
"id": "openai_credentials",
"name": "openai_credentials"
}
},
"typeVersion": 1.8
},
{
"id": "ff76dcfc-40d3-469b-9308-7dec5dcfe4a2",
"name": "交易数据验证器",
"type": "n8n-nodes-base.function",
"position": [
608,
176
],
"parameters": {
"functionCode": "try {\n // Parse AI response\n let aiResponse = $input.first().json.content || $input.first().json.response || $input.first().json;\n\n // Handle if response is string\n if (typeof aiResponse === 'string') {\n // Try to extract JSON from string response\n const jsonMatch = aiResponse.match(/\\{[\\s\\S]*\\}/);\n if (jsonMatch) {\n aiResponse = jsonMatch[0];\n }\n aiResponse = JSON.parse(aiResponse);\n }\n\n // Validate required fields\n const requiredFields = ['vendor', 'amount', 'date', 'transaction_type'];\n const missingFields = requiredFields.filter(field => !aiResponse[field]);\n\n if (missingFields.length > 0) {\n throw new Error(`Missing required fields: ${missingFields.join(', ')}`);\n }\n\n // Generate UUID alternative\n const generateId = () => {\n return 'txn_' + Math.random().toString(36).substring(2) + Date.now().toString(36);\n };\n\n // Standardize and clean data\n const transaction = {\n id: generateId(),\n vendor: String(aiResponse.vendor).trim(),\n amount: parseFloat(aiResponse.amount),\n currency: aiResponse.currency || 'USD',\n date: aiResponse.date,\n transaction_type: aiResponse.transaction_type,\n category: aiResponse.category || 'uncategorized',\n processed_date: new Date().toISOString(),\n user_id: $('Telegram Bot Trigger').item.json.message.from.id,\n username: $('Telegram Bot Trigger').item.json.message.from.username || 'unknown'\n };\n\n // Validate amount is a valid number\n if (isNaN(transaction.amount) || transaction.amount <= 0) {\n throw new Error('Invalid amount detected');\n }\n\n // Validate date format\n if (!transaction.date.match(/^\\d{4}-\\d{2}-\\d{2}$/)) {\n transaction.date = new Date().toISOString().split('T')[0];\n }\n\n return { json: transaction };\n\n} catch (error) {\n // Pass error info for error handler\n return {\n json: {\n error: true,\n message: error.message,\n user_id: $('Telegram Bot Trigger').item.json.message.from.id,\n original_data: $input.first().json\n }\n };\n}"
},
"typeVersion": 1
},
{
"id": "7c57c8da-7156-48d2-936c-33f33c31f797",
"name": "检查错误",
"type": "n8n-nodes-base.switch",
"position": [
800,
176
],
"parameters": {
"rules": {
"values": [
{
"conditions": {
"options": {
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"operator": {
"type": "boolean",
"operation": "true"
},
"leftValue": "={{ $json.error }}",
"rightValue": ""
}
]
}
}
]
},
"options": {}
},
"typeVersion": 3.2
},
{
"id": "06af3c07-0613-4990-95ae-2395aeda7725",
"name": "发送错误消息",
"type": "n8n-nodes-base.telegram",
"position": [
960,
176
],
"webhookId": "74df7c52-973d-4789-9f31-2a1f8dcddbc5",
"parameters": {
"text": "❌ Error processing your receipt:\\n\\n{{ $json.message }}\\n\\nPlease try again or send a clearer image of your receipt.\\n\\nFor text input, use format: \"Vendor $amount description\"",
"chatId": "={{ $json.user_id }}",
"additionalFields": {}
},
"credentials": {
"telegramApi": {
"id": "telegram_bot_credentials",
"name": "telegram_bot_credentials"
}
},
"typeVersion": 1.2
},
{
"id": "9fb86db3-19dd-4dab-9309-69151fffd0d1",
"name": "记录到数据库",
"type": "n8n-nodes-base.googleSheets",
"position": [
1184,
96
],
"parameters": {
"options": {},
"operation": "append",
"sheetName": {
"__rl": true,
"mode": "list",
"value": "Transactions"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "YOUR_GOOGLE_SHEET_ID_HERE"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "google_sheets_credentials",
"name": "google_sheets_credentials"
}
},
"typeVersion": 4.7
},
{
"id": "181ea179-c278-422a-934e-4d5ec899ba3f",
"name": "存储收据图片",
"type": "n8n-nodes-base.googleDrive",
"position": [
1184,
-32
],
"parameters": {
"name": "receipt_{{ $json.id }}_{{ $json.date }}.jpg",
"driveId": {
"__rl": true,
"mode": "list",
"value": "My Drive"
},
"options": {},
"folderId": {
"__rl": true,
"mode": "list",
"value": "root"
}
},
"credentials": {
"googleDriveOAuth2Api": {
"id": "google_drive_credentials",
"name": "google_drive_credentials"
}
},
"typeVersion": 3
},
{
"id": "4249d4f3-e394-4d03-9ee9-d608ba94082f",
"name": "保存到 Notion 数据库",
"type": "n8n-nodes-base.notion",
"position": [
1184,
240
],
"parameters": {
"options": {},
"resource": "databasePage",
"databaseId": "YOUR_NOTION_DATABASE_ID_HERE"
},
"credentials": {
"notionApi": {
"id": "notion_api_credentials",
"name": "notion_api_credentials"
}
},
"typeVersion": 2
},
{
"id": "96f32d63-a79b-4154-a223-76d00336f76e",
"name": "发送到网站 API",
"type": "n8n-nodes-base.httpRequest",
"position": [
1248,
384
],
"parameters": {
"url": "https://yourwebsite.com/api/transactions",
"method": "POST",
"options": {},
"sendBody": true,
"sendHeaders": true,
"bodyParameters": {
"parameters": [
{}
]
},
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
},
{
"name": "Authorization",
"value": "Bearer YOUR_API_KEY_HERE"
}
]
}
},
"typeVersion": 4.2
},
{
"id": "c4e931b6-5988-4cd4-ae38-48650d523213",
"name": "发送确认",
"type": "n8n-nodes-base.telegram",
"position": [
1424,
176
],
"webhookId": "3200b803-5c0e-41bf-8c1e-002447596408",
"parameters": {
"text": "✅ Transaction Recorded Successfully!\\n\\n📊 Details:\\n• Vendor: {{ $json.vendor }}\\n• Amount: {{ $json.currency || 'USD' }} {{ $json.amount }}\\n• Type: {{ $json.transaction_type }}\\n• Category: {{ $json.category }}\\n• Date: {{ $json.date }}\\n• ID: {{ $json.id }}\\n\\n💾 Receipt stored and data recorded in all systems.",
"chatId": "={{ $json.user_id }}",
"additionalFields": {}
},
"credentials": {
"telegramApi": {
"id": "telegram_bot_credentials",
"name": "telegram_bot_credentials"
}
},
"typeVersion": 1.2
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "1d2c44d6-1f06-4c6e-a25d-87c7d8c5e894",
"connections": {
"Check for Errors": {
"main": [
[
{
"node": "Send Error Message",
"type": "main",
"index": 0
}
]
]
},
"Record to Database": {
"main": [
[
{
"node": "Send Confirmation",
"type": "main",
"index": 0
}
]
]
},
"Send Error Message": {
"main": [
[
{
"node": "Save to Notion Database",
"type": "main",
"index": 0
},
{
"node": "Send to Website API",
"type": "main",
"index": 0
},
{
"node": "Record to Database",
"type": "main",
"index": 0
},
{
"node": "Store Receipt Image",
"type": "main",
"index": 0
}
]
]
},
"Handle Text Message": {
"main": [
[
{
"node": "AI Purchase Data Extractor",
"type": "main",
"index": 0
}
]
]
},
"Message Type Router": {
"main": [
[
{
"node": "Download Telegram Image",
"type": "main",
"index": 0
}
],
[
{
"node": "Handle Text Message",
"type": "main",
"index": 0
}
]
]
},
"Send to Website API": {
"main": [
[
{
"node": "Send Confirmation",
"type": "main",
"index": 0
}
]
]
},
"Store Receipt Image": {
"main": [
[
{
"node": "Send Confirmation",
"type": "main",
"index": 0
}
]
]
},
"Telegram Bot Trigger": {
"main": [
[
{
"node": "Message Type Router",
"type": "main",
"index": 0
}
]
]
},
"OCR Receipt Processing": {
"main": [
[
{
"node": "AI Purchase Data Extractor",
"type": "main",
"index": 0
}
]
]
},
"Download Telegram Image": {
"main": [
[
{
"node": "OCR Receipt Processing",
"type": "main",
"index": 0
}
]
]
},
"Save to Notion Database": {
"main": [
[
{
"node": "Send Confirmation",
"type": "main",
"index": 0
}
]
]
},
"AI Purchase Data Extractor": {
"main": [
[
{
"node": "Transaction Data Validator",
"type": "main",
"index": 0
}
]
]
},
"Transaction Data Validator": {
"main": [
[
{
"node": "Check for Errors",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
中级 - 杂项, AI 摘要总结, 多模态 AI
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
交易机器人ICT 2025智能货币概念
使用ICT方法、GPT-4o和Coinbase的自动化加密货币交易机器人
If
Set
Code
+6
15 节点Tegar karunia ilham
杂项
对冲基金多代理交易系统 + GPT-5
使用 GPT-5、Telegram、Coinbase 和 Notion 进行多代理交易分析
Notion
Open Ai
Telegram
+2
23 节点Tegar karunia ilham
杂项
通过 Telegram 机器人找工作:AI 驱动的 LinkedIn、Indeed 和 Monster 抓取器
基于 AI 的 Telegram 机器人,抓取 LinkedIn、Indeed 和 Monster 职位信息
Code
Filter
Airtable
+4
15 节点n8n Automation Expert | Template Creator | 2+ Years Experience
杂项
Telegram 语音消息_音频转录--> AI 摘要和情感分析--> Gmail 投递
使用 AssemblyAI 和 GPT-4.1 转录分析 Telegram 语音消息并发送至 Gmail
If
Wait
Gmail
+7
17 节点Sridevi Edupuganti
杂项
💥 使用 NanoBanana 和 Seedance 创建病毒式广告,通过 upload-post 在社交媒体发布 VIDE II
使用 AI 创建病毒式多媒体广告:NanoBanana、Seedance 和 Suno 用于社交媒体
If
Set
Code
+13
45 节点Dr. Firas
杂项
💥 使用NanoBanana和VEO3生成AI病毒视频,通过Blotato分享到社交平台 - 视频
使用NanoBanana和VEO3生成AI病毒视频,通过Blotato在社交媒体分享
Set
Code
Wait
+13
47 节点Dr. Firas
杂项
工作流信息
难度等级
中级
节点数量14
分类3
节点类型9
作者
Tegar karunia ilham
@tegarkaruniailhamHelping business owners & marketers automate their processes with n8n. Specialist in custom workflows, API integrations, and template development. 📈 100+ successful automation projects 🔧 Premium n8n templates available 💡 Free consultation for custom automation Book a consultation for your business digital transformation!"
外部链接
在 n8n.io 查看 →
分享此工作流