8
n8n 中文网amn8n.com

Tesseract - 理财助手X

高级

这是一个Finance, AI领域的自动化工作流,包含 27 个节点。主要使用 If, Set, Code, Telegram, HttpRequest 等节点,结合人工智能技术实现智能自动化。 通过Telegram使用Tesseract和Llama从收据中提取详细信息

前置要求
  • Telegram Bot Token
  • 可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "V2s5idMq9qNtiMP9",
  "meta": {
    "instanceId": "c2650793f644091dc80fb900fe63448ad1f4b774008de9608064d67294f8307c",
    "templateCredsSetupCompleted": true
  },
  "name": "Tesseract - Money MateX",
  "tags": [],
  "nodes": [
    {
      "id": "42a12e32-36e3-40c1-9f33-9947c0e263a1",
      "name": "格式化摘要消息",
      "type": "n8n-nodes-base.code",
      "position": [
        120,
        200
      ],
      "parameters": {
        "jsCode": "// Get input data from Parser node\nconst inputData = $input.all()[0].json.output || {};\n\n// Default values if data is incomplete\nconst store = inputData.store || { store_name: 'not available', store_location: 'not available' };\nconst transaction = inputData.transaction || { date: 'not available', time: 'not available' };\nconst items = inputData.items || [];\nconst summary = inputData.summary || { total: 'not available', payment_method: 'not available', expense_category: 'not available' };\n\n// Create message with available information\nlet message = '';\n\nif (store.store_name !== 'not available') {\n  message += `📋 Store: ${store.store_name}\\n`;\n}\nif (store.store_location !== 'not available') {\n  message += `📍 Location: ${store.store_location}\\n`;\n}\nif (transaction.date !== 'not available' || transaction.time !== 'not available') {\n  message += `📅 Date: ${transaction.date} ${transaction.time}\\n`;\n}\n\nif (items.length > 0) {\n  message += `\\n🛒 Items:\\n`;\n  items.forEach(item => {\n    message += `- ${item.description || 'not available'}: ${item.total_price || 'not available'}\\n`;\n  });\n}\n\nif (summary.total !== 'not available') {\n  if (parseFloat(summary.total) === 0) {\n    message = 'Looks like an input error, total is 0? Did you get this for free? Please check again.';\n  } else {\n    message += `\\n💸 Total: Rp ${summary.total}\\n`;\n  }\n}\n\nif (summary.expense_category !== 'not available' && parseFloat(summary.total) !== 0) {\n  message += `📌 Category: ${summary.expense_category}\\n`;\n}\n\n// Default message if no information is available\nif (!message) {\n  message = 'No information available from the input.';\n}\n\n// Return message as output\nreturn [\n  {\n    json: {\n      message: message\n    }\n  }\n];"
      },
      "typeVersion": 2
    },
    {
      "id": "4078e97c-debf-4216-8c18-c9e1d8b76fd5",
      "name": "获取 Telegram 文件",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -600,
        -180
      ],
      "parameters": {
        "url": "=https://api.telegram.org/bot<your_bot_token_here>/getFile?file_id={{ $json.message.photo[3].file_id }}",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "819b724d-7ab5-4a59-b3d0-52a77013c311",
      "name": "下载图像",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -300,
        -180
      ],
      "parameters": {
        "url": "=https://api.telegram.org/file/bot<your_bot_token_here>/{{ $node['Get Telegram File'].json['result']['file_path'] }}",
        "options": {
          "response": {
            "response": {
              "responseFormat": "file"
            }
          }
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "9e7d33c8-42d1-4870-8626-087aae8375c6",
      "name": "Telegram 触发器",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -1280,
        0
      ],
      "webhookId": "56161a53-5b4d-46fb-9a9b-d65cdd9a7070",
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "id": "UAvyFVvuZ3qtAjBR",
          "name": "motun8nmoney"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "094293ee-dcdc-4a19-b33a-5361e12177db",
      "name": "固定 - Telegram 触发器",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1280,
        -140
      ],
      "parameters": {
        "color": null,
        "width": 260,
        "height": 180,
        "content": "## 📲 **Telegram 触发器**"
      },
      "typeVersion": 1
    },
    {
      "id": "49a51aa2-0a1c-417e-868e-d6a5f9284846",
      "name": "AI 分类器",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        -200,
        200
      ],
      "parameters": {
        "text": "={{ $json.text }}",
        "messages": {
          "messageValues": [
            {
              "message": "=You are a financial planner expert with a robust parser algorithm. Category options are:\n- Income\n- Expense\n\nExpense options are:\n- Food & Beverages\n- Household\n- Transport\n\nInput may be in English, or Bahasa Indonesia. Always generate output in Input Language.\n\nAnalyze the input. If no expenses or income detected, return 'not found' and 0 for the total. If date is not specified, use {{ $('Telegram Trigger').item.json.message.date}}. For relative dates (e.g., yesterday, tomorrow), use {{ $('Telegram Trigger').item.json.message.date}} as the base. Example: yesterday is {{ $('Telegram Trigger').item.json.message.date}} - 1."
            }
          ]
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 1.6
    },
    {
      "id": "15feb90d-e82f-4c45-8785-2fa9a26e98b7",
      "name": "检查无效输入",
      "type": "n8n-nodes-base.if",
      "position": [
        380,
        200
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "b8408eb5-502b-48bf-b85d-3cea897f60b9",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.message }}",
              "rightValue": "Looks like an input error, total is 0? Did you get this for free? Please check again."
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "cc4cf545-6ef9-455b-a5b6-9876bc2e3866",
      "name": "提取文本输入",
      "type": "n8n-nodes-base.set",
      "position": [
        -600,
        200
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "aa52b49e-1087-4623-83cb-905500c36d3c",
              "name": "message",
              "type": "string",
              "value": "={{ $json.message.text }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "b6dc7831-994c-4539-a456-cbfde3c009a8",
      "name": "检查是否为图片",
      "type": "n8n-nodes-base.if",
      "position": [
        -980,
        0
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "c5999c0e-853d-45e6-bec6-f446defe909d",
              "operator": {
                "type": "string",
                "operation": "exists",
                "singleValue": true
              },
              "leftValue": "={{ $json.message.photo }}",
              "rightValue": "="
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "ea0c351f-8cae-4252-a3b9-34a1d03d3ef2",
      "name": "固定 - 检查是否为图片",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -980,
        -140
      ],
      "parameters": {
        "color": null,
        "height": 180,
        "content": "## 🔍 **检查是否为图片**"
      },
      "typeVersion": 1
    },
    {
      "id": "0e3d255e-69e7-4b78-82c4-1077a3ea91f4",
      "name": "收据解析器",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        -40,
        380
      ],
      "parameters": {
        "jsonSchemaExample": "{\n  \"store\": {\n    \"store_name\": \"Store A\",\n    \"store_location\": \"Store location\"\n  },\n  \"transaction\": {\n    \"date\": \"Transaction date\",\n    \"time\": \"Transaction time\",\n    \"receipt_number\": \"Receipt number\"\n  },\n  \"items\": [\n    {\n      \"description\": \"Item name\",\n      \"quantity\": \"Quantity\",\n      \"unit_price\": \"Unit price\",\n      \"total_price\": \"Item total price\"\n    }\n  ],\n  \"summary\": {\n    \"total\": \"Total (number)\",\n    \"payment_method\": \"Payment method\",\n    \"expense_category\": \"Household\"\n  }\n}"
      },
      "typeVersion": 1.2
    },
    {
      "id": "675093cf-68b1-47b1-a2c5-aeda2e1b5360",
      "name": "AI 分析器",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        -200,
        380
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "openRouterApi": {
          "id": "DPrHlBN0s5WFDxi9",
          "name": "OpenRouter account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "ffed21ef-2aed-4d63-b17e-df83bd4e6c9d",
      "name": "发送错误消息",
      "type": "n8n-nodes-base.telegram",
      "position": [
        700,
        180
      ],
      "webhookId": "6c7df749-2bb0-4dff-95f8-8980325158e1",
      "parameters": {
        "text": "=hello  {{ $('Telegram Trigger').item.json.message.from.first_name }}\n\n{{ $json.message }}",
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "id": "UAvyFVvuZ3qtAjBR",
          "name": "motun8nmoney"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "af0f7caa-f746-4eb3-bf57-4c345e448c23",
      "name": "发送费用摘要",
      "type": "n8n-nodes-base.telegram",
      "position": [
        700,
        460
      ],
      "webhookId": "f7a56f02-1aa8-4caa-9ccb-e4006a98db69",
      "parameters": {
        "text": "=hello  {{ $('Telegram Trigger').item.json.message.from.first_name }}\n\nIni Rekap Belanjamu\n{{ $json.message }}",
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "id": "UAvyFVvuZ3qtAjBR",
          "name": "motun8nmoney"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "9ebee364-9df5-4e05-acee-dad2e3f02d07",
      "name": "固定 - 解析收据数据1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        680,
        -300
      ],
      "parameters": {
        "color": 4,
        "width": 360,
        "height": 200,
        "content": "## **MoneyMate 免费使用!**"
      },
      "typeVersion": 1
    },
    {
      "id": "13a31b33-3ccc-4680-a2c6-cd8255a827e0",
      "name": "从图片中提取值",
      "type": "n8n-nodes-tesseractjs.tesseractNode",
      "position": [
        20,
        -180
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "297c9837-890b-42a2-9234-3d808ada6850",
      "name": "固定 - 发送费用摘要1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        700,
        360
      ],
      "parameters": {
        "color": null,
        "width": 340,
        "content": "## 📬 **发送费用摘要**"
      },
      "typeVersion": 1
    },
    {
      "id": "32f7368a-cac0-4b4e-b944-9a3453a78118",
      "name": "固定 - 提取文本输入1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -600,
        100
      ],
      "parameters": {
        "color": null,
        "width": 260,
        "content": "## 📝 **提取文本输入**"
      },
      "typeVersion": 1
    },
    {
      "id": "c7c9d1cd-368b-4374-9533-e3e76fb48c08",
      "name": "固定 - 解析收据数据2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -60,
        500
      ],
      "parameters": {
        "color": null,
        "width": 300,
        "content": "## 📊 **解析收据数据**"
      },
      "typeVersion": 1
    },
    {
      "id": "4b3b0887-e3a7-4365-a41b-6773d2009d71",
      "name": "固定 - 获取 Telegram 文件1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -600,
        -280
      ],
      "parameters": {
        "color": null,
        "width": 260,
        "content": "## 📦 **获取 Telegram 文件**"
      },
      "typeVersion": 1
    },
    {
      "id": "b1edb77f-6425-47f3-ba63-ed1b00dd6219",
      "name": "固定 - 下载图片2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -300,
        -280
      ],
      "parameters": {
        "color": null,
        "width": 260,
        "content": "## ⬇️ **下载图片**"
      },
      "typeVersion": 1
    },
    {
      "id": "d7437f5c-276d-46b5-956b-72d89809ebc9",
      "name": "固定 - 下载图片3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        -280
      ],
      "parameters": {
        "color": null,
        "width": 260,
        "content": "## 🖼️ **文本提取器**"
      },
      "typeVersion": 1
    },
    {
      "id": "a381a022-9675-4e22-8bb5-b27992cfc3b8",
      "name": "固定 - 格式化摘要消息1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        100,
        80
      ],
      "parameters": {
        "color": null,
        "width": 260,
        "content": "## 🧾 **格式化消息**"
      },
      "typeVersion": 1
    },
    {
      "id": "5234e9fe-0202-460a-8a26-4dbf64ef3141",
      "name": "固定 - AI 分类器1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -200,
        80
      ],
      "parameters": {
        "color": null,
        "width": 280,
        "content": "## 🧠 **AI 分类器**"
      },
      "typeVersion": 1
    },
    {
      "id": "1a7c3a49-a08c-4260-a393-04803a96aa02",
      "name": "固定 - 发送错误消息1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        700,
        80
      ],
      "parameters": {
        "color": null,
        "width": 340,
        "content": "## ❗ **发送错误消息**"
      },
      "typeVersion": 1
    },
    {
      "id": "912961cb-4ce1-41ea-9007-876ad3478a09",
      "name": "固定 - 检查无效输入1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        380,
        80
      ],
      "parameters": {
        "color": null,
        "width": 280,
        "content": "## 🚫 **检查无效输入**"
      },
      "typeVersion": 1
    },
    {
      "id": "56dfbcb7-b04c-41ba-b1e8-c7ad273a8bb4",
      "name": "固定 - OpenRouter AI 模型1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -400,
        500
      ],
      "parameters": {
        "color": null,
        "width": 300,
        "content": "## 🤖 **OpenRouter AI 模型**"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "3c1c7a80-0901-4dcb-a8ce-caa9331ca8c3",
  "connections": {
    "AI Analyzer": {
      "ai_languageModel": [
        [
          {
            "node": "AI Categorizer",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "AI Categorizer": {
      "main": [
        [
          {
            "node": "Format Summary Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Image": {
      "main": [
        [
          {
            "node": "Extract Value From Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Receipt Parser": {
      "ai_outputParser": [
        [
          {
            "node": "AI Categorizer",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Check for Image": {
      "main": [
        [
          {
            "node": "Get Telegram File",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Extract Text Input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Check for Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Telegram File": {
      "main": [
        [
          {
            "node": "Download Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Text Input": {
      "main": [
        [
          {
            "node": "AI Categorizer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Invalid Input": {
      "main": [
        [
          {
            "node": "Send Error Message",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send Expense Summary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Summary Message": {
      "main": [
        [
          {
            "node": "Check Invalid Input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Value From Image": {
      "main": [
        [
          {
            "node": "AI Categorizer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

高级 - 财务, 人工智能

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
高级
节点数量27
分类2
节点类型11
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

外部链接
在 n8n.io 查看

分享此工作流