8
n8n 中文网amn8n.com

发票分类器

高级

这是一个Invoice Processing, AI Summarization领域的自动化工作流,包含 18 个节点。主要使用 Switch, GoogleDrive, ManualTrigger, SplitInBatches, Agent 等节点。 使用GPT-4o在Google Drive中分类和自动整理发票

前置要求
  • Google Drive API 凭证
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "M4i2qOxJ3Us04fab",
  "meta": {
    "instanceId": "8443f10082278c46aa5cf3acf8ff0f70061a2c58bce76efac814b16290845177",
    "templateCredsSetupCompleted": true
  },
  "name": "发票分类器",
  "tags": [],
  "nodes": [
    {
      "id": "c3eb01ce-ad98-4c88-8426-f6ff738ec932",
      "name": "下载文件",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -1600,
        632
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.id }}"
        },
        "options": {},
        "operation": "download",
        "authentication": "oAuth2"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "gQtjXVGUgZru29qC",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "f4ae926e-f3a2-4471-84e8-5b9c37050d04",
      "name": "当点击\"执行工作流\"时",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -2048,
        632
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "bbf3ef7d-1a6e-44cc-b878-1c3a0c73535b",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -928,
        192
      ],
      "parameters": {
        "text": "={{ $json.text }}",
        "options": {
          "systemMessage": "You are a smart document classifier.\n\nYour task is to analyze the text content of an invoice and classify it into one of the following industries:\n- Retail\n- Manufacturing\n- EdTech\n\nRespond with the industry name at top: \"Retail\", \"Manufacturing\", or \"EdTech\"."
        },
        "promptType": "define"
      },
      "typeVersion": 2.1
    },
    {
      "id": "2a77af9f-32db-49c0-9655-308a2dc2d9c4",
      "name": "Azure OpenAI 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatAzureOpenAi",
      "position": [
        -832,
        416
      ],
      "parameters": {
        "model": "gpt-4o-mini",
        "options": {}
      },
      "credentials": {
        "azureOpenAiApi": {
          "id": "C3WzT18XqF8OdVM6",
          "name": "Azure Open AI account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "c10f4dbc-9378-426b-bf74-5873f4c9194d",
      "name": "遍历项目",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -1152,
        632
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "aedbda2e-2625-437a-a138-2ee019fad248",
      "name": "从文件提取",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        -1376,
        632
      ],
      "parameters": {
        "options": {},
        "operation": "pdf"
      },
      "typeVersion": 1
    },
    {
      "id": "6018cc36-6bb0-45c8-946f-77fc87beb52b",
      "name": "分支",
      "type": "n8n-nodes-base.switch",
      "position": [
        -528,
        176
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "bad389b5-d967-4f72-839d-9f099911c65a",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.output }}",
                    "rightValue": "Retail"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "aea4162d-2682-4147-9724-cb79f66fc4f5",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.output }}",
                    "rightValue": "Manufacturing"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "0af9f9aa-95d3-4982-9f52-a7b4d7d1749a",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.output }}",
                    "rightValue": "EdTech"
                  }
                ]
              }
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "11a50e6e-4bb3-41bc-9a3f-e5e12b898209",
      "name": "搜索文件和文件夹",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -1824,
        632
      ],
      "parameters": {
        "filter": {
          "folderId": {
            "__rl": true,
            "mode": "list",
            "value": "1CcHp9tPoC-f7-umMjLdUU-Y7GedKLQkx",
            "cachedResultUrl": "https://drive.google.com/drive/folders/1CcHp9tPoC-f7-umMjLdUU-Y7GedKLQkx",
            "cachedResultName": "Indore"
          }
        },
        "options": {},
        "resource": "fileFolder",
        "returnAll": true
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "gQtjXVGUgZru29qC",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "934c8224-4adb-491a-a696-f60292088eb0",
      "name": "制造业",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -304,
        488
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Download File').item.json.id }}"
        },
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "1-fmURc7hW1JcQCcP_lk4VxhkOk4GA00H",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1-fmURc7hW1JcQCcP_lk4VxhkOk4GA00H",
          "cachedResultName": "Manufacturing"
        },
        "operation": "move"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "gQtjXVGUgZru29qC",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "7db81eed-1d18-4af6-850e-9acc696b4f84",
      "name": "零售业",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -304,
        296
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Download File').item.json.id }}"
        },
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "13YZe1eYMQGXqR62n8aQIlYeSHE2HqpAv",
          "cachedResultUrl": "https://drive.google.com/drive/folders/13YZe1eYMQGXqR62n8aQIlYeSHE2HqpAv",
          "cachedResultName": "Retail"
        },
        "operation": "move"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "gQtjXVGUgZru29qC",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "c200afa0-87b3-4e81-8b72-3735e21c36c9",
      "name": "教育科技",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -304,
        680
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Download File').item.json.id }}"
        },
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "1H-JpO6eNDYGHT4G92-mB846NvaNu8P-1",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1H-JpO6eNDYGHT4G92-mB846NvaNu8P-1",
          "cachedResultName": "Edtech"
        },
        "operation": "move"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "gQtjXVGUgZru29qC",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "249fa33e-26e5-4668-b54f-e3ba5e10099d",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1968,
        800
      ],
      "parameters": {
        "width": 320,
        "height": 240,
        "content": "搜索文件和文件夹 (Google Drive)"
      },
      "typeVersion": 1
    },
    {
      "id": "d210bbff-936d-4216-afcd-6b2646fdb00a",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1600,
        800
      ],
      "parameters": {
        "color": 3,
        "height": 240,
        "content": "下载文件 (Google Drive)"
      },
      "typeVersion": 1
    },
    {
      "id": "88dd5e88-6673-480e-8005-27398846f504",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1552,
        400
      ],
      "parameters": {
        "color": 2,
        "width": 272,
        "height": 208,
        "content": "从文件提取 (从文件提取)"
      },
      "typeVersion": 1
    },
    {
      "id": "5c87b592-9143-4bfb-8f54-2f8a92fff83b",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1168,
        800
      ],
      "parameters": {
        "color": 5,
        "height": 240,
        "content": "遍历项目 (分批处理)"
      },
      "typeVersion": 1
    },
    {
      "id": "983aa05a-34b6-44db-bc1e-a2eaed231848",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1248,
        -16
      ],
      "parameters": {
        "color": 4,
        "width": 288,
        "height": 288,
        "content": "#AI代理 (LangChain代理)"
      },
      "typeVersion": 1
    },
    {
      "id": "90a266fe-ceda-4e79-b4b0-a772ee0234c7",
      "name": "便利贴5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -752,
        528
      ],
      "parameters": {
        "color": 7,
        "width": 288,
        "height": 240,
        "content": "Azure OpenAI聊天模型 (语言模型)"
      },
      "typeVersion": 1
    },
    {
      "id": "f9daf053-6ab0-43b2-8878-c07829c17b52",
      "name": "便签6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -608,
        -144
      ],
      "parameters": {
        "color": 6,
        "width": 288,
        "height": 304,
        "content": "分支 (条件逻辑)"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "8c3ea819-3a44-4c6e-9b54-a25edfc40fbe",
  "connections": {
    "EdTech": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Retail": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "Retail",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Manufacturing",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "EdTech",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download File": {
      "main": [
        [
          {
            "node": "Extract from File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Manufacturing": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from File": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Azure OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Search files and folders": {
      "main": [
        [
          {
            "node": "Download File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "Search files and folders",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 发票处理, AI 摘要总结

需要付费吗?

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

工作流信息
难度等级
高级
节点数量18
分类2
节点类型8
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

作者
Rahul Joshi

Rahul Joshi

@rahul08

Rahul Joshi is a seasoned technology leader specializing in the n8n automation tool and AI-driven workflow automation. With deep expertise in building open-source workflow automation and self-hosted automation platforms, he helps organizations eliminate manual processes through intelligent n8n ai agent automation solutions.

外部链接
在 n8n.io 查看

分享此工作流