AI驱动的邮件PDF发票数据提取
高级
这是一个Finance, AI领域的自动化工作流,包含 27 个节点。主要使用 Set, Gmail, Merge, Airtable, SplitOut 等节点,结合人工智能技术实现智能自动化。 基于AI的邮件PDF发票数据提取至Airtable,集成GPT-4o
前置要求
- •Google 账号和 Gmail API 凭证
- •Airtable API Key
- •可能需要目标 API 的认证凭证
- •OpenAI API Key
使用的节点 (27)
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"meta": {
"instanceId": "c8c9ba5d3eb26ae47a06d24ff164a01c0d73ed4753a74903c2bb609d434a0f6b",
"templateId": "2320",
"templateCredsSetupCompleted": true
},
"nodes": [
{
"id": "7076854e-c7e8-45b5-9e5e-16678bffa254",
"name": "OpenAI 模型",
"type": "@n8n/n8n-nodes-langchain.lmOpenAi",
"position": [
1120,
1460
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4o",
"cachedResultName": "gpt-4o"
},
"options": {
"temperature": 0
}
},
"credentials": {
"openAiApi": {
"id": "IscXryYQZrfSUSkH",
"name": "OpenAi account"
}
},
"typeVersion": 1
},
{
"id": "00819f1c-2c60-4b7c-b395-445ec05fd898",
"name": "多表:您可以连接多个表以实现有组织的数据结构",
"type": "@n8n/n8n-nodes-langchain.outputParserStructured",
"position": [
1300,
1460
],
"parameters": {
"jsonSchema": "{\n \"Invoice Date\": { \"type\": \"string\", \"format\": \"date\" },\n\"Due Date\": { \"type\": \"string\", \"format\": \"date\" },\n \"Invoice Number\": { \"type\": \"string\" },\n \"Vendor Name\": { \"type\": \"string\" },\n \"Vendor Tax ID\": { \"type\": \"string\" },\n \"Product Name\": { \"type\": \"string\" },\n \"Price without Tax\": { \"type\": \"number\" },\n \"Price with Tax\": { \"type\": \"number\" }\n}"
},
"typeVersion": 1.1
},
{
"id": "1acf2c60-c2b9-4f78-94a4-0711c8bd71ab",
"name": "便签5",
"type": "n8n-nodes-base.stickyNote",
"position": [
-200,
180
],
"parameters": {
"color": 4,
"width": 760,
"height": 533,
"content": "# 发票处理自动化"
},
"typeVersion": 1
},
{
"id": "5f9b507f-4dc1-4853-bf71-a64f2f4b55c1",
"name": "映射输出",
"type": "n8n-nodes-base.set",
"position": [
1460,
1300
],
"parameters": {
"mode": "raw",
"options": {},
"jsonOutput": "={{ $json.output }}"
},
"typeVersion": 3.3
},
{
"id": "d22744cd-151d-4b92-b4f2-4a5b9ceb4ee7",
"name": "应用数据提取规则",
"type": "@n8n/n8n-nodes-langchain.chainLlm",
"position": [
1120,
1300
],
"parameters": {
"text": "=Given the following invoice in the <invoice> xml tags, extract the following information as listed below.\n\nIf you cannot the information for a specific item, then leave blank and skip to the next. Do **not come up with example or hallucinated information in any case!**\n\nInvoice Date format: YYYY/MM/DD\n\n{\n \"Invoice Date\": { \"type\": \"string\", \"format\": \"date\" },\n \"Due Date\": { \"type\": \"string\", \"format\": \"date\" },\n \"Invoice Number\": { \"type\": \"string\" },\n \"Vendor Name\": { \"type\": \"string\" },\n \"Vendor Tax ID\": { \"type\": \"string\" },\n \"Product Name\": { \"type\": \"string\" },\n \"Price without Tax\": { \"type\": \"number\" },\n \"Price with Tax\": { \"type\": \"number\" }\n}\n\nIf no tax displayed, price with and without should be the same!\n\n<invoice>{{ $json.choices[0].message.content }}</invoice>",
"promptType": "define",
"hasOutputParser": true
},
"typeVersion": 1.4
},
{
"id": "31b27190-bf01-4d2a-82ad-621e89bfbf6f",
"name": "Gmail1",
"type": "n8n-nodes-base.gmail",
"position": [
960,
600
],
"webhookId": "3561fdfa-c7bd-4d8b-a4c8-66da23965cc2",
"parameters": {
"simple": false,
"filters": {
"q": "in:inbox has:attachment invoice -label:invoice_checked "
},
"options": {
"downloadAttachments": true
},
"operation": "getAll"
},
"credentials": {
"gmailOAuth2": {
"id": "E3alb5H7xlfxfBur",
"name": "Automable Demo Gmail"
}
},
"typeVersion": 2.1
},
{
"id": "955fd212-11f7-4b2d-8e5c-a297509cbf08",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
900,
440
],
"parameters": {
"width": 230,
"height": 280,
"content": "获取所有满足以下条件的消息:"
},
"typeVersion": 1
},
{
"id": "712495a2-0c3d-452b-bd10-b19f6bea2178",
"name": "获取所有 img_url",
"type": "n8n-nodes-base.set",
"position": [
1760,
600
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "7715e33a-c5cc-4a22-aa28-ac19a24bbd7c",
"name": "url",
"type": "string",
"value": "={{ $json.Url }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "caa879e0-54c5-40c8-83b2-b59b1b74af67",
"name": "分析图片",
"type": "@n8n/n8n-nodes-langchain.openAi",
"position": [
800,
1300
],
"parameters": {
"text": "You can see the image of an invoice.\n\nExtract the following information as listed below.\n\nIn any way, extract everything from the image.\n\nIf you cannot the information for a specific item, then leave blank and skip to the next. Do **not come up with example or hallucinated information in any case!**\n\nInvoice date\nInvoice Due Date\n-- comment: sometimes instead of an explicit date it would have \"immediate\" payment, then it's the same as date; or eg. \"30 days from receipt\" in which case it's date + 30 days etc.)\ninvoice number\nSupplier name\nSupplier Tax ID\nName of Product or Service (if there are multiple, make it a general name, such as \"marketing services\" or \"computer parts and accessories\")\nPrice without Tax\nPrice with Tax (total price)\nIf no tax displayed, price with and without should be the same!\n\nRespond in a nice structured, easy to read format.\n",
"modelId": {
"__rl": true,
"mode": "list",
"value": "gpt-4o",
"cachedResultName": "GPT-4O"
},
"options": {},
"resource": "image",
"simplify": false,
"imageUrls": "={{ $('Get image data').item.json.Url }}",
"operation": "analyze"
},
"credentials": {
"openAiApi": {
"id": "IscXryYQZrfSUSkH",
"name": "OpenAi account"
}
},
"typeVersion": 1.8
},
{
"id": "b0052237-4129-460f-ae38-69680760c78b",
"name": "获取图片数据",
"type": "n8n-nodes-base.splitOut",
"position": [
1500,
600
],
"parameters": {
"options": {},
"fieldToSplitOut": "Files"
},
"typeVersion": 1
},
{
"id": "f7752ed2-5497-42a9-ab41-4fcee7faf52a",
"name": "PDF -> JPG - ConvertAPI",
"type": "n8n-nodes-base.httpRequest",
"position": [
1260,
600
],
"parameters": {
"url": "https://v2.convertapi.com/convert/pdf/to/jpg",
"method": "POST",
"options": {},
"sendBody": true,
"contentType": "multipart-form-data",
"sendHeaders": true,
"authentication": "genericCredentialType",
"bodyParameters": {
"parameters": [
{
"name": "StoreFile",
"value": "true"
},
{
"name": "ImageOutputFormat",
"value": "jpg"
},
{
"name": "File",
"parameterType": "formBinaryData",
"inputDataFieldName": "attachment_0"
}
]
},
"genericAuthType": "httpHeaderAuth",
"headerParameters": {
"parameters": [
{}
]
}
},
"credentials": {
"httpHeaderAuth": {
"id": "sRBpsZNt4u2787GP",
"name": "ConvertAPI Auth"
}
},
"retryOnFail": true,
"typeVersion": 4.2,
"waitBetweenTries": 5000
},
{
"id": "0625e6f0-d8ed-469e-a551-e82225a97144",
"name": "获取供应商列表",
"type": "n8n-nodes-base.airtable",
"position": [
1160,
900
],
"parameters": {
"base": {
"__rl": true,
"mode": "list",
"value": "appFMuGzhsUxbFKUh",
"cachedResultUrl": "https://airtable.com/appFMuGzhsUxbFKUh",
"cachedResultName": "Invoice Processing"
},
"table": {
"__rl": true,
"mode": "list",
"value": "tblDSjYz7MBFPh0PR",
"cachedResultUrl": "https://airtable.com/appFMuGzhsUxbFKUh/tblDSjYz7MBFPh0PR",
"cachedResultName": "Vendors"
},
"options": {},
"operation": "search"
},
"credentials": {
"airtableTokenApi": {
"id": "lkxZWCd27TyEahCT",
"name": "Airtable Personal Access Token account"
}
},
"typeVersion": 2.1
},
{
"id": "6d808c56-0449-43c8-afdb-2097a240ef87",
"name": "合并",
"type": "n8n-nodes-base.merge",
"position": [
1620,
880
],
"parameters": {
"mode": "combine",
"options": {},
"combineBy": "combineAll"
},
"typeVersion": 3.1
},
{
"id": "c7d36fae-d497-4ed2-be0f-2b2a699fb9f6",
"name": "编辑字段",
"type": "n8n-nodes-base.set",
"position": [
1360,
900
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "d8a97fc9-0ca8-4a27-a305-107409755d78",
"name": "vendors",
"type": "array",
"value": "={{ $input.all().map(({ json: { id, Name } }) => ({ id, Name })) }}"
}
]
}
},
"executeOnce": true,
"typeVersion": 3.4
},
{
"id": "69fbdb0d-8eff-4de2-bb9c-8261ebe7f67a",
"name": "信息提取器",
"type": "@n8n/n8n-nodes-langchain.informationExtractor",
"position": [
1840,
1400
],
"parameters": {
"text": "=List of vendors:\n{{ JSON.stringify($json.vendors) }}\n\nVendor info from the invoice:\nVendor name: {{ $json['Vendor Name'] }}\nVendor Tax ID: {{ $json['Vendor Tax ID'] }}\n\nRespond **only** with the ",
"options": {
"systemPromptTemplate": "You are an expert extraction algorithm.\nOnly extract relevant information from the text.\nIf you do not know the value of an attribute asked to extract, you may omit the attribute's value."
},
"attributes": {
"attributes": [
{
"name": "vendor_id",
"required": true,
"description": "Vendor ID. Or empty string (\"\") if there is no match."
}
]
}
},
"typeVersion": 1
},
{
"id": "134cb237-5500-4575-802a-ae8759104f92",
"name": "OpenAI 聊天模型",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
1860,
1580
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4o",
"cachedResultName": "gpt-4o"
},
"options": {}
},
"credentials": {
"openAiApi": {
"id": "IscXryYQZrfSUSkH",
"name": "OpenAi account"
}
},
"typeVersion": 1.2
},
{
"id": "4b32647c-1521-4279-8223-dbbc1c1eb714",
"name": "合并1",
"type": "n8n-nodes-base.merge",
"position": [
2380,
780
],
"parameters": {
"mode": "combine",
"options": {},
"combineBy": "combineByPosition",
"numberInputs": 3
},
"typeVersion": 3.1
},
{
"id": "6ad25f9f-f1e5-4468-9862-b0c93bc9b19d",
"name": "Airtable",
"type": "n8n-nodes-base.airtable",
"position": [
2620,
780
],
"parameters": {
"base": {
"__rl": true,
"mode": "list",
"value": "appFMuGzhsUxbFKUh",
"cachedResultUrl": "https://airtable.com/appFMuGzhsUxbFKUh",
"cachedResultName": "Invoice Processing"
},
"table": {
"__rl": true,
"mode": "list",
"value": "tblc95K9ITUgglNIC",
"cachedResultUrl": "https://airtable.com/appFMuGzhsUxbFKUh/tblc95K9ITUgglNIC",
"cachedResultName": "Invoices"
},
"columns": {
"value": {
"Vendor": "={{[ $json.output.vendor_id ]}}",
"Invoice": "={{ [ { url: $json.url }] }}",
"Due Date": "={{ $json['Due Date'] || null }}",
"Invoice Date": "={{ $json['Invoice Date'] }}",
"Product Name": "={{ $json['Product Name'] }}",
"Invoice Number": "=Invoice {{ $json['Invoice Number'] }}",
"Price with Tax": "={{ $json['Price with Tax'] }}",
"Price without Tax": "={{ $json['Price without Tax'] }}"
},
"schema": [
{
"id": "id",
"type": "string",
"display": true,
"removed": true,
"readOnly": true,
"required": false,
"displayName": "id",
"defaultMatch": true
},
{
"id": "Invoice Number",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "Invoice Number",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Invoice Date",
"type": "dateTime",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "Invoice Date",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Due Date",
"type": "dateTime",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "Due Date",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Product Name",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "Product Name",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Price without Tax",
"type": "number",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "Price without Tax",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Price with Tax",
"type": "number",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "Price with Tax",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Vendor",
"type": "array",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "Vendor",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Vendor Name",
"type": "string",
"display": true,
"removed": true,
"readOnly": true,
"required": false,
"displayName": "Vendor Name",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Invoice",
"type": "array",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "Invoice",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Approve",
"type": "string",
"display": true,
"removed": true,
"readOnly": true,
"required": false,
"displayName": "Approve",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Status",
"type": "options",
"display": true,
"options": [
{
"name": "New",
"value": "New"
},
{
"name": "Approved",
"value": "Approved"
}
],
"removed": true,
"readOnly": false,
"required": false,
"displayName": "Status",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [
"Invoice Number"
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {
"typecast": true
},
"operation": "upsert"
},
"credentials": {
"airtableTokenApi": {
"id": "lkxZWCd27TyEahCT",
"name": "Airtable Personal Access Token account"
}
},
"typeVersion": 2.1
},
{
"id": "9e775f8d-4af5-4212-8c65-36e3e5c161f2",
"name": "Gmail 触发器",
"type": "n8n-nodes-base.gmailTrigger",
"position": [
720,
600
],
"parameters": {
"filters": {},
"pollTimes": {
"item": [
{
"mode": "everyHour"
}
]
}
},
"credentials": {
"gmailOAuth2": {
"id": "duhSaIumY2CifCex",
"name": "Gmail account"
}
},
"typeVersion": 1.2
},
{
"id": "39afb11e-f98a-4d50-b31c-4b1806b6e483",
"name": "Gmail",
"type": "n8n-nodes-base.gmail",
"position": [
2820,
780
],
"webhookId": "9857fdd5-0c41-4b6f-80c2-2dba8dd3a086",
"parameters": {
"labelIds": [
"Label_292293622344874549"
],
"messageId": "={{ $('Gmail1').item.json.id }}",
"operation": "addLabels"
},
"credentials": {
"gmailOAuth2": {
"id": "E3alb5H7xlfxfBur",
"name": "Automable Demo Gmail"
}
},
"typeVersion": 2.1
},
{
"id": "ce68d5b8-1532-459f-b6fe-33f46e3f9186",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-200,
740
],
"parameters": {
"color": 5,
"width": 440,
"height": 460,
"content": "# *1. 设置 Airtable*"
},
"typeVersion": 1
},
{
"id": "89c5f457-fe92-43d2-b4ca-7cd5624f5cb1",
"name": "便签3",
"type": "n8n-nodes-base.stickyNote",
"position": [
-200,
1220
],
"parameters": {
"color": 5,
"width": 440,
"height": 420,
"content": "# 2. 设置 ConvertAPI"
},
"typeVersion": 1
},
{
"id": "896d3cd8-079e-4976-ae6b-61b73cd8c100",
"name": "便签4",
"type": "n8n-nodes-base.stickyNote",
"position": [
2560,
680
],
"parameters": {
"height": 100,
"content": "### 待办:将基础更改为复制的基础,并将表格更改为 \"Invoices\""
},
"typeVersion": 1
},
{
"id": "92a526d0-c116-4b1e-9ad2-5c1f45e0a6b8",
"name": "便签6",
"type": "n8n-nodes-base.stickyNote",
"position": [
1100,
1040
],
"parameters": {
"height": 100,
"content": "### 待办:将基础更改为复制的基础,并将表格更改为 \"Vendors\""
},
"typeVersion": 1
},
{
"id": "f4635b8b-25d5-4e23-af98-0d2d25040d90",
"name": "便签7",
"type": "n8n-nodes-base.stickyNote",
"position": [
-200,
1660
],
"parameters": {
"color": 5,
"width": 440,
"height": 420,
"content": "# 3. 设置 Gmail"
},
"typeVersion": 1
},
{
"id": "903f5ee9-fde9-4225-949f-d02b0e820bbd",
"name": "便签8",
"type": "n8n-nodes-base.stickyNote",
"position": [
-200,
2100
],
"parameters": {
"color": 5,
"width": 440,
"height": 220,
"content": "# 4. 设置 OpenAI"
},
"typeVersion": 1
},
{
"id": "58c3cdaf-3912-40d3-9b95-8b610ae95540",
"name": "便签9",
"type": "n8n-nodes-base.stickyNote",
"position": [
1180,
520
],
"parameters": {
"height": 100,
"content": "### 待办:添加 ConvertAPI Header Auth"
},
"typeVersion": 1
}
],
"pinData": {},
"connections": {
"Merge": {
"main": [
[
{
"node": "Information Extractor",
"type": "main",
"index": 0
}
]
]
},
"Gmail1": {
"main": [
[
{
"node": "PDF -> JPG - ConvertAPI",
"type": "main",
"index": 0
}
]
]
},
"Merge1": {
"main": [
[
{
"node": "Airtable",
"type": "main",
"index": 0
}
]
]
},
"Airtable": {
"main": [
[
{
"node": "Gmail",
"type": "main",
"index": 0
}
]
]
},
"Map Output": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 1
},
{
"node": "Merge1",
"type": "main",
"index": 2
}
]
]
},
"Edit Fields": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Model": {
"ai_languageModel": [
[
{
"node": "Apply Data Extraction Rules",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Analyze image": {
"main": [
[
{
"node": "Apply Data Extraction Rules",
"type": "main",
"index": 0
}
]
]
},
"Gmail Trigger": {
"main": [
[
{
"node": "Gmail1",
"type": "main",
"index": 0
}
]
]
},
"Get image data": {
"main": [
[
{
"node": "Get all img_url",
"type": "main",
"index": 0
}
]
]
},
"Get all img_url": {
"main": [
[
{
"node": "Analyze image",
"type": "main",
"index": 0
},
{
"node": "Merge1",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "Information Extractor",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Get list of vendors": {
"main": [
[
{
"node": "Edit Fields",
"type": "main",
"index": 0
}
]
]
},
"Information Extractor": {
"main": [
[
{
"node": "Merge1",
"type": "main",
"index": 1
}
]
]
},
"PDF -> JPG - ConvertAPI": {
"main": [
[
{
"node": "Get image data",
"type": "main",
"index": 0
}
]
]
},
"Structured Output Parser": {
"ai_outputParser": [
[
{
"node": "Apply Data Extraction Rules",
"type": "ai_outputParser",
"index": 0
}
]
]
},
"Apply Data Extraction Rules": {
"main": [
[
{
"node": "Map Output",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
高级 - 财务, 人工智能
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
在可视化参考库中探索n8n节点
在可视化参考库中探索n8n节点
If
Ftp
Set
+93
113 节点I versus AI
其他
初创公司融资研究自动化
使用 Claude、Perplexity AI 和 Airtable 进行初创公司融资研究自动化
Set
Xml
Html
+15
51 节点Julian Kaiser
财务
使用 AI 去重抓取的 AI 资助资格数据
使用 AI 去重抓取的 AI 资助资格数据
Html
Gmail
Merge
+8
24 节点Jimleuk
财务
附件 Gmail 到 Drive 和 Google Sheets
从Gmail到Drive和Google表格的发票处理
If
Set
Gmail
+10
18 节点Juan Carlos Cavero Gracia
财务
AI邮件分诊与GPT-4警报系统及Telegram通知
AI邮件分诊与GPT-4警报系统及Telegram通知
If
Set
Gmail
+22
104 节点Peter Joslyn
客户支持
自动化新闻到简报AI代理v13
AI新闻研究团队:24/7简报自动化,含Perplexity引用
Set
Code
Gmail
+15
37 节点Derek Cheung
产品