8
n8n 中文网amn8n.com

AI驱动的Telegram发票提取器

高级

这是一个Miscellaneous, AI Summarization, Multimodal AI领域的自动化工作流,包含 17 个节点。主要使用 Set, Switch, Telegram, AirtableTool, Agent 等节点。 基于AI的Telegram发票提取器,数据导出至Airtable

前置要求
  • Telegram Bot Token
  • Airtable API Key
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "93492ad7b85fe52ec3ead1e96f0add030f2389fbe9175f2fc6dc08fb0457b641",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "189e5268-10ed-4031-82d0-1b8e3e357b54",
      "name": "OpenAI 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1552,
        688
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o",
          "cachedResultName": "gpt-4o"
        },
        "options": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "049ecc9f-4b50-4816-85de-de014d5d67bd",
      "name": "简单记忆",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        1712,
        688
      ],
      "parameters": {
        "sessionKey": "={{ $('Telegram Trigger1').item.json.message.chat.id }}",
        "sessionIdType": "customKey"
      },
      "typeVersion": 1.3
    },
    {
      "id": "a2fc4040-1e46-4dcf-a737-a5daf958b3d3",
      "name": "创建行项目1",
      "type": "n8n-nodes-base.airtableTool",
      "position": [
        2032,
        688
      ],
      "parameters": {
        "base": {
          "__rl": true,
          "mode": "list",
          "value": "appG8Paox9E4p7vMR",
          "cachedResultUrl": "https://airtable.com/appG8Paox9E4p7vMR",
          "cachedResultName": "Invoice Tracker Proper"
        },
        "table": {
          "__rl": true,
          "mode": "list",
          "value": "tblVqPbTLM5IgTnyW",
          "cachedResultUrl": "https://airtable.com/appG8Paox9E4p7vMR/tblVqPbTLM5IgTnyW",
          "cachedResultName": "Line Items"
        },
        "columns": {
          "value": {
            "Quantity": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Quantity', `number only`, 'number') }}",
            "Sub Total": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Sub_Total', `number only`, 'number') }}",
            "Unit Type": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Unit_Type', ``, 'string') }}",
            "Unit Price": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Unit_Price', `number only`, 'number') }}",
            "Description": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Description', ``, 'string') }}",
            "Product Code": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Product_Code', ``, 'string') }}",
            "Invoice (linked)": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Invoice__linked_', ``, 'string') }}"
          },
          "schema": [
            {
              "id": "Product Code",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Product Code",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Invoice Number (from Invoice (linked)) 2",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "Invoice Number (from Invoice (linked)) 2",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Invoice Date (from Invoice (linked))",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "Invoice Date (from Invoice (linked))",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Supplier (from Invoice (linked)) 2",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "Supplier (from Invoice (linked)) 2",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Description",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Description",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Unit Price",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Unit Price",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Quantity",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Quantity",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Unit Type",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Unit Type",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Sub Total",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Sub Total",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Invoice (linked)",
              "type": "array",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Invoice (linked)",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "create",
        "descriptionType": "manual",
        "toolDescription": "Create line items in Airtable"
      },
      "typeVersion": 2.1
    },
    {
      "id": "8b7727e5-d8a6-45c6-ab3a-ca0d9aaad5cf",
      "name": "创建发票1",
      "type": "n8n-nodes-base.airtableTool",
      "position": [
        1872,
        720
      ],
      "parameters": {
        "base": {
          "__rl": true,
          "mode": "list",
          "value": "appG8Paox9E4p7vMR",
          "cachedResultUrl": "https://airtable.com/appG8Paox9E4p7vMR",
          "cachedResultName": "Invoice Tracker Proper"
        },
        "table": {
          "__rl": true,
          "mode": "list",
          "value": "tblKpTcfWab8jl8Ru",
          "cachedResultUrl": "https://airtable.com/appG8Paox9E4p7vMR/tblKpTcfWab8jl8Ru",
          "cachedResultName": "Invoices"
        },
        "columns": {
          "value": {
            "Due Date": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Due_Date', ``, 'string') }}",
            "Supplier": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Supplier', ``, 'string') }}",
            "PO Number": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('PO_Number', ``, 'string') }}",
            "Total Tax": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Total_Tax', ``, 'number') }}",
            "Invoice Date": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Invoice_Date', ``, 'string') }}",
            "Total Amount": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Total_Amount', ``, 'number') }}",
            "Delivery Date": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Delivery_Date', ``, 'string') }}",
            "Receiver Name": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Receiver_Name', ``, 'string') }}",
            "Invoice Number": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Invoice_Number', ``, 'string') }}",
            "Supplier Tax ID": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Supplier_Tax_ID', ``, 'string') }}",
            "Receiver Address": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Receiver_Address', ``, 'string') }}",
            "Supplier Address": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Supplier_Address', ``, 'string') }}"
          },
          "schema": [
            {
              "id": "Invoice Number",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Invoice Number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Invoice Date",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Invoice Date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Receiver Name",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Receiver Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Supplier",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Supplier",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Supplier Address",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Supplier Address",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Supplier Tax ID",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Supplier Tax ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "PO Number",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "PO Number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Receiver Address",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Receiver Address",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Delivery Date",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Delivery Date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Due Date",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Due Date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Total Tax",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Total Tax",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Total Amount",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Total Amount",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Line Items",
              "type": "array",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "Line Items",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "create",
        "descriptionType": "manual",
        "toolDescription": "Create a new invoice record in Airtable"
      },
      "typeVersion": 2.1
    },
    {
      "id": "891591f1-c49c-4a07-8e31-897c170ca3d3",
      "name": "Telegram3",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2208,
        448
      ],
      "webhookId": "3f60f8f1-081d-4ece-b9e9-49ffb0ab02ce",
      "parameters": {
        "text": "={{ $json.output }}",
        "chatId": "={{ $('Telegram Trigger1').item.json.message.chat.id }}",
        "additionalFields": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "8d8a2f8e-c597-4c1c-b3b5-ef885a34fb58",
      "name": "编辑字段1",
      "type": "n8n-nodes-base.set",
      "position": [
        1424,
        448
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "1fcca79e-3f1a-4f0f-a3c2-1c066ad6fcc3",
              "name": "Message",
              "type": "string",
              "value": "={{ $json.text }} {{ $json.message.text }}"
            },
            {
              "id": "e8adf125-46bd-4579-a4c9-7f2cea533b0f",
              "name": "memory_id",
              "type": "string",
              "value": "={{ $json.message.chat.id }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "464bf8e2-36b8-4fac-a8f5-aa6534a33ba6",
      "name": "Telegram2",
      "type": "n8n-nodes-base.telegram",
      "position": [
        976,
        304
      ],
      "webhookId": "2e4d1e34-c4d0-43de-9e4d-609274803532",
      "parameters": {
        "fileId": "={{ $json.message.document.file_id }}",
        "resource": "file",
        "additionalFields": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "22233cf2-bea7-4e63-99ee-6fb4362ec5a5",
      "name": "从文件1提取",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        1184,
        288
      ],
      "parameters": {
        "options": {},
        "operation": "pdf"
      },
      "typeVersion": 1
    },
    {
      "id": "66f8e4dc-87ab-4aef-bbb6-092b9e9c2aa9",
      "name": "Switch1",
      "type": "n8n-nodes-base.switch",
      "position": [
        768,
        448
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "4718cf27-1e39-40f9-b77d-4cdb3032e051",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.message.document.mime_type }}",
                    "rightValue": "=application/pdf"
                  }
                ]
              }
            }
          ]
        },
        "options": {
          "fallbackOutput": "extra"
        }
      },
      "typeVersion": 3.2
    },
    {
      "id": "9a9456f2-822d-49dc-bef7-c388fa305a25",
      "name": "Telegram 触发器1",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        544,
        448
      ],
      "webhookId": "9f56f20f-4a13-4826-aac7-c17056341c2b",
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "typeVersion": 1.1
    },
    {
      "id": "dfe45125-5b47-49ac-a554-b711877d9dd0",
      "name": "AI Agent1",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1744,
        448
      ],
      "parameters": {
        "text": "={{ $json.Message }}",
        "options": {
          "systemMessage": "=You are a helpful assistant that extracts structured data from invoices and logs it into Airtable.\n\n⸻\n\n🧑‍💼 Step 1: Ask for the Company or Individual Name\n\nBefore we begin, please provide the company or individual name associated with this invoice.\n\nWait for the user’s input and store this as client_name.\n\n⸻\n\n📎 Step 2: Ask for Invoice Upload\n\nNow, please upload the invoice.\n\nOnce uploaded, continue with data extraction.\n\n⸻\n\n📤 Step 3: Extract Invoice-Level Information\n\nFrom the invoice, extract the following fields and prepare to create a record in the Invoices table:\n\t•\tInvoice Number\n\t•\tInvoice Date\n\t•\tSupplier\n\t•\tSupplier Address\n\t•\tSupplier Tax ID\n\t•\tPO Number\n\t•\tDue Date\n\t•\tTotal Tax (as number only, no currency symbols)\n\t•\tTotal Amount (as number only, no currency symbols)\n\t•\tClient Name (use the input from Step 1)\n\nUse the Create Invoice tool and remember the returned record ID.\n\n⸻\n\n🧾 Step 4: Extract Each Line Item\n\nUse the Create Item tool for each item and extract the following data:\n - product code\n - description\n - unit price\n - quantity\n - unit type\n - sub total\nalso use the record id returned from the Create Invoice tool, wrapped in an array: [value]. This should be passed to the Invoice (linked) field as an array to create the relationship.\n\nIgnore zero quantity items.\n\n⸻\n\n⚠️ Important Data Format Rules:\n- Total Tax and Total Amount must be numbers only (no currency symbols)\n- Invoice_linked must be a JSON array string containing the invoice record ID: [\"rec123abc\"]\n- All date fields should be in YYYY-MM-DD format\n- If any field is missing, use \"MISSING\" as the value\n\n⚠️ Critical: When providing the Invoice_linked value, you MUST format it as a JSON array string like this: [\"rec123abc\"] where rec123abc is the actual record ID returned from the Create Invoice tool."
        },
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "b72a51ed-2565-44f5-a604-404b7cce3464",
      "name": "设置要求",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        176,
        -144
      ],
      "parameters": {
        "width": 300,
        "height": 474,
        "content": "📋 设置要求"
      },
      "typeVersion": 1
    },
    {
      "id": "ea014ffe-0cfc-4b11-9f30-25540383525c",
      "name": "工作流概览",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        496,
        -144
      ],
      "parameters": {
        "width": 300,
        "height": 472,
        "content": "🤖 发票分类器工作流"
      },
      "typeVersion": 1
    },
    {
      "id": "e3a61fbb-0fb3-4a5a-baba-a308aa9abac7",
      "name": "使用说明",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        176,
        352
      ],
      "parameters": {
        "width": 300,
        "height": 524,
        "content": "📱 如何使用"
      },
      "typeVersion": 1
    },
    {
      "id": "a4a18c9d-f8f3-44a4-b497-c8bd3ead9b53",
      "name": "数据结构",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1232,
        -208
      ],
      "parameters": {
        "width": 280,
        "height": 440,
        "content": "📊 AIRTABLE 数据结构"
      },
      "typeVersion": 1
    },
    {
      "id": "00cc68f8-d71e-49fe-9a14-86159a111c7d",
      "name": "故障排除",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1568,
        -272
      ],
      "parameters": {
        "width": 280,
        "height": 590,
        "content": "🔧 故障排除"
      },
      "typeVersion": 1
    },
    {
      "id": "1c1abbbd-b162-4803-9b90-28e663424a61",
      "name": "配置说明",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        864,
        -288
      ],
      "parameters": {
        "width": 300,
        "height": 544,
        "content": "⚙️ 配置说明"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "Switch1": {
      "main": [
        [
          {
            "node": "Telegram2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Edit Fields1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent1": {
      "main": [
        [
          {
            "node": "Telegram3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram2": {
      "main": [
        [
          {
            "node": "Extract from File1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields1": {
      "main": [
        [
          {
            "node": "AI Agent1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Create Invoice1": {
      "ai_tool": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Create Line Item1": {
      "ai_tool": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger1": {
      "main": [
        [
          {
            "node": "Switch1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from File1": {
      "main": [
        [
          {
            "node": "Edit Fields1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 杂项, AI 摘要总结, 多模态 AI

需要付费吗?

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

工作流信息
难度等级
高级
节点数量17
分类3
节点类型10
难度说明

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

作者
BizThrive.ai

BizThrive.ai

@davids

We are an automation company providing businesses with automations to improve productivity and save on costs. We also provide Ai solutions including Ai Voice Receptionists.

外部链接
在 n8n.io 查看

分享此工作流