8
n8n 中文网amn8n.com

使用OCR、Gemini AI和Airtable从发票提取数据

高级

这是一个AI Summarization, Multimodal AI领域的自动化工作流,包含 18 个节点。主要使用 If, Switch, Telegram, Aggregate, AirtableTool 等节点。 使用OCR、Gemini AI和Airtable从发票提取数据

前置要求
  • Telegram Bot Token
  • Airtable API Key
  • Google Gemini API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "558d88703fb65b2d0e44613bc35916258b0f0bf983c5d4730c00c424b77ca36a",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "b7d49dfb-9e34-4ef3-8533-938a5dc1bbcb",
      "name": "本地文件触发器",
      "type": "n8n-nodes-base.localFileTrigger",
      "position": [
        -2928,
        368
      ],
      "parameters": {
        "path": "/image-output/ocr",
        "events": [
          "add"
        ],
        "options": {
          "usePolling": true,
          "awaitWriteFinish": true
        },
        "triggerOn": "folder"
      },
      "typeVersion": 1
    },
    {
      "id": "dda2ddaa-ff24-4694-95c8-5e3d5cfaa88d",
      "name": "Google Gemini 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        -1488,
        592
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-2.5-flash-preview-05-20"
      },
      "credentials": {
        "googlePalmApi": {
          "id": "DgSd8qj0VSc8QXnp",
          "name": "Google Gemini(PaLM) Api account (vinrocks.1789)"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "9c13f6b8-626a-4eb0-80ff-90b093d1948d",
      "name": "Tesseract",
      "type": "n8n-nodes-tesseractjs.tesseractNode",
      "position": [
        -2224,
        464
      ],
      "parameters": {
        "options": {
          "psm": "SINGLE_COLUMN",
          "language": "eng"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "a364c562-5092-4c88-8a80-2271997dee0d",
      "name": "切换",
      "type": "n8n-nodes-base.switch",
      "position": [
        -1984,
        368
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Jpg",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "6e77c197-5184-4293-9038-e4231c481df9",
                    "operator": {
                      "type": "string",
                      "operation": "contains"
                    },
                    "leftValue": "={{ $('Check File Type').item.json.fileExtension }}",
                    "rightValue": "jpg"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Pdf",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "d500e707-0f7e-4a4f-86a6-9090888dbf7e",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('Check File Type').item.json.fileExtension }}",
                    "rightValue": "pdf"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Png",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "5411d519-2475-43fd-ae62-8d9f795716c8",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('Check File Type').item.json.fileExtension }}",
                    "rightValue": "png"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {
          "allMatchingOutputs": false
        }
      },
      "typeVersion": 3.2
    },
    {
      "id": "13144779-2c29-47bd-bf46-5d58b272564c",
      "name": "聚合",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        -1728,
        368
      ],
      "parameters": {
        "include": "allFieldsExcept",
        "options": {},
        "aggregate": "aggregateAllItemData",
        "fieldsToExclude": "confidence, filename, totalPages, pages, metadata, info"
      },
      "typeVersion": 1
    },
    {
      "id": "f264557e-3691-4c64-97a9-5ca11cf58789",
      "name": "PDF 页面提取",
      "type": "n8n-nodes-pdf-page-extract.pdfPageExtract",
      "position": [
        -2224,
        224
      ],
      "parameters": {
        "includeRawText": true
      },
      "typeVersion": 1
    },
    {
      "id": "4ce9888a-1534-41eb-9636-87b861e7ea79",
      "name": "Telegram",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -1120,
        368
      ],
      "webhookId": "bb7bb12e-438f-4cd1-82bd-a7ffcc08b33e",
      "parameters": {
        "text": "={{ $json.output }}",
        "chatId": "8182583xxx",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "o62WcUBZY5nNl0wr",
          "name": "Telegram account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "cab3796a-87ed-4a33-9eb6-f73f5da840cc",
      "name": "读取文件",
      "type": "n8n-nodes-base.readWriteFile",
      "position": [
        -2656,
        368
      ],
      "parameters": {
        "options": {
          "dataPropertyName": "data"
        },
        "fileSelector": "={{ $json.path }}"
      },
      "typeVersion": 1
    },
    {
      "id": "3bd4eb3b-c0d6-48bc-ac75-a10eaf258f39",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3008,
        240
      ],
      "parameters": {
        "color": 7,
        "width": 260,
        "height": 100,
        "content": "### 请确保触发器中的文件夹路径指向您在 n8n 中挂载的文件夹"
      },
      "typeVersion": 1
    },
    {
      "id": "40d2b4ef-4cea-4cdd-aec2-92293c50c11f",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3008,
        -80
      ],
      "parameters": {
        "width": 800,
        "height": 180,
        "content": "## 功能特性"
      },
      "typeVersion": 1
    },
    {
      "id": "55ef424c-137c-4dee-82f8-0cec6ec9b6dc",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2288,
        128
      ],
      "parameters": {
        "color": 7,
        "width": 220,
        "height": 80,
        "content": "### 社区节点:"
      },
      "typeVersion": 1
    },
    {
      "id": "b3b4dc66-549e-4a07-a59f-75dad99ff605",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1184,
        240
      ],
      "parameters": {
        "color": 7,
        "height": 100,
        "content": "### 请确保更新您的 Chat ID,以便机器人可以向您的私信发送消息"
      },
      "typeVersion": 1
    },
    {
      "id": "c93ffea4-940a-4249-9f82-fc3e4971f18f",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1232,
        624
      ],
      "parameters": {
        "color": 3,
        "width": 360,
        "height": 80,
        "content": "### 如果您不想使用 Airtable,可以使用 Google Sheets 作为替代方案"
      },
      "typeVersion": 1
    },
    {
      "id": "1471c100-5ab0-4eb7-bd0b-2c4063f71715",
      "name": "便签5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2288,
        624
      ],
      "parameters": {
        "color": 3,
        "width": 200,
        "height": 80,
        "content": "### 社区节点:"
      },
      "typeVersion": 1
    },
    {
      "id": "8b019576-37ff-4c16-b679-fb00d132243f",
      "name": "便签6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3008,
        768
      ],
      "parameters": {
        "width": 740,
        "height": 80,
        "content": "## 如果您在设置工作流时需要任何帮助,请随时通过 @ vinaysingh.b@outlook.in 联系我"
      },
      "typeVersion": 1
    },
    {
      "id": "28d2c502-3104-4d18-ab1c-2fd14495a3cf",
      "name": "提取发票数据 (Gemini)",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -1488,
        368
      ],
      "parameters": {
        "text": "={{ $json.data }}",
        "options": {
          "systemMessage": "=<TASK>\nProcess received \"{{ $json.data[0].text }}\" and update individual fields in the Airtable tool, like for example\n\nInvoice Number,\nInvoice date if available (if available), Always convert the date into format : '2025-06-21',\nInvoice SubTotal amount (if available),\nInvoice tax (if available),\nInvoice Total,\nCurrency,\nVendor Name,\nEmail address of the vendor,\nPhone number(ignore if FAX number is available),\nShip to address\n</TASK>\n\n<Telegram_Response>\nPlease reply in the below format:\n\nInvoice details has been updated successfully.\nInvoice: <>\nInvoice date: <>\nInvoice SubTotal: <>\nInvoice tax: <>\nInvoice Total: <>\nCurrency: <>\nVendor: <>\nEmail address: <>\nPhone number: <>\nShip to address: <>\n</Telegram_Response>"
        },
        "promptType": "define"
      },
      "typeVersion": 2
    },
    {
      "id": "d702cf55-1761-4b31-9e8e-e8ceb1da9171",
      "name": "检查文件类型",
      "type": "n8n-nodes-base.if",
      "position": [
        -2480,
        368
      ],
      "parameters": {
        "options": {
          "ignoreCase": true
        },
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": false,
            "typeValidation": "strict"
          },
          "combinator": "or",
          "conditions": [
            {
              "id": "7fbe81a0-6a37-4e9b-af8a-b692a8151507",
              "operator": {
                "type": "string",
                "operation": "contains"
              },
              "leftValue": "={{ $json.fileType }}",
              "rightValue": "pdf"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "880b0f62-07e1-495e-b36a-948c5eb70c27",
      "name": "保存到 Airtable",
      "type": "n8n-nodes-base.airtableTool",
      "position": [
        -1344,
        592
      ],
      "parameters": {
        "base": {
          "__rl": true,
          "mode": "list",
          "value": "appAl4CX1mypNyRJv",
          "cachedResultUrl": "https://airtable.com/appAl4CX1mypNyRJv",
          "cachedResultName": "Personal Project Tracker"
        },
        "table": {
          "__rl": true,
          "mode": "list",
          "value": "tblBr2vL7frtavGn8",
          "cachedResultUrl": "https://airtable.com/appAl4CX1mypNyRJv/tblBr2vL7frtavGn8",
          "cachedResultName": "OCR"
        },
        "columns": {
          "value": {
            "Currency": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Currency', ``, 'string') }}",
            "Invoice tax": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Invoice_tax', ``, 'number') }}",
            "Vendor name": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Vendor_name', ``, 'string') }}",
            "Invoice date": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Invoice_date', ``, 'string') }}",
            "Phone number": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Phone_number', ``, 'string') }}",
            "Email address": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Email_address', ``, 'string') }}",
            "Invoice Total": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Invoice_Total', ``, 'number') }}",
            "Invoice Number": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Invoice_Number', ``, 'string') }}",
            "Ship to address": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Ship_to_address', ``, 'string') }}",
            "Invoice SubTotal": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Invoice_SubTotal', ``, 'number') }}"
          },
          "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": "Invoice SubTotal",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Invoice SubTotal",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Invoice tax",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Invoice tax",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Invoice Total",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Invoice Total",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Currency",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Currency",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Vendor name",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Vendor name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Email address",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Email address",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Phone number",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Phone number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Ship to address",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Ship to address",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "create"
      },
      "credentials": {
        "airtableTokenApi": {
          "id": "9jCNxhVQFJQuxhGU",
          "name": "Airtable Personal Access Token account"
        }
      },
      "typeVersion": 2.1
    }
  ],
  "pinData": {},
  "connections": {
    "a364c562-5092-4c88-8a80-2271997dee0d": {
      "main": [
        [
          {
            "node": "13144779-2c29-47bd-bf46-5d58b272564c",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "13144779-2c29-47bd-bf46-5d58b272564c",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "13144779-2c29-47bd-bf46-5d58b272564c",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "13144779-2c29-47bd-bf46-5d58b272564c": {
      "main": [
        [
          {
            "node": "28d2c502-3104-4d18-ab1c-2fd14495a3cf",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "cab3796a-87ed-4a33-9eb6-f73f5da840cc": {
      "main": [
        [
          {
            "node": "d702cf55-1761-4b31-9e8e-e8ceb1da9171",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "9c13f6b8-626a-4eb0-80ff-90b093d1948d": {
      "main": [
        [
          {
            "node": "a364c562-5092-4c88-8a80-2271997dee0d",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "d702cf55-1761-4b31-9e8e-e8ceb1da9171": {
      "main": [
        [
          {
            "node": "f264557e-3691-4c64-97a9-5ca11cf58789",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "9c13f6b8-626a-4eb0-80ff-90b093d1948d",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "f264557e-3691-4c64-97a9-5ca11cf58789": {
      "main": [
        [
          {
            "node": "a364c562-5092-4c88-8a80-2271997dee0d",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "880b0f62-07e1-495e-b36a-948c5eb70c27": {
      "ai_tool": [
        [
          {
            "node": "28d2c502-3104-4d18-ab1c-2fd14495a3cf",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "b7d49dfb-9e34-4ef3-8533-938a5dc1bbcb": {
      "main": [
        [
          {
            "node": "cab3796a-87ed-4a33-9eb6-f73f5da840cc",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "dda2ddaa-ff24-4694-95c8-5e3d5cfaa88d": {
      "ai_languageModel": [
        [
          {
            "node": "28d2c502-3104-4d18-ab1c-2fd14495a3cf",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "28d2c502-3104-4d18-ab1c-2fd14495a3cf": {
      "main": [
        [
          {
            "node": "4ce9888a-1534-41eb-9636-87b861e7ea79",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

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

需要付费吗?

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

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

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

外部链接
在 n8n.io 查看

分享此工作流

分类

分类: 34