Nanonets文档处理
中级
这是一个Invoice Processing, AI Summarization领域的自动化工作流,包含 9 个节点。主要使用 Code, Wait, Webhook, HttpRequest, ConvertToFile 等节点。 使用Nanonets OCR解析发票数据并导出至Excel
前置要求
- •HTTP Webhook 端点(n8n 会自动生成)
- •可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "PubBpd4HHWaOtHJV",
"meta": {
"instanceId": "2d34387799014884b6bb4a0dc8b683ee92ad2bcf5aadb21177a0062d65f47540",
"templateCredsSetupCompleted": true
},
"name": "Nanonets文档处理",
"tags": [],
"nodes": [
{
"id": "ce555c80-3e22-4cda-90fd-8a741dc77f52",
"name": "HTTP 请求",
"type": "n8n-nodes-base.httpRequest",
"position": [
-960,
0
],
"parameters": {
"url": "=https://app.nanonets.com/api/v4/workflows/28f99e34-2bfb-4d50-8ac3-17eaa5ee2ecf/documents/",
"method": "POST",
"options": {},
"sendBody": true,
"contentType": "multipart-form-data",
"authentication": "genericCredentialType",
"bodyParameters": {
"parameters": [
{
"name": "=file",
"parameterType": "formBinaryData",
"inputDataFieldName": "=data"
},
{
"name": "async",
"value": "false"
}
]
},
"genericAuthType": "httpBasicAuth"
},
"typeVersion": 4.2
},
{
"id": "72b6d303-d070-4a26-a218-37e2fdf22d3d",
"name": "HTTP 请求 2",
"type": "n8n-nodes-base.httpRequest",
"position": [
-280,
0
],
"parameters": {
"url": "=https://app.nanonets.com/api/v4/workflows/28f99e34-2bfb-4d50-8ac3-17eaa5ee2ecf/documents/{{ $json.documentId }}",
"options": {},
"authentication": "genericCredentialType",
"genericAuthType": "httpBasicAuth"
},
"typeVersion": 4.2
},
{
"id": "b24e5adb-e583-40db-95fa-112250b240e3",
"name": "转换为文件",
"type": "n8n-nodes-base.convertToFile",
"position": [
140,
0
],
"parameters": {
"options": {},
"operation": "xls"
},
"typeVersion": 1.1
},
{
"id": "9b4575f9-5f13-4d3a-befd-827844f52799",
"name": "代码",
"type": "n8n-nodes-base.code",
"position": [
-740,
0
],
"parameters": {
"jsCode": "// Get the string data from the previous node\nconst inputDataString = $('HTTP Request').item.json.data;\n\n// Parse the string into a real JSON object\nconst parsedData = JSON.parse(inputDataString);\n\n// Get the document_id from the parsed data\nconst docId = parsedData.document_id;\n\n// Create a new, clean object to pass to the next node\nconst newOutput = {\n json: {\n documentId: docId\n }\n};\n\n// Return the new object\nreturn newOutput;"
},
"typeVersion": 2
},
{
"id": "0a82a366-71ed-4fa7-8e07-2c7573bee169",
"name": "代码1",
"type": "n8n-nodes-base.code",
"position": [
-60,
0
],
"parameters": {
"jsCode": "// Get the string data from the previous node\nconst inputDataString = $('HTTP Request2').item.json.data;\n\n// Parse the string into a real JSON object\nconst parsedData = JSON.parse(inputDataString);\n\n// 1. Create a base object with all the main header fields\nconst headerData = {\n document_id: parsedData.document_id,\n original_document_name: parsedData.original_document_name,\n status: parsedData.status\n};\n\nconst fields = parsedData.pages[0]?.data?.fields;\nif (fields) {\n for (const key in fields) {\n if (Array.isArray(fields[key]) && fields[key].length > 0 && typeof fields[key][0].value !== 'undefined') {\n headerData[key] = fields[key][0].value;\n }\n }\n}\n\n// 2. Process the line items from the first table\nconst finalOutputItems = [];\nconst firstTable = parsedData.pages[0]?.data?.tables[0];\n\n// Check if the table and its cells exist\nif (firstTable && firstTable.cells && Array.isArray(firstTable.cells)) {\n const rows = {};\n \n // Group all cells by their row number\n firstTable.cells.forEach(cell => {\n // If we haven't seen this row number before, create a new object for it\n if (!rows[cell.row]) {\n rows[cell.row] = {};\n }\n // Use the table header (e.g., 'Description', 'Quantity') as the key\n const headerKey = \"line_item_\" + cell.header.replace(/ /g, '_').toLowerCase();\n rows[cell.row][headerKey] = cell.text;\n });\n\n // Now, create a final output for each reconstructed row\n for (const rowNum in rows) {\n const lineItemData = rows[rowNum];\n // Combine the main header data with this line's data\n const fullItem = { ...headerData, ...lineItemData };\n finalOutputItems.push({ json: fullItem });\n }\n}\n\n// 3. Return the results\nif (finalOutputItems.length === 0) {\n // If no line items were found, return just the header data\n return [{ json: headerData }];\n}\n\n// Return one item for each line item row that was found\nreturn finalOutputItems;"
},
"typeVersion": 2
},
{
"id": "757c2b59-f47c-4f8d-aa34-134273b45023",
"name": "等待",
"type": "n8n-nodes-base.wait",
"position": [
-500,
0
],
"webhookId": "3d97f48d-a66b-4ede-bc8e-ff6e5bb9053b",
"parameters": {
"amount": 15
},
"typeVersion": 1.1
},
{
"id": "835a183d-826d-497d-ad04-7b57ba9472b2",
"name": "Webhook",
"type": "n8n-nodes-base.webhook",
"position": [
-1240,
0
],
"webhookId": "1a03d800-3e91-4284-9323-0609c0974f18",
"parameters": {
"path": "1a03d800-3e91-4284-9323-0609c0974f18",
"options": {},
"httpMethod": "POST",
"responseMode": "responseNode"
},
"typeVersion": 2
},
{
"id": "cc68eafe-9e80-4319-913a-d650c6715987",
"name": "响应 Webhook",
"type": "n8n-nodes-base.respondToWebhook",
"position": [
360,
0
],
"parameters": {
"options": {},
"respondWith": "binary"
},
"typeVersion": 1.4
},
{
"id": "c19705bc-e2cd-47d6-a57f-d11cad5d97eb",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-980,
-360
],
"parameters": {
"width": 520,
"height": 340,
"content": "工作流概览"
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "55c67182-80fb-4972-9148-7e715dd3a6e9",
"connections": {
"Code": {
"main": [
[
{
"node": "Wait",
"type": "main",
"index": 0
}
]
]
},
"Wait": {
"main": [
[
{
"node": "HTTP Request2",
"type": "main",
"index": 0
}
]
]
},
"Code1": {
"main": [
[
{
"node": "Convert to File",
"type": "main",
"index": 0
}
]
]
},
"Webhook": {
"main": [
[
{
"node": "HTTP Request",
"type": "main",
"index": 0
}
]
]
},
"HTTP Request": {
"main": [
[
{
"node": "Code",
"type": "main",
"index": 0
}
]
]
},
"HTTP Request2": {
"main": [
[
{
"node": "Code1",
"type": "main",
"index": 0
}
]
]
},
"Convert to File": {
"main": [
[
{
"node": "Respond to Webhook",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
中级 - 发票处理, AI 摘要总结
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
DocSumo发票解析器
使用DocSumo提取并结构化发票数据并导出至Excel
Code
Form Trigger
Http Request
+2
7 节点Anurag
发票处理
每日 WhatsApp 群组智能分析:GPT-4.1 分析与语音消息转录
每日 WhatsApp 群组智能分析:GPT-4.1 分析与语音消息转录
If
Set
Code
+20
52 节点Daniel Lianes
杂项
我的工作流程 2
基于AI的发票数据提取与审批工作流程,集成ScrapeGraphAI和Telegram
Code
Switch
Webhook
+5
18 节点vinci-king-01
发票处理
在可视化参考库中探索n8n节点
在可视化参考库中探索n8n节点
If
Ftp
Set
+93
113 节点I versus AI
其他
自动化客户培育邮件与Notion客户评价收集
使用WhatsApp、GPT-4V和Google Sheets提取并整理收据数据
If
Code
Notion
+7
18 节点Shelly-Ann Davy
发票处理
[模板] AI宠物店 v8
🐶 AI宠物店助手 - 集成GPT-4o、Google日历和WhatsApp/Instagram/Facebook
If
N8n
Set
+38
244 节点Amanda Benks
销售