邮件发票数据提取到Google Sheets
中级
这是一个Finance, AI领域的自动化工作流,包含 10 个节点。主要使用 Code, Filter, GoogleDrive, GmailTrigger, GoogleSheets 等节点,结合人工智能技术实现智能自动化。 使用GPT-4o AI自动化从邮件中提取发票数据到Google Sheets
前置要求
- •Google Drive API 凭证
- •Google 账号和 Gmail API 凭证
- •Google Sheets API 凭证
- •OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"meta": {
"instanceId": "5aaf4236c70e34e423fbdb2c7b754d19253a933bb1476d548f75848a01e473cf",
"templateCredsSetupCompleted": true
},
"nodes": [
{
"id": "70ca3a90-55c8-4e46-9278-6a8fd3d107cd",
"name": "Gmail 触发器",
"type": "n8n-nodes-base.gmailTrigger",
"position": [
-1820,
220
],
"parameters": {
"simple": false,
"filters": {
"labelIds": [
"Label_1393502052621954450"
]
},
"options": {
"downloadAttachments": true
},
"pollTimes": {
"item": [
{
"mode": "everyMinute"
}
]
}
},
"typeVersion": 1.2
},
{
"id": "f7dcff0f-7e98-4042-a33e-2fc32d876908",
"name": "创建空白电子表格",
"type": "n8n-nodes-base.googleSheets",
"position": [
-780,
220
],
"parameters": {
"title": "=invoice_{{ $now }}",
"options": {},
"resource": "spreadsheet",
"sheetsUi": {
"sheetValues": [
{
"title": "=invoice_details"
}
]
}
},
"executeOnce": false,
"typeVersion": 4.5
},
{
"id": "9769ad04-a41c-4d55-806a-042b7d00e131",
"name": "将电子表格移动到发票文件夹",
"type": "n8n-nodes-base.googleDrive",
"position": [
-560,
220
],
"parameters": {
"fileId": {
"__rl": true,
"mode": "id",
"value": "={{ $json.spreadsheetId }}"
},
"driveId": {
"__rl": true,
"mode": "list",
"value": "My Drive",
"cachedResultUrl": "https://drive.google.com/drive/my-drive",
"cachedResultName": "My Drive"
},
"folderId": {
"__rl": true,
"mode": "list",
"value": "1JIdajTJvK6gj4bRjniBJvHEJbQ1pn3AM",
"cachedResultUrl": "https://drive.google.com/drive/folders/1JIdajTJvK6gj4bRjniBJvHEJbQ1pn3AM",
"cachedResultName": "invoices"
},
"operation": "move"
},
"typeVersion": 3
},
{
"id": "f9dbfe55-70b0-4abc-9745-9f4a65d5d1c2",
"name": "OpenAI 聊天模型",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
-1180,
480
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4o-mini"
},
"options": {
"responseFormat": "json_object"
}
},
"credentials": {
"openAiApi": {
"id": "7dME1fmMlkFyzFjq",
"name": "OpenAi account 2"
}
},
"typeVersion": 1.2
},
{
"id": "00c59142-6079-4e9c-9374-ad487e48f072",
"name": "附件验证",
"type": "n8n-nodes-base.filter",
"position": [
-1600,
220
],
"parameters": {
"options": {
"ignoreCase": false
},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "efd974d9-aa20-461a-86ae-6e0a16d1527d",
"operator": {
"type": "object",
"operation": "exists",
"singleValue": true
},
"leftValue": "={{ $('Gmail Trigger').item.binary }}",
"rightValue": ""
}
]
}
},
"typeVersion": 2.2
},
{
"id": "8a29ac14-be2b-468a-97fa-540d28e80006",
"name": "提取发票数据",
"type": "n8n-nodes-base.extractFromFile",
"position": [
-1380,
220
],
"parameters": {
"options": {},
"operation": "pdf",
"binaryPropertyName": "={{ $('Attachment Verification').item.binary.keys() }}"
},
"typeVersion": 1
},
{
"id": "ae08cdc8-fcf9-4891-be86-b2dcf6f35278",
"name": "准备最终数据",
"type": "n8n-nodes-base.code",
"position": [
-340,
220
],
"parameters": {
"mode": "runOnceForEachItem",
"jsCode": "// Loop over input items and add a new field called 'myNewField' to the JSON of $input$json.output.first().json.outputeach one\n\nlet invoice_details = $('Invoice AI Agent').item.json.output\n\nreturn JSON.parse(invoice_details)"
},
"typeVersion": 2
},
{
"id": "7615a5b0-8761-43e2-82b0-32ac5c772f44",
"name": "包含发票数据的最终电子表格",
"type": "n8n-nodes-base.googleSheets",
"position": [
-140,
220
],
"parameters": {
"columns": {
"value": {},
"schema": [
{
"id": "billed_to",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "billed_to",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "invoice_number",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "invoice_number",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "date_of_issue",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "date_of_issue",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "due_date",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "due_date",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "item_0_description",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "item_0_description",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "item_0_quantity",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "item_0_quantity",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "item_0_rate",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "item_0_rate",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "item_0_amount",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "item_0_amount",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "tax_0_cgst_rate",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "tax_0_cgst_rate",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "tax_0_cgst_amount",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "tax_0_cgst_amount",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "tax_0_sgst_rate",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "tax_0_sgst_rate",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "tax_0_sgst_amount",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "tax_0_sgst_amount",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "item_0_total_amount",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "item_0_total_amount",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "subtotal",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "subtotal",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "total",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "total",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "terms",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "terms",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "conditions_instructions",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "conditions_instructions",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "company_name",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "company_name",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "company_mobile",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "company_mobile",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "company_email",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "company_email",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "company_website",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "company_website",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "payment_transaction_ids",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "payment_transaction_ids",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "mode_of_payment",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "mode_of_payment",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "billing_address",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "billing_address",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "shipping_address",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "shipping_address",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "place_of_supply",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "place_of_supply",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "place_of_delivery",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "place_of_delivery",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "gst_registration_no",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "gst_registration_no",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "pan_no",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "pan_no",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "autoMapInputData",
"matchingColumns": [],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {},
"operation": "append",
"sheetName": {
"__rl": true,
"mode": "name",
"value": "invoice_details"
},
"documentId": {
"__rl": true,
"mode": "id",
"value": "={{ $('Create blank spreadsheet').item.json.spreadsheetId }}"
}
},
"typeVersion": 4.5
},
{
"id": "e68aa386-7150-4070-a5d7-1dcb963b620d",
"name": "发票AI代理",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
-1160,
220
],
"parameters": {
"text": "={{ $json.text }}",
"options": {
"systemMessage": "you are an financial advisor , who reads the array of data to identify certain elements of an Invoice, from the input data and provide a json response. use only following specified keys \nfor example:\n{\n\"billed_to\": \"John\",\n\"invoice_number\": \"569871234\",\n\"date_of_issue\": \"2025-05-21\",\n\"due_date\": \"2025-05-25\",\n\"item_0_description\": \"Computer CPU\",\n\"item_0_quantity\": 6,\n\"item_0_rate\": 15,\n\"item_0_amount\": 90,\n\"item_1_description\": \"Chair Wooden\",\n\"item_1_quantity\": 8,\n\"item_1_rate\": 10,\n\"item_1_amount\": 80,\n\"subtotal\": 170.00,\n\"discount\": 20.00,\n\"total\": 150.00,\n\"terms\": \"Sold items not be acceptable\",\n\"conditions_instructions\": \"xyaABC\",\n\"company_name\": \"Digital Electronics\",\n\"company_mobile\": \"987654321\",\n\"company_email\": \"ayz@gmail.com\",\n\"company_website\": \"www.abc.com\"\n}"
},
"promptType": "define",
"hasOutputParser": true
},
"typeVersion": 1.9,
"alwaysOutputData": false
},
{
"id": "335a80c5-ad86-4379-b1a6-9a2ef7285f3c",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-2860,
100
],
"parameters": {
"width": 880,
"height": 1520,
"content": "AI发票处理代理:从电子邮件到结构化数据"
},
"typeVersion": 1
}
],
"pinData": {},
"connections": {
"Gmail Trigger": {
"main": [
[
{
"node": "Attachment Verification",
"type": "main",
"index": 0
}
]
]
},
"Invoice AI Agent": {
"main": [
[
{
"node": "Create blank spreadsheet",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "Invoice AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Extract Invoice data": {
"main": [
[
{
"node": "Invoice AI Agent",
"type": "main",
"index": 0
}
]
]
},
"Preparing Final data": {
"main": [
[
{
"node": "Final Spreadsheet with Invoice data",
"type": "main",
"index": 0
}
]
]
},
"Attachment Verification": {
"main": [
[
{
"node": "Extract Invoice data",
"type": "main",
"index": 0
}
]
]
},
"Create blank spreadsheet": {
"main": [
[
{
"node": "Move spreadsheet in invoice folder",
"type": "main",
"index": 0
}
]
]
},
"Move spreadsheet in invoice folder": {
"main": [
[
{
"node": "Preparing Final data",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
中级 - 财务, 人工智能
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
哥伦比亚发票处理
使用Gmail、GPT-4o和Google Workspace提取并整理哥伦比亚发票
Xml
Code
Merge
+15
23 节点Juan Sanchez
财务
自动化PDF发票处理与审批流程,使用OpenAI和Google表格
自动化PDF发票处理与审批流程,使用OpenAI和Google表格
If
Gmail
Form Trigger
+9
17 节点Billy Christi
财务
AI YouTube分析助手:评论分析与洞察报告
AI YouTube分析助手:评论分析器与洞察报告生成器
If
Set
Code
+9
19 节点Yaron Been
人工智能
AI驱动的PDF发票解析器 - Google Drive、Google Sheets和OpenAI
基于Google Drive、Google Sheets和OpenAI的AI驱动PDF发票解析器
Google Drive
Google Sheets
Agent
+5
10 节点Billy Christi
财务
(Tung) OCR发票提取到电子表格副本
自动发票和收据OCR到Google表格 - 支持云端硬盘、Gmail和Telegram触发
If
Set
Code
+10
25 节点Daniel Ng
财务
使用 GPT-4 自动生成并分发 LinkedIn 帖子到个人资料和群组
使用 GPT-4 自动生成并分发 LinkedIn 帖子到个人资料和群组
If
Code
Limit
+8
14 节点Yaron Been
人工智能
工作流信息
难度等级
中级
节点数量10
分类2
节点类型9
作者
Yaron Been
@yaron-nofluffBuilding AI Agents and Automations | Growth Marketer | Entrepreneur | Book Author & Podcast Host
外部链接
在 n8n.io 查看 →
分享此工作流