8
n8n 中文网amn8n.com

JotForm PDF结构化发票数据提取(OpenAI GPT-4.1-mini)

高级

这是一个Invoice Processing, AI Summarization领域的自动化工作流,包含 19 个节点。主要使用 Webhook, Function, HttpRequest, GoogleSheets, ReadWriteFile 等节点。 使用OpenAI GPT-4.1-mini从JotForm PDF中提取结构化发票数据至表格

前置要求
  • HTTP Webhook 端点(n8n 会自动生成)
  • 可能需要目标 API 的认证凭证
  • Google Sheets API 凭证
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "QvIVxAgboRsZMMr0",
  "meta": {
    "instanceId": "885b4fb4a6a9c2cb5621429a7b972df0d05bb724c20ac7dac7171b62f1c7ef40",
    "templateCredsSetupCompleted": true
  },
  "name": "通过OpenAI GPT-4.1-mini从JotForm PDF中提取结构化发票数据",
  "tags": [
    {
      "id": "Kujft2FOjmOVQAmJ",
      "name": "Engineering",
      "createdAt": "2025-04-09T01:31:00.558Z",
      "updatedAt": "2025-04-09T01:31:00.558Z"
    },
    {
      "id": "ddPkw7Hg5dZhQu2w",
      "name": "AI",
      "createdAt": "2025-04-13T05:38:08.053Z",
      "updatedAt": "2025-04-13T05:38:08.053Z"
    }
  ],
  "nodes": [
    {
      "id": "bcd1e88b-4435-4862-960e-86f284884681",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -544,
        -32
      ],
      "webhookId": "b3a65dd9-8203-4aff-8005-80d98fb4c030",
      "parameters": {
        "path": "b3a65dd9-8203-4aff-8005-80d98fb4c030",
        "options": {},
        "httpMethod": "POST"
      },
      "typeVersion": 2.1
    },
    {
      "id": "84b85e47-b3aa-4c61-85ce-c17aba383b8e",
      "name": "格式化结构化数据提取",
      "type": "@n8n/n8n-nodes-langchain.informationExtractor",
      "position": [
        -352,
        -32
      ],
      "parameters": {
        "text": "= Extract Structured Information in JSON from the provided invoice raw request {{ $('Webhook').item.json.body.rawRequest }}",
        "options": {},
        "schemaType": "fromJson",
        "jsonSchemaExample": "{\n  \"formSubmission\": {\n    \"id\": \"252920932663460\",\n    \"source\": \"form\",\n    \"submittedAt\": \"2025-10-20T11:45:35.950Z\",\n    \"timeToSubmitSeconds\": 20,\n    \"eventId\": \"1760940191615_252920932663460_6BZ73Ag\"\n  },\n  \"user\": {\n    \"name\": {\n      \"first\": \"Ranjan\",\n      \"last\": \"Dailata\"\n    },\n    \"email\": \"ranjancse@gmail.com\"\n  },\n  \"invoice\": {\n    \"number\": \"INV-3337\",\n    \"date\": {\n      \"month\": \"\",\n      \"day\": \"\",\n      \"year\": \"\"\n    },\n    \"description\": \"Sample Invoice\",\n    \"attachments\": [\n      {\n        \"filename\": \"PDF-Invoice-Sample.pdf\",\n        \"url\": \"https://www.jotform.com/uploads/ranjancse/252920932663460/6367495377218625724/PDF-Invoice-Sample.pdf\",\n        \"fileServer\": \"jotformfs-e4f4ece4d0a90#019a0038-65e1-79f6-bdb5-c9281000db56\"\n      }\n    ]\n  },\n  \"system\": {\n    \"uploadServerUrl\": \"https://upload.jotform.com/upload\",\n    \"eventObserverEnabled\": true,\n    \"validatedFields\": {\n      \"new\": 1\n    },\n    \"buildDate\": \"1760940189728\",\n    \"jsExecutionTracker\": {\n      \"buildDate\": \"1760940189728\",\n      \"initStarted\": \"1760940191614\",\n      \"validatorCalled\": \"1760940191680\",\n      \"validatorMounted\": false,\n      \"initComplete\": \"1760940191684\",\n      \"intervalComplete\": \"1760940212688\",\n      \"onSubmitFired\": \"1760940335932\",\n      \"validationPassed\": \"1760940335944\",\n      \"formSubmitted\": \"1760940335950\"\n    }\n  }\n}\n"
      },
      "typeVersion": 1.2
    },
    {
      "id": "f7f77bb3-eb70-4000-aace-061d022e2882",
      "name": "下载发票",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        0,
        -32
      ],
      "parameters": {
        "url": "={{ $json.output.invoice.attachments[0].url }}",
        "options": {
          "redirect": {
            "redirect": {}
          },
          "response": {
            "response": {
              "responseFormat": "file",
              "outputPropertyName": "=PDF-Invoice-Sample.pdf"
            }
          }
        },
        "sendHeaders": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "headerParameters": {
          "parameters": [
            {}
          ]
        }
      },
      "credentials": {
        "httpBearerAuth": {
          "id": "m17YVh2yJY7Fl9Wx",
          "name": "Thordata SERP Bearer YOUR_TOKEN_HERE Account"
        },
        "httpHeaderAuth": {
          "id": "i2RtoFcQm5F2NqG2",
          "name": "Jotform Api Key"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "cc1a28b8-a287-43c3-9bb3-118a89570562",
      "name": "从文件提取",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        416,
        -32
      ],
      "parameters": {
        "options": {},
        "operation": "pdf",
        "binaryPropertyName": "={{ $('Write File from Disk for Inbound Invoice Processing').item.binary['PDF-Invoice-Sample.pdf']}}"
      },
      "typeVersion": 1
    },
    {
      "id": "e9a4d6af-2efc-4d6b-8f72-5b49f60181ca",
      "name": "结构化输出解析器",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        736,
        160
      ],
      "parameters": {
        "autoFix": true,
        "schemaType": "manual",
        "inputSchema": "{\n  \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n  \"title\": \"Invoice\",\n  \"type\": \"object\",\n  \"properties\": {\n    \"invoiceId\": {\n      \"type\": \"string\",\n      \"description\": \"Unique invoice identifier\"\n    },\n    \"invoiceNumber\": {\n      \"type\": \"string\",\n      \"description\": \"Human-readable invoice number (e.g. INV-2025-001)\"\n    },\n    \"invoiceDate\": {\n      \"type\": \"string\",\n      \"format\": \"date\",\n      \"description\": \"Invoice issue date\"\n    },\n    \"dueDate\": {\n      \"type\": \"string\",\n      \"format\": \"date\",\n      \"description\": \"Payment due date\"\n    },\n    \"company\": {\n      \"type\": \"object\",\n      \"properties\": {\n        \"name\": { \"type\": \"string\" },\n        \"address\": { \"type\": \"string\" },\n        \"email\": { \"type\": \"string\" },\n        \"phone\": { \"type\": \"string\" },\n        \"taxId\": { \"type\": \"string\" }\n      },\n      \"required\": [\"name\"]\n    },\n    \"client\": {\n      \"type\": \"object\",\n      \"properties\": {\n        \"name\": { \"type\": \"string\" },\n        \"address\": { \"type\": \"string\" },\n        \"email\": { \"type\": \"string\" },\n        \"phone\": { \"type\": \"string\" }\n      },\n      \"required\": [\"name\"]\n    },\n    \"items\": {\n      \"type\": \"array\",\n      \"description\": \"Line items billed on the invoice\",\n      \"items\": {\n        \"type\": \"object\",\n        \"properties\": {\n          \"description\": { \"type\": \"string\" },\n          \"quantity\": { \"type\": \"number\" },\n          \"unitPrice\": { \"type\": \"number\" },\n          \"total\": { \"type\": \"number\" },\n          \"taxRate\": { \"type\": \"number\" }\n        },\n        \"required\": [\"description\", \"quantity\", \"unitPrice\"]\n      }\n    },\n    \"subTotal\": {\n      \"type\": \"number\",\n      \"description\": \"Total before tax and discounts\"\n    },\n    \"taxAmount\": {\n      \"type\": \"number\",\n      \"description\": \"Total tax amount applied\"\n    },\n    \"discount\": {\n      \"type\": \"number\",\n      \"description\": \"Discount applied to invoice\"\n    },\n    \"totalAmount\": {\n      \"type\": \"number\",\n      \"description\": \"Final amount due\"\n    },\n    \"currency\": {\n      \"type\": \"string\",\n      \"description\": \"Currency code (e.g. USD, EUR, INR)\"\n    },\n    \"notes\": {\n      \"type\": \"string\",\n      \"description\": \"Optional notes or terms\"\n    },\n    \"payment\": {\n      \"type\": \"object\",\n      \"properties\": {\n        \"method\": { \"type\": \"string\", \"description\": \"Payment method (Bank, Card, etc.)\" },\n        \"status\": { \"type\": \"string\", \"description\": \"paid, pending, overdue\" },\n        \"transactionId\": { \"type\": \"string\" },\n        \"paymentDate\": { \"type\": \"string\", \"format\": \"date\" }\n      }\n    },\n    \"attachments\": {\n      \"type\": \"array\",\n      \"description\": \"Links to attached invoice PDFs or receipts\",\n      \"items\": {\n        \"type\": \"string\",\n        \"format\": \"uri\"\n      }\n    }\n  }\n}\n"
      },
      "typeVersion": 1.3
    },
    {
      "id": "c60bd005-d03e-4053-93a1-7137c90b8e80",
      "name": "结构化数据提取",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        640,
        -32
      ],
      "parameters": {
        "text": "=Parse the below invoice info into a structured data\n\n{{ $json.text }}",
        "batching": {},
        "promptType": "define",
        "hasOutputParser": true
      },
      "retryOnFail": true,
      "typeVersion": 1.7,
      "alwaysOutputData": false
    },
    {
      "id": "2d0f93f5-6372-4c2c-97a0-61275648fc58",
      "name": "用于结构化数据的OpenAI聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        576,
        176
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "vPKynKbDzJ5ZU4cU",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "48d81c63-ed97-4229-a63d-ad1a2a8959ae",
      "name": "用于输出解析器的OpenAI聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        672,
        368
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "vPKynKbDzJ5ZU4cU",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "a54f0c84-82ca-439e-8cd8-86dabe04f69b",
      "name": "用于结构化数据格式化内容的OpenAI聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -352,
        176
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini",
          "cachedResultName": "gpt-4.1-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "vPKynKbDzJ5ZU4cU",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "a21275f7-fc1b-47ab-ba6a-06bcde58875e",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -608,
        -432
      ],
      "parameters": {
        "color": 7,
        "width": 352,
        "height": 272,
        "content": "![Logo](https://www.jotform.com/resources/assets/logo-nb/min/jotform-logo-white-400x200.png)"
      },
      "typeVersion": 1
    },
    {
      "id": "569de30c-835b-4ed3-aa7c-21052f4c06c9",
      "name": "从磁盘写入文件用于入站发票处理",
      "type": "n8n-nodes-base.readWriteFile",
      "position": [
        208,
        -32
      ],
      "parameters": {
        "options": {},
        "fileName": "=c:\\\\PDF-Invoice-Sample.pdf",
        "operation": "write",
        "dataPropertyName": "={{ $json.output.invoice.attachments[0].filename }}"
      },
      "typeVersion": 1
    },
    {
      "id": "9f3662ac-82cf-48fd-b04e-979d8d4d9310",
      "name": "在表格中追加或更新行",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1120,
        144
      ],
      "parameters": {
        "columns": {
          "value": {},
          "schema": [
            {
              "id": "output",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "output",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "autoMapInputData",
          "matchingColumns": [
            "output"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1WaQUR9Q32uKLbbu77CrvWhM2I_3NXEsxT0RDMGq-Dm0/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1WaQUR9Q32uKLbbu77CrvWhM2I_3NXEsxT0RDMGq-Dm0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1WaQUR9Q32uKLbbu77CrvWhM2I_3NXEsxT0RDMGq-Dm0/edit?usp=drivesdk",
          "cachedResultName": "Jotform Invoice Extraction"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "Zjoxh2BUZ6VXGQhA",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "707dd08c-6896-4888-9b16-699557d09320",
      "name": "将结构化发票写入磁盘",
      "type": "n8n-nodes-base.readWriteFile",
      "position": [
        1296,
        -192
      ],
      "parameters": {
        "options": {},
        "fileName": "=C:\\\\{{ $json.output.invoiceId }}-{{ $json.output.invoiceDate }}.json",
        "operation": "write"
      },
      "typeVersion": 1
    },
    {
      "id": "12cb7d07-9233-4081-92d9-11ebbe70270d",
      "name": "创建二进制响应",
      "type": "n8n-nodes-base.function",
      "position": [
        1120,
        -192
      ],
      "parameters": {
        "functionCode": "\n\nitems[0].binary = {\n  data: {\n    data: new Buffer(JSON.stringify(items[0].json, null, 2)).toString('base64')\n  }\n};\nreturn items;"
      },
      "typeVersion": 1
    },
    {
      "id": "077170e7-ca49-49be-a8d9-892b999a6724",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -608,
        384
      ],
      "parameters": {
        "color": 7,
        "width": 512,
        "height": 512,
        "content": "### **目的:**"
      },
      "typeVersion": 1
    },
    {
      "id": "575ee55d-ff5f-4ec1-a9a5-e9f711f2b05c",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        368,
        -160
      ],
      "parameters": {
        "color": 5,
        "width": 656,
        "height": 672,
        "content": "## 使用OpenAI进行结构化数据提取"
      },
      "typeVersion": 1
    },
    {
      "id": "47621c4a-20cc-455c-b901-d12b93447bb8",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1040,
        -288
      ],
      "parameters": {
        "color": 3,
        "width": 400,
        "height": 800,
        "content": "## 导出数据处理"
      },
      "typeVersion": 1
    },
    {
      "id": "73c0cc88-4604-4f19-83a2-10ce1bb9ea40",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -608,
        -128
      ],
      "parameters": {
        "color": 4,
        "width": 512,
        "height": 464,
        "content": "## Webhook接收器与数据格式化"
      },
      "typeVersion": 1
    },
    {
      "id": "1f92db74-0623-4785-a62b-18ff14405463",
      "name": "便利贴5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -80,
        -128
      ],
      "parameters": {
        "width": 432,
        "height": 464,
        "content": "## 发票下载与写入磁盘"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "2b629465-8dc5-4eba-ad21-65f5e50f6280",
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Formatted Structured Data Extract",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Invoice": {
      "main": [
        [
          {
            "node": "Write File from Disk for Inbound Invoice Processing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from File": {
      "main": [
        [
          {
            "node": "Structured Data Extract",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Data Extract": {
      "main": [
        [
          {
            "node": "Append or update row in sheet",
            "type": "main",
            "index": 0
          },
          {
            "node": "Create a Binary Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create a Binary Response": {
      "main": [
        [
          {
            "node": "Write the Structured Invoice to Disk",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Structured Data Extract",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Formatted Structured Data Extract": {
      "main": [
        [
          {
            "node": "Download Invoice",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model for Output Parser": {
      "ai_languageModel": [
        [
          {
            "node": "Structured Output Parser",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model for Structured Data": {
      "ai_languageModel": [
        [
          {
            "node": "Structured Data Extract",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Write File from Disk for Inbound Invoice Processing": {
      "main": [
        [
          {
            "node": "Extract from File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model for Structured Data Formatted Content": {
      "ai_languageModel": [
        [
          {
            "node": "Formatted Structured Data Extract",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 发票处理, AI 摘要总结

需要付费吗?

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

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

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

作者
Ranjan Dailata

Ranjan Dailata

@ranjancse

A Professional based out of India specialized in handling AI-powered automations. Contact me at ranjancse@gmail.com

外部链接
在 n8n.io 查看

分享此工作流