8
n8n 中文网amn8n.com

AI发票助手

中级

这是一个Invoice Processing, Multimodal AI领域的自动化工作流,包含 13 个节点。主要使用 Set, Gmail, Filter, GoogleSheets, ManualTrigger 等节点。 AI发票代理

前置要求
  • Google 账号和 Gmail API 凭证
  • Google Sheets API 凭证
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "eOgIRm4wzZec7jkD",
  "meta": {
    "instanceId": "061ca141d020a6e1355b8c7fe05f92a699e37e92079ad2e150a506ee8bbe9e11",
    "templateCredsSetupCompleted": true
  },
  "name": "AI 发票助手",
  "tags": [],
  "nodes": [
    {
      "id": "a3c4602c-fde7-4fed-9f6b-71a08a51f9ce",
      "name": "当点击\"执行工作流\"时",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -2944,
        448
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "89a82cb6-c972-4a06-9f7e-29e3f322ad89",
      "name": "Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -2752,
        448
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1d7CWcM_Ge6s2iaoGXOsxykLQFsDa_iyEFyP0qxJ9Qbs/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1d7CWcM_Ge6s2iaoGXOsxykLQFsDa_iyEFyP0qxJ9Qbs",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1d7CWcM_Ge6s2iaoGXOsxykLQFsDa_iyEFyP0qxJ9Qbs/edit?usp=drivesdk",
          "cachedResultName": "Client Invoices"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "95b66133-04fe-42fd-b906-8e742efa1b27",
      "name": "过滤器",
      "type": "n8n-nodes-base.filter",
      "position": [
        -2528,
        448
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "afe0ae0a-9f88-4605-b064-223db0c34522",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.Status }}",
              "rightValue": "Pending"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "2ab041df-a151-4eb7-b38d-b75b4c76fa91",
      "name": "获取简报",
      "type": "n8n-nodes-base.set",
      "position": [
        -2304,
        448
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "eae2796d-a5bb-4bc1-a4f6-26abc64e2185",
              "name": "\tInvoice ID",
              "type": "string",
              "value": "={{ $json['\tInvoice ID'] }}"
            },
            {
              "id": "72f18799-575f-4c4c-9f67-02a9dc9a45ab",
              "name": "Client Name",
              "type": "string",
              "value": "={{ $json['Client Name'] }}"
            },
            {
              "id": "66338ec2-a287-4319-b0a2-89c6e2915d07",
              "name": "Client Address",
              "type": "string",
              "value": "={{ $json['Client Address'] }}"
            },
            {
              "id": "9e9dceea-5fe0-4be8-8ddb-826b9e569dea",
              "name": "Project Name\t",
              "type": "string",
              "value": "={{ $json['Project Name\t'] }}"
            },
            {
              "id": "82d90cd2-1075-41d0-a251-242498884069",
              "name": "Amount (USD)",
              "type": "number",
              "value": "={{ $json['Amount (USD)'] }}"
            },
            {
              "id": "b84b6393-bfc2-494a-b8e1-3f918734088f",
              "name": "Invoice Date",
              "type": "string",
              "value": "={{ $now.format('yyyy-MM-dd') }}"
            },
            {
              "id": "889bc329-2802-4670-8d0e-88e97f25be65",
              "name": "Due Date",
              "type": "string",
              "value": "={{ $now.plus({day: 7}).format('yyyy-MM-dd') }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "bab29942-290c-43f0-940f-0a6a2553ba97",
      "name": "遍历项目",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -2080,
        448
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "fe9ce649-2590-4569-879e-1933f32ddf57",
      "name": "AI 代理",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -1760,
        208
      ],
      "parameters": {
        "text": "=You are a professional invoicing assistant for a creative agency called \"Upward Engine\". Generate a polite, professional email to a client who has received an invoice as a PDF attachment. Include the client name, project name, invoice amount, invoice ID, invoice date, and due date.\n\nThe tone should be friendly but business-oriented, and the purpose is to inform the client that the invoice is attached, and to kindly request timely payment. End with a thank-you message and sign off as \"Upward Engine Team\".\n\nHere is the invoice data:\n- Client name: {{ $json['Client Name'] }}\n- Project Name: {{ $json['Project Name\t'] }}\n- Invoice Amount: {{ $json['Amount (USD)'] }}\n- Invoice ID: {{ $json['\tInvoice ID'] }}\n- Invoice Date: {{ $json['Invoice Date'] }}\n- Due Date: {{ $json['Due Date'] }}",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 2
    },
    {
      "id": "f6d889e9-5bf0-48a7-8562-bd45ced618fc",
      "name": "信息提取器",
      "type": "@n8n/n8n-nodes-langchain.informationExtractor",
      "position": [
        -1424,
        208
      ],
      "parameters": {
        "text": "={{ $json.output }}",
        "options": {},
        "attributes": {
          "attributes": [
            {
              "name": "email subject",
              "description": "subject of the mail"
            },
            {
              "name": "email body",
              "description": "email body without the subject"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "012075eb-1e97-4d49-9b36-2a2e22ccdbdc",
      "name": "CraftMyPDF",
      "type": "n8n-nodes-craftmypdf.craftMyPdf",
      "position": [
        -1072,
        352
      ],
      "parameters": {
        "data": "={\n\"company_name\": \"Upward Engine\",\n    \"company_address\": \"Silicon Valey, USA\",\n    \"company_email\": \"admin@upwardengine.com\",\n    \"bill_to\": \"{{ $('Edit Fields').item.json['Client Name'] }}\",\n    \"bill_to_address\": \"{{ $('Edit Fields').item.json['Client Address'] }}\",\n    \"invoice_no\": \"{{ $('Edit Fields').item.json['\tInvoice ID'] }}\",\n    \"invoice_date\": \"{{ $('Edit Fields').item.json['Invoice Date'] }}\",\n    \"invoice_due_date\": \"{{ $('Edit Fields').item.json['Due Date'] }}\",\n    \"footer\": \"Thank you for working with Upward Engine\",\n    \"balance\": \"{{ $('Edit Fields').item.json['Amount (USD)'] }}\",\n    \"project_name\": \"{{ $('Edit Fields').item.json['Project Name\t'] }}\",\n    \"currency\": \"$\"\n\n}",
        "resource": "pdf",
        "templateId": "YOUR_TEMPLATE_ID",
        "export_type": "file"
      },
      "typeVersion": 1
    },
    {
      "id": "8f9cbcf4-0162-41ba-8934-3a2490e213bb",
      "name": "Gmail",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -848,
        352
      ],
      "webhookId": "85f9cc55-4019-4f9f-a7b8-852ba7f38d1b",
      "parameters": {
        "sendTo": "={{ $('Google Sheets').item.json['Client Email'] }}",
        "message": "={{ $('Information Extractor').item.json.output['email body'] }}",
        "options": {
          "attachmentsUi": {
            "attachmentsBinary": [
              {
                "property": "output.pdf"
              }
            ]
          },
          "appendAttribution": false
        },
        "subject": "={{ $('Information Extractor').item.json.output['email subject'] }}",
        "emailType": "text"
      },
      "typeVersion": 2.1
    },
    {
      "id": "d2249aba-b9ef-451b-9646-e529836c38aa",
      "name": "Google Sheets1",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -608,
        448
      ],
      "parameters": {
        "columns": {
          "value": {
            "Status": "Completed",
            "Due Date": "={{ $('Edit Fields').item.json['Due Date'] }}",
            "\tInvoice ID": "={{ $('Edit Fields').item.json['\tInvoice ID'] }}",
            "Invoice Date": "={{ $('Edit Fields').item.json['Invoice Date'] }}"
          },
          "schema": [
            {
              "id": "\tInvoice ID",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "\tInvoice ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Client Name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Client Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Client Email",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Client Email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Client Address",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Client Address",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Project Name\t",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Project Name\t",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Amount (USD)",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Amount (USD)",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Status",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Status",
              "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
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "\tInvoice ID"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1d7CWcM_Ge6s2iaoGXOsxykLQFsDa_iyEFyP0qxJ9Qbs/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1d7CWcM_Ge6s2iaoGXOsxykLQFsDa_iyEFyP0qxJ9Qbs",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1d7CWcM_Ge6s2iaoGXOsxykLQFsDa_iyEFyP0qxJ9Qbs/edit?usp=drivesdk",
          "cachedResultName": "Client Invoices"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "499dbf0b-3c1a-4a86-930e-d792834635d2",
      "name": "GPT - 4.1 mini",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -1584,
        480
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "YmJZYHbn92LbB3C0",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "81872408-4ad6-4bf7-8f45-aecfd9dadddd",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -4000,
        -320
      ],
      "parameters": {
        "color": 2,
        "width": 912,
        "height": 1152,
        "content": "✅ 确保您的 n8n 中已安装 **CraftMyPDF** 节点,否则会显示错误。如果首次未显示 **CraftMyPDF** 节点,请先安装,然后删除整个工作流并重新使用/重新上传工作流:"
      },
      "typeVersion": 1
    },
    {
      "id": "a036c3db-df20-49a6-a42d-93559a8f245a",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2992,
        -304
      ],
      "parameters": {
        "color": 2,
        "width": 480,
        "height": 448,
        "content": "## 从这里开始:分步 YouTube 教程 :star:"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "71a433b1-d1c0-432b-942d-a7c45cf021e4",
  "connections": {
    "Gmail": {
      "main": [
        [
          {
            "node": "Google Sheets1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Information Extractor",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "CraftMyPDF": {
      "main": [
        [
          {
            "node": "Gmail",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets": {
      "main": [
        [
          {
            "node": "Filter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GPT - 4.1 mini": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "Information Extractor",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets1": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Information Extractor": {
      "main": [
        [
          {
            "node": "CraftMyPDF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

中级 - 发票处理, 多模态 AI

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
中级
节点数量13
分类2
节点类型11
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

外部链接
在 n8n.io 查看

分享此工作流