自动化差旅费用报销工作流
高级
这是一个Invoice Processing, AI Summarization领域的自动化工作流,包含 20 个节点。主要使用 Code, EmailSend, FormTrigger, GoogleDrive, GoogleSheets 等节点。 使用GPT-4.1-mini从差旅收据中提取数据,结合Google Sheets和邮件通知
前置要求
- •Google Drive API 凭证
- •Google Sheets API 凭证
- •OpenAI API Key
使用的节点 (20)
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "r6Clz7C4iBTnB3ar",
"meta": {
"instanceId": "4a2e6764ba7a6bc9890d9225f4b21d570ce88fc9bd57549c89057fcee58fed0f",
"templateId": "5453",
"templateCredsSetupCompleted": true
},
"name": "使用 gpt-4.1-mini 的自动化差旅费用报销工作流",
"tags": [
{
"id": "5HqPDYxcmr92h5gG",
"name": "Finance Workflow",
"createdAt": "2025-08-02T13:47:30.790Z",
"updatedAt": "2025-08-02T13:47:30.790Z"
}
],
"nodes": [
{
"id": "511042e8-828d-4eed-a305-58a5fb10c8bb",
"name": "便利贴7",
"type": "n8n-nodes-base.stickyNote",
"position": [
-2544,
1168
],
"parameters": {
"width": 1120,
"height": 1568,
"content": "# 🧾 使用 gpt-4.1-mini 的自动化差旅费用报销工作流"
},
"typeVersion": 1
},
{
"id": "5f325f14-8a4e-4920-9302-c598805b5a70",
"name": "便利贴3",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1360,
1168
],
"parameters": {
"width": 540,
"height": 948,
"content": ""
},
"typeVersion": 1
},
{
"id": "e3f8bbb9-594e-4e89-9d78-e55a0db9803f",
"name": "便利贴5",
"type": "n8n-nodes-base.stickyNote",
"position": [
-240,
1632
],
"parameters": {
"width": 892,
"height": 496,
"content": "## 1.1 – 使用 AI 代理提取和解析发票"
},
"typeVersion": 1
},
{
"id": "efe400aa-4b57-4651-a847-976e1a4c927b",
"name": "便利贴",
"type": "n8n-nodes-base.stickyNote",
"position": [
1408,
1664
],
"parameters": {
"width": 556,
"height": 336,
"content": "## 3. 将报销摘要发送给财务团队"
},
"typeVersion": 1
},
{
"id": "5c0dd81a-634f-4f98-83c5-6420c19fe3c4",
"name": "便利贴6",
"type": "n8n-nodes-base.stickyNote",
"position": [
2000,
1856
],
"parameters": {
"width": 1004,
"height": 516,
"content": ""
},
"typeVersion": 1
},
{
"id": "6c4e9c64-e684-45c3-b979-b7de198df9b8",
"name": "表单提交时",
"type": "n8n-nodes-base.formTrigger",
"position": [
-736,
1664
],
"webhookId": "d2b90e45-460e-416f-8e8f-00cb2d370d9d",
"parameters": {
"options": {},
"formTitle": "Business Trip Claim Submission",
"formFields": {
"values": [
{
"fieldLabel": "Employee Name",
"placeholder": "Your full name",
"requiredField": true
},
{
"fieldType": "dropdown",
"fieldLabel": "Department",
"fieldOptions": {
"values": [
{
"option": "Sales"
},
{
"option": "Engineering"
},
{
"option": "HR"
},
{
"option": "Executive"
}
]
},
"requiredField": true
},
{
"fieldLabel": "Trip Purpose",
"placeholder": "Client meeting with ABC Corp",
"requiredField": true
},
{
"fieldType": "date",
"fieldLabel": "From Date",
"requiredField": true
},
{
"fieldType": "date",
"fieldLabel": "To Date",
"requiredField": true
},
{
"fieldType": "file",
"fieldLabel": "Receipts / Invoices",
"requiredField": true,
"acceptFileTypes": ".pdf"
}
]
},
"formDescription": "Submit your business trip expense claim by providing trip details and uploading all related invoices or receipts."
},
"typeVersion": 2.2
},
{
"id": "fca9ee73-d2da-4420-a541-8b641a70b097",
"name": "转换输出",
"type": "n8n-nodes-base.code",
"position": [
832,
1808
],
"parameters": {
"jsCode": "// Static or dynamic employee information\nconst profile = $('On form submission').first().json;\nconst employee = {\n name: profile[\"Employee Name\"],\n department: profile[\"Department\"],\n tripPurpose: profile[\"Trip Purpose\"],\n fromDate: profile[\"From Date\"],\n toDate: profile[\"To Date\"],\n};\n\n// Collect parsed expense outputs\nconst items = $input.all();\nconst expenses = items.map((item, index) => {\n const data = item.json.output;\n\n return {\n index: index + 1,\n expenseType: data.expense_type || \"\",\n vendor: data.vendor_name || \"\",\n invoiceNumber: data.invoice_number || \"\",\n receiptNumber: data.receipt_number || \"\",\n issueDate: data.issue_date || \"\",\n totalAmount: data.total_amount || 0,\n currency: data.currency || \"\",\n taxAmount: data.tax_amount || 0,\n paymentMethod: data.payment_method || \"\",\n location: data.location || \"\",\n notes: data.notes || \"\",\n items: data.itemized_descriptions || []\n };\n});\n\nreturn [\n {\n json: {\n employee,\n expenses\n }\n }\n];"
},
"typeVersion": 2
},
{
"id": "2d99c9cf-842c-4fec-af66-c87291a39383",
"name": "上传文件",
"type": "n8n-nodes-base.googleDrive",
"position": [
-96,
1424
],
"parameters": {
"name": "=invoice-{{ $now.toFormat(\"yyyyLLdd-HHmmss\") }}-{{$binary.data.fileName}}",
"driveId": {
"__rl": true,
"mode": "list",
"value": "My Drive"
},
"options": {},
"folderId": {
"__rl": true,
"mode": "list",
"value": "1IPcko8bzogO3W4mxhrW2Q017QA0Lc5MI",
"cachedResultUrl": "https://drive.google.com/drive/folders/1IPcko8bzogO3W4mxhrW2Q017QA0Lc5MI",
"cachedResultName": "SmartSales"
}
},
"credentials": {
"googleDriveOAuth2Api": {
"id": "fC471es5gk5Mm900",
"name": "Google Drive account"
}
},
"typeVersion": 3
},
{
"id": "f2249caa-a6b6-41d5-8ed8-9dac36134716",
"name": "便利贴9",
"type": "n8n-nodes-base.stickyNote",
"position": [
-240,
1280
],
"parameters": {
"width": 892,
"height": 320,
"content": "## 1.2. 将发票存储到 Google Sheet"
},
"typeVersion": 1
},
{
"id": "509b2701-e1d7-43da-bf7f-c51b0f4b68d6",
"name": "便利贴10",
"type": "n8n-nodes-base.stickyNote",
"position": [
720,
1664
],
"parameters": {
"width": 620,
"height": 336,
"content": "## 2. 转换并生成 HTML 电子邮件"
},
"typeVersion": 1
},
{
"id": "e8937db3-e66b-4638-84b1-06c847440628",
"name": "从文件提取",
"type": "n8n-nodes-base.extractFromFile",
"position": [
-96,
1808
],
"parameters": {
"options": {},
"operation": "pdf"
},
"typeVersion": 1
},
{
"id": "36c4ad16-9720-4a79-b112-81b7836234be",
"name": "DocClaim 助手代理",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
176,
1808
],
"parameters": {
"text": "=Extract all relevant information from thisreceipt or invoice below:\n---\n{{ $json.text }}\n---\nI need the output in a structured format suitable for generating a business expense claim report. Include fields like vendor name, invoice or receipt number, date, total amount, tax, payment method, currency, and item descriptions.",
"options": {
"systemMessage": "You are a document extraction assistant specialized in parsing receipts and invoices. Your role is to read and extract all relevant financial and business information from uploaded PDF files. Focus on identifying fields commonly used in expense claim reports, such as vendor name, invoice number, receipt number, date of issue, total amount, tax amount, currency, payment method, and itemized descriptions. Return the data in a clean, structured format. Do not include unnecessary text or decorative content. If some fields are missing, leave them blank. Maintain consistency in field naming and format."
},
"promptType": "define",
"hasOutputParser": true
},
"typeVersion": 2.1
},
{
"id": "ca934b9b-3c6a-45e3-8df6-90593691a6e3",
"name": "在表格中附加行",
"type": "n8n-nodes-base.googleSheets",
"position": [
384,
1424
],
"parameters": {
"columns": {
"value": {},
"schema": [
{
"id": "EmployeeName",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "EmployeeName",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Department",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "Department",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "TripPurpose",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "TripPurpose",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "FromDate",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "FromDate",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "ToDate",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "ToDate",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "FileName",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "FileName",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "DownloadURL",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "DownloadURL",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Size",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "Size",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "SubmittedAt",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "SubmittedAt",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "autoMapInputData",
"matchingColumns": [],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {},
"operation": "append",
"sheetName": {
"__rl": true,
"mode": "list",
"value": "gid=0",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1qk6OebcuZkIRorf1k235ew88oZ-UlUJSyiHFqZYDbaU/edit#gid=0",
"cachedResultName": "Sheet1"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1qk6OebcuZkIRorf1k235ew88oZ-UlUJSyiHFqZYDbaU",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1qk6OebcuZkIRorf1k235ew88oZ-UlUJSyiHFqZYDbaU/edit?usp=drivesdk",
"cachedResultName": "Invoices Tracking"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "L670Nly6gZGo71br",
"name": "Google Sheets account 2"
}
},
"typeVersion": 4.6
},
{
"id": "ac2f4a6e-d950-4aa8-b0b3-072eac9fbe0d",
"name": "转换发票记录",
"type": "n8n-nodes-base.code",
"position": [
144,
1424
],
"parameters": {
"mode": "runOnceForEachItem",
"jsCode": "const claimForm = $('On form submission').first().json;\nreturn {\n EmployeeName: claimForm[\"Employee Name\"],\n Department: claimForm[\"Department\"],\n TripPurpose: claimForm[\"Trip Purpose\"],\n FromDate: claimForm[\"From Date\"],\n ToDate: claimForm[\"To Date\"],\n FileName: $json.name,\n DownloadURL: $json.webContentLink,\n Size: $json.size,\n SubmittedAt: claimForm[\"submittedAt\"]\n }"
},
"typeVersion": 2
},
{
"id": "4ab39a13-3479-40d8-b782-201416bb4cc8",
"name": "结构化输出解析器",
"type": "@n8n/n8n-nodes-langchain.outputParserStructured",
"position": [
384,
1984
],
"parameters": {
"jsonSchemaExample": "{\n \"expense_type\": \"Hotel\",\n \"vendor_name\": \"Grand Central Hotel\",\n \"invoice_number\": \"INV-20250802-001\",\n \"receipt_number\": \"RCPT-56789\",\n \"issue_date\": \"2025-08-02\",\n \"total_amount\": 150.00,\n \"tax_amount\": 15.00,\n \"currency\": \"USD\",\n \"payment_method\": \"Credit Card\",\n \"location\": \"Hanoi, Vietnam\",\n \"trip_purpose\": \"Client Meeting\",\n \"trip_dates\": {\n \"from\": \"2025-08-02\",\n \"to\": \"2025-08-03\"\n },\n \"itemized_descriptions\": [\n {\n \"category\": \"Accommodation\",\n \"description\": \"1 night stay - Deluxe Room\",\n \"quantity\": 1,\n \"unit_price\": 120.00,\n \"line_total\": 120.00\n },\n {\n \"category\": \"Service Charge\",\n \"description\": \"Hotel service fee\",\n \"quantity\": 1,\n \"unit_price\": 10.00,\n \"line_total\": 10.00\n },\n {\n \"category\": \"Tax\",\n \"description\": \"VAT 10%\",\n \"quantity\": 1,\n \"unit_price\": 15.00,\n \"line_total\": 15.00\n }\n ],\n \"notes\": \"\"\n}"
},
"typeVersion": 1.3
},
{
"id": "8ae7f569-3bb0-4d3b-91a2-fd0ae82649bc",
"name": "创建 HTML 电子邮件模板",
"type": "n8n-nodes-base.code",
"position": [
1120,
1808
],
"parameters": {
"jsCode": "const data = $input.first().json;\n\nconst { employee, expenses } = data;\n\n// Helper to generate expense summary rows\nconst expenseSummaryRows = expenses.map(expense => `\n <tr>\n <td>${expense.index}</td>\n <td>${expense.expenseType}</td>\n <td>${expense.vendor}</td>\n <td>${expense.issueDate}</td>\n <td>${expense.totalAmount}</td>\n <td>${expense.currency}</td>\n <td>${expense.taxAmount}</td>\n <td>${expense.paymentMethod}</td>\n </tr>\n`).join(\"\");\n\n// Helper to generate detailed tables for each expense\nconst expenseDetailSections = expenses.map(expense => {\n const itemRows = (expense.items || []).map(item => `\n <tr>\n <td>${item.category}</td>\n <td>${item.description}</td>\n <td>${item.quantity}</td>\n <td>${item.unit_price}</td>\n <td>${item.line_total}</td>\n </tr>\n `).join(\"\");\n\n return `\n <div style=\"margin-top:32px;\">\n <h4>Details for Expense #${expense.index} - ${expense.expenseType}</h4>\n <p><strong>Vendor:</strong> ${expense.vendor}</p>\n <p><strong>Invoice No.:</strong> ${expense.invoiceNumber}</p>\n <p><strong>Receipt No.:</strong> ${expense.receiptNumber}</p>\n <p><strong>Location:</strong> ${expense.location}</p>\n <p><strong>Notes:</strong> ${expense.notes}</p>\n <table border=\"1\" cellpadding=\"6\" cellspacing=\"0\" width=\"100%\" style=\"border-collapse:collapse;margin-top:10px;\">\n <thead>\n <tr style=\"background-color:#f4f4f4;\">\n <th>Category</th>\n <th>Description</th>\n <th>Qty</th>\n <th>Unit Price</th>\n <th>Line Total</th>\n </tr>\n </thead>\n <tbody>${itemRows}</tbody>\n </table>\n </div>\n `;\n}).join(\"\");\n\nconst html = `\n<!DOCTYPE html>\n<html>\n<head>\n <meta charset=\"UTF-8\" />\n <style>\n body { font-family: Arial, sans-serif; color: #333; }\n h2 { color: #0077b6; }\n table { width: 100%; border-collapse: collapse; margin-bottom: 24px; }\n th, td { padding: 8px; border: 1px solid #ddd; font-size: 14px; }\n th { background-color: #f4f4f4; text-align: left; }\n h4 { margin-bottom: 5px; margin-top: 30px; color: #444; }\n </style>\n</head>\n<body>\n\n <h2>Expense Claim Request</h2>\n\n <p><strong>Employee Name:</strong> ${employee.name}</p>\n <p><strong>Department:</strong> ${employee.department}</p>\n <p><strong>Trip Purpose:</strong> ${employee.tripPurpose}</p>\n <p><strong>Trip Dates:</strong> ${employee.fromDate} to ${employee.toDate}</p>\n\n <h3>Expense Summary</h3>\n <table>\n <thead>\n <tr>\n <th>#</th>\n <th>Type</th>\n <th>Vendor</th>\n <th>Issue Date</th>\n <th>Total</th>\n <th>Currency</th>\n <th>Tax</th>\n <th>Payment</th>\n </tr>\n </thead>\n <tbody>\n ${expenseSummaryRows}\n </tbody>\n </table>\n\n ${expenseDetailSections}\n\n <p style=\"margin-top:32px;\">Thank you,<br/>${employee.name}</p>\n\n</body>\n</html>\n`;\n\nreturn [{ json: { html } }];"
},
"typeVersion": 2
},
{
"id": "b32b2c21-d4a9-4c58-8f4b-0cc35436cce5",
"name": "便利贴8",
"type": "n8n-nodes-base.stickyNote",
"position": [
2000,
1328
],
"parameters": {
"width": 1004,
"height": 516,
"content": ""
},
"typeVersion": 1
},
{
"id": "c3755330-96b8-4aa6-9463-8bb77a6c178c",
"name": "将差旅费用请求发送给财务团队",
"type": "n8n-nodes-base.emailSend",
"position": [
1600,
1808
],
"webhookId": "0ed7153b-1dbc-45af-8509-511e3478c079",
"parameters": {
"html": "={{ $json.html }}",
"options": {},
"subject": "=Expense Claim Request - {{ $('Transform Output').item.json.employee.name }} – {{ $('Transform Output').item.json.employee.department }} - {{ $('Transform Output').item.json.employee.tripPurpose }}"
},
"credentials": {
"smtp": {
"id": "Cqc9p9Z5PHj2MHzn",
"name": "SMTP account"
}
},
"typeVersion": 2.1
},
{
"id": "97927e98-c5b0-4a7c-a183-88e47919b050",
"name": "处理多个文件",
"type": "n8n-nodes-base.code",
"position": [
-464,
1664
],
"parameters": {
"jsCode": "const data = $input.item.json;\nconst binaryData = $input.item.binary;\n\nlet output = [];\n\nObject.keys(binaryData)\n .filter(label => label.startsWith(\"Receipts___Invoices_\"))\n .forEach(label => {\n output.push({\n json: data,\n binary: { data: binaryData[label] }\n });\n });\n\nreturn output;"
},
"typeVersion": 2
},
{
"id": "5cd08389-4b62-41e8-845b-c321361e03d2",
"name": "GPT",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
160,
1984
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4.1-mini",
"cachedResultName": "gpt-4.1-mini"
},
"options": {}
},
"credentials": {
"openAiApi": {
"id": "PPSwAKeLQYgAPobT",
"name": "OpenAi account"
}
},
"typeVersion": 1.2
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "55afe44c-c3c5-42ac-9857-70e65e57e5ee",
"connections": {
"GPT": {
"ai_languageModel": [
[
{
"node": "DocClaim Assistant Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Upload file": {
"main": [
[
{
"node": "Transform invoice record",
"type": "main",
"index": 0
}
]
]
},
"Transform Output": {
"main": [
[
{
"node": "Create HTML Email Template",
"type": "main",
"index": 0
}
]
]
},
"Extract from File": {
"main": [
[
{
"node": "DocClaim Assistant Agent",
"type": "main",
"index": 0
}
]
]
},
"On form submission": {
"main": [
[
{
"node": "Handle multiple files",
"type": "main",
"index": 0
}
]
]
},
"Handle multiple files": {
"main": [
[
{
"node": "Upload file",
"type": "main",
"index": 0
},
{
"node": "Extract from File",
"type": "main",
"index": 0
}
]
]
},
"DocClaim Assistant Agent": {
"main": [
[
{
"node": "Transform Output",
"type": "main",
"index": 0
}
]
]
},
"Structured Output Parser": {
"ai_outputParser": [
[
{
"node": "DocClaim Assistant Agent",
"type": "ai_outputParser",
"index": 0
}
]
]
},
"Transform invoice record": {
"main": [
[
{
"node": "Append row in sheet",
"type": "main",
"index": 0
}
]
]
},
"Create HTML Email Template": {
"main": [
[
{
"node": "Send trip expense request to finance team",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
高级 - 发票处理, AI 摘要总结
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
HireMind – AI驱动的简历智能处理流程
HR AI简历筛选与评估:GPT-4和Google Workspace
If
Code
Slack
+10
26 节点Trung Tran
人力资源
TalentFlow AI - 批量简历筛选与职位描述匹配
使用GPT-4为HR团队进行批量简历筛选与职位描述匹配
If
Code
Merge
+12
30 节点Trung Tran
人力资源
智能面试助手:基于简历、职位描述和轮次的定制问题
基于简历、职位描述和轮次使用GPT-4生成定制面试问题
Set
Code
Merge
+10
26 节点Trung Tran
人力资源
智能简历提取器:Google Drive到Sheet + 招聘人员Slack更新
AI驱动简历提取器:GPT-4处理Google Drive到Sheet,Slack通知招聘人员
Code
Slack
Filter
+8
19 节点Trung Tran
人力资源
构建用于Slack候选人评估的AI驱动聊天机器人
AI简历分析与候选人评估:Slack和Google表格集成
If
Code
Slack
+12
29 节点Trung Tran
AI 聊天机器人
使用GPT4o自动从名片提取联系人到表格
使用GPT4o从名片提取联系人到Google表格
Code
Filter
Form Trigger
+6
16 节点Trung Tran
潜在客户开发
工作流信息
难度等级
高级
节点数量20
分类2
节点类型10
作者
Trung Tran
@trungtranEmpowering small and medium businesses with smart automation and practical AI, no big tech team required. Reach out: lets@automatewith.me
外部链接
在 n8n.io 查看 →
分享此工作流