智能文档解析器(用于发票、日志或传感器报告)(PDF/图像/csv到表格)
中级
这是一个Invoice Processing, Multimodal AI领域的自动化工作流,包含 12 个节点。主要使用 Code, Switch, Webhook, GoogleSheets, ExtractFromFile 等节点。 使用Gemini AI、OCR和Google Sheets集成解析发票和文档
前置要求
- •HTTP Webhook 端点(n8n 会自动生成)
- •Google Sheets API 凭证
- •Google Gemini API Key
使用的节点 (12)
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "c92ZApSKwsRmg6zb",
"meta": {
"instanceId": "14e4c77104722ab186539dfea5182e419aecc83d85963fe13f6de862c875ebfa",
"templateCredsSetupCompleted": true
},
"name": "智能文档解析器(用于发票、日志或传感器报告)(PDF/图像/csv到表格)",
"tags": [],
"nodes": [
{
"id": "98517a08-3fc4-4c0c-aa4b-44d93c864eb4",
"name": "检查文件类型",
"type": "n8n-nodes-base.switch",
"position": [
220,
860
],
"parameters": {
"rules": {
"values": [
{
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "40ee8e68-2b72-4ba9-b7a2-8c976852d48b",
"operator": {
"type": "string",
"operation": "contains"
},
"leftValue": "={{ $('Webhook Invoice upload').item.binary.file.mimeType }}",
"rightValue": "image"
}
]
}
},
{
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "c4315e16-313f-4363-a625-71436498e46a",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $('Webhook Invoice upload').item.binary.file.mimeType }}",
"rightValue": "application/pdf"
}
]
}
},
{
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "cffb0678-f006-47e0-91ea-afd17f133a77",
"operator": {
"type": "string",
"operation": "contains"
},
"leftValue": "={{ $('Webhook Invoice upload').item.binary.file.mimeType }}",
"rightValue": "csv"
}
]
}
}
]
},
"options": {}
},
"typeVersion": 3.2
},
{
"id": "6ef5d99c-b842-4290-9766-8b780df66f6b",
"name": "发票数据",
"type": "n8n-nodes-base.googleSheets",
"position": [
738,
1110
],
"parameters": {
"columns": {
"value": {
"total": "={{ $json.total }}",
"currency": "={{ $json.currency }}",
"due_date": "={{ $json.due_date }}",
"subtotal": "={{ $json.subtotal }}",
"tax_total": "={{ $json.tax_total }}",
"invoice_id": "={{ $json.invoice_id }}",
"vendor_name": "={{ $json.vendor_name }}",
"invoice_date": "={{ $json.invoice_date }}",
"customer_name": "={{ $json.customer_name }}"
},
"schema": [
{
"id": "invoice_id",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "invoice_id",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "invoice_date",
"type": "string",
"display": true,
"required": false,
"displayName": "invoice_date",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "due_date",
"type": "string",
"display": true,
"required": false,
"displayName": "due_date",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "customer_name",
"type": "string",
"display": true,
"required": false,
"displayName": "customer_name",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "vendor_name",
"type": "string",
"display": true,
"required": false,
"displayName": "vendor_name",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "subtotal",
"type": "string",
"display": true,
"required": false,
"displayName": "subtotal",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "tax_total",
"type": "string",
"display": true,
"required": false,
"displayName": "tax_total",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "total",
"type": "string",
"display": true,
"required": false,
"displayName": "total",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "currency",
"type": "string",
"display": true,
"required": false,
"displayName": "currency",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "customer_address",
"type": "string",
"display": true,
"removed": true,
"required": false,
"displayName": "customer_address",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "customer_tax_id",
"type": "string",
"display": true,
"removed": true,
"required": false,
"displayName": "customer_tax_id",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "vendor_address",
"type": "string",
"display": true,
"removed": true,
"required": false,
"displayName": "vendor_address",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "vendor_tax_id",
"type": "string",
"display": true,
"removed": true,
"required": false,
"displayName": "vendor_tax_id",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "vendor_iban",
"type": "string",
"display": true,
"removed": true,
"required": false,
"displayName": "vendor_iban",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "vendor_bic",
"type": "string",
"display": true,
"removed": true,
"required": false,
"displayName": "vendor_bic",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "line_id",
"type": "string",
"display": true,
"removed": true,
"required": false,
"displayName": "line_id",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "description",
"type": "string",
"display": true,
"removed": true,
"required": false,
"displayName": "description",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "quantity",
"type": "string",
"display": true,
"removed": true,
"required": false,
"displayName": "quantity",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "unit_price",
"type": "string",
"display": true,
"removed": true,
"required": false,
"displayName": "unit_price",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "line_total",
"type": "string",
"display": true,
"removed": true,
"required": false,
"displayName": "line_total",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "tax_rate",
"type": "string",
"display": true,
"removed": true,
"required": false,
"displayName": "tax_rate",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [
"invoice_id"
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {},
"operation": "appendOrUpdate",
"sheetName": {
"__rl": true,
"mode": "list",
"value": 0,
"cachedResultUrl": "",
"cachedResultName": "Invoice"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "0",
"cachedResultUrl": "",
"cachedResultName": ""
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "",
"name": ""
}
},
"typeVersion": 4.6
},
{
"id": "6b0ce6fd-5d09-4bc2-a3b2-cc8c0e2878d6",
"name": "发票数据",
"type": "n8n-nodes-base.googleSheets",
"position": [
1256,
760
],
"parameters": {
"columns": {
"value": {
"total": "={{ $json.total }}",
"currency": "={{ $json.currency }}",
"due_date": "={{ $json.due_date }}",
"subtotal": "={{ $json.subtotal }}",
"tax_total": "={{ $json.tax_total }}",
"invoice_id": "={{ $json.invoice_id }}",
"vendor_name": "={{ $json.vendor_name }}",
"invoice_date": "={{ $json.invoice_date }}",
"customer_name": "={{ $json.customer_name }}"
},
"schema": [
{
"id": "invoice_id",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "invoice_id",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "invoice_date",
"type": "string",
"display": true,
"required": false,
"displayName": "invoice_date",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "due_date",
"type": "string",
"display": true,
"required": false,
"displayName": "due_date",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "customer_name",
"type": "string",
"display": true,
"required": false,
"displayName": "customer_name",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "vendor_name",
"type": "string",
"display": true,
"required": false,
"displayName": "vendor_name",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "subtotal",
"type": "string",
"display": true,
"required": false,
"displayName": "subtotal",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "tax_total",
"type": "string",
"display": true,
"required": false,
"displayName": "tax_total",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "total",
"type": "string",
"display": true,
"required": false,
"displayName": "total",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "currency",
"type": "string",
"display": true,
"required": false,
"displayName": "currency",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Accounting",
"type": "string",
"display": true,
"removed": true,
"required": false,
"displayName": "Accounting",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [
"invoice_id"
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {},
"operation": "appendOrUpdate",
"sheetName": {
"__rl": true,
"mode": "list",
"value": 0,
"cachedResultUrl": "",
"cachedResultName": "Invoice"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "0",
"cachedResultUrl": "",
"cachedResultName": ""
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "",
"name": ""
}
},
"typeVersion": 4.6
},
{
"id": "7f5b8ffe-d4e8-4b7b-803e-6c37d0da0221",
"name": "转换数据",
"type": "n8n-nodes-base.code",
"position": [
1036,
760
],
"parameters": {
"jsCode": "const raw = $input.first().json.text || '';\n\n// 1. Remove code block syntax like ```json ... ```\nconst cleaned = raw.replace(/```json|```/g, '').trim();\n\n\n const parsed = JSON.parse(cleaned);\n return [{ json: parsed }];"
},
"typeVersion": 2,
"alwaysOutputData": true
},
{
"id": "b818ac61-4837-4a9f-b90e-bb6b4b7739c1",
"name": "Google Gemini 聊天模型",
"type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
"position": [
748,
880
],
"parameters": {
"options": {},
"modelName": "models/gemini-1.5-flash"
},
"credentials": {
"googlePalmApi": {
"id": "",
"name": ""
}
},
"typeVersion": 1
},
{
"id": "2941bf32-0db6-4486-8696-e207de09364c",
"name": "从文本格式化数据",
"type": "@n8n/n8n-nodes-langchain.chainLlm",
"position": [
660,
660
],
"parameters": {
"text": "=Extract the following invoice details from the given raw text:\n\n- invoice_id \n- invoice_date \n- due_date \n- customer_name \n- vendor_name \n- subtotal \n- tax_total \n- total \n- currency\n\nUse the following input text:\n{{ $json.text }}\n\nReturn the result as a valid JSON object using this exact structure:\n\n{\n \"invoice_id\": \"string or null\",\n \"invoice_date\": \"string (e.g., 2024-10-10) or null\",\n \"due_date\": \"string (e.g., 2024-10-25) or null\",\n \"customer_name\": \"string or null\",\n \"vendor_name\": \"string or null\",\n \"subtotal\": \"string or null\",\n \"tax_total\": \"string or null\",\n \"total\": \"string or null\",\n \"currency\": \"string (e.g., €, $, £) or null\"\n}\n\nIf any field is missing or not found, set it as `null`. Return only the JSON output without extra text.\n",
"batching": {},
"promptType": "define"
},
"typeVersion": 1.7
},
{
"id": "7c829587-f028-4332-831f-92f9529b72ca",
"name": "Webhook发票上传",
"type": "n8n-nodes-base.webhook",
"position": [
0,
860
],
"webhookId": "3dafecda-82df-4af9-84f2-7815ffa81319",
"parameters": {
"path": "uploadDoc",
"options": {},
"httpMethod": "POST"
},
"typeVersion": 2
},
{
"id": "05176b33-fcda-4f1a-84fa-2449108a0a54",
"name": "PDF转文本",
"type": "n8n-nodes-base.extractFromFile",
"position": [
440,
860
],
"parameters": {
"options": {},
"operation": "pdf",
"binaryPropertyName": "file"
},
"typeVersion": 1
},
{
"id": "81690344-d04c-428b-b720-bb539fbe2bbe",
"name": "图像转文本",
"type": "n8n-nodes-tesseractjs.tesseractNode",
"position": [
440,
660
],
"parameters": {
"options": {},
"inputDataFieldName": "file"
},
"typeVersion": 1
},
{
"id": "a0f49ed7-1d42-4df8-a802-74754d1549c0",
"name": "CSV转JSON",
"type": "n8n-nodes-base.extractFromFile",
"position": [
440,
1110
],
"parameters": {
"options": {},
"binaryPropertyName": "file"
},
"typeVersion": 1
},
{
"id": "0473ba6b-734e-4f53-8ecb-86711db1bd76",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-60,
1300
],
"parameters": {
"color": 2,
"width": 1500,
"height": 540,
"content": "---"
},
"typeVersion": 1
},
{
"id": "63a9e69e-566c-4db6-9d31-b25f438fbd26",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-72,
550
],
"parameters": {
"color": 7,
"width": 1500,
"height": 720,
"content": "## 智能文档解析器(用于发票、日志或传感器报告)(PDF/图像/csv到表格)"
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "b5ae5035-b75f-4f8d-8d43-020fdb2c529e",
"connections": {
"CSV to JSON": {
"main": [
[
{
"node": "Invoice data",
"type": "main",
"index": 0
}
]
]
},
"PDF to Text": {
"main": [
[
{
"node": "Format data from text",
"type": "main",
"index": 0
}
]
]
},
"Image to Text": {
"main": [
[
{
"node": "Format data from text",
"type": "main",
"index": 0
}
]
]
},
"Transfrom data": {
"main": [
[
{
"node": "Invoice Data",
"type": "main",
"index": 0
}
]
]
},
"Check file type": {
"main": [
[
{
"node": "Image to Text",
"type": "main",
"index": 0
}
],
[
{
"node": "PDF to Text",
"type": "main",
"index": 0
}
],
[
{
"node": "CSV to JSON",
"type": "main",
"index": 0
}
]
]
},
"Format data from text": {
"main": [
[
{
"node": "Transfrom data",
"type": "main",
"index": 0
}
]
]
},
"Webhook Invoice upload": {
"main": [
[
{
"node": "Check file type",
"type": "main",
"index": 0
}
]
]
},
"Google Gemini Chat Model": {
"ai_languageModel": [
[
{
"node": "Format data from text",
"type": "ai_languageModel",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
中级 - 发票处理, 多模态 AI
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
客户反馈循环分析器
使用AI、Google表格和Slack提醒自动分类客户反馈
Code
Gmail
Slack
+7
11 节点WeblineIndia
杂项
YouTube 转录、摘要与翻译到 Google 文档
使用 Gemini AI 将 YouTube 转录和翻译至 Google 文档
Code
Webhook
Google Docs
+4
10 节点WeblineIndia
内容创作
每日申请人摘要
使用Gemini AI提取的按职位分类每日申请人摘要,供招聘经理使用
Code
Gmail
Schedule Trigger
+3
10 节点WeblineIndia
AI 摘要总结
构建用于Slack候选人评估的AI驱动聊天机器人
AI简历分析与候选人评估:Slack和Google表格集成
If
Code
Slack
+12
29 节点Trung Tran
AI 聊天机器人
基于AI的潜在客户资格评定与个性化触达(使用Relevance AI)
基于AI的潜在客户资格评定与个性化触达:使用Relevance AI
Set
Code
Gmail
+11
34 节点Diptamoy Barman
内容创作
PDF文档助手2.0
使用GPT和o4-mini分析法律文档,集成Gmail和Google Sheets
Code
Gmail
Webhook
+7
18 节点Swot.AI
AI 摘要总结
工作流信息
难度等级
中级
节点数量12
分类2
节点类型9
作者
WeblineIndia
@weblineindiaA Leading Software Engineering, Consulting & Outsourcing Services Company in USA & India serving Clients Globally since 1999.
外部链接
在 n8n.io 查看 →
分享此工作流