Automate Invoice Processing with OCR, GPT-4 & Salesforce Opportunity Creation — n8n 工作流

复杂度 触发器11 个节点🏷️ Invoice Processing👁 4 次查看作者:Le Nguyen

概览

PDF Invoice Extractor (AI)

End-to-end pipeline: Watch Drive ➜ Download PDF ➜ OCR text ➜ AI normalize to JSON ➜ Upsert Buyer (Account) ➜ Create Opportunity ➜ Map Products ➜ Create OLI via Composite API ➜ Archive to OneDrive.

Node by node (what it does & key setup)

  1. Google Drive Trigger Purpose**: Fire when a new file appears in a specific Google Drive folder. Key settings**: Event: fileCreated Folder ID: google drive folder id Polling: everyMinute Creds: googleDriveOAuth2Api Output**

使用的节点

HTTP RequestGoogle DriveMicrosoft OneDriveSalesforceCodeOpenAI

工作流预览

PDF Invoice Extractor (AI) to Salesforce Oppo
What it does:
Watch a Drive folder → OCR PDF → extract invoices (JSON
1) Google Drive Trigger
- Op: fileCreated in folder (ID)
- Poll: every minute
- Creds: Google Drive OAuth2
- Note: Ensure access/Shared Drive rights
2) Download from Drive
- Op: download by {{$json.id}}
- Binary key: data (default)
- Creds: Google Drive OAuth2
3) Extract from File
- Op: pdf (enable OCR for scans)
- Output: {{$json.text}}
4) Message a Model (JSON)
- Node: @n8n/n8n-nodes-langchain.openAi
- Model: gpt-4.1 (or gpt-4.1-mini)
- Prompt: strict schema; return only JSON array
- jsonOutput: true
- Output path (first item
5) Salesforce: Upsert Account (Buyer)
- Node: salesforce (account upsert)
- External Id: tax_id__c
- externalIdValue: ={{ $json.message.content.buyer.tax_
- name: ={{ $json.message.content.buy
6) Salesforce: Create Opportunity
- Node: salesforce (resource: opportunity)
- name: ={{ $('Message a model').item.json.message.cont
- closeDate: ={{ $('Message a model').item.js
7) Code: Build SOQL (PricebookEntry)
- Node: Code (JS)
- Purpose: collect ProductCodes from LLM products → bui
- Output: { soql, codes }
8) Salesforce: Query PricebookEntries
- Node: salesforce (search)
- query: ={{ $json.soql }}
9) Code: Build OLI Payloads
- Node: Code (JS)
- Inputs:
- OpportunityId: ={{ $('Create an opportunity').first
- Lines: ={{ $('Message a model').first().json.messag
10) HTTP Request: Create Opportunity Line Ite
- Method: POST
- URL: https://<your-instance>.my.salesforce.com/servic
- Auth: salesforceOAuth2Api
- Body (JSON): ={{
11) Upload to OneDrive
- Op: upload
- Name: ={{ $json.name }}
- Parent Folder ID: (set)
- Binary: from step 2
- Creds: OneDrive OAuth2
E
Extract from File
G
Google Drive Trigger
Message a model
Download File From Google
Update File to One Drive
Create an opportunity
Create or update an acco…
Build SOQL
Query PricebookEntries
Code in JavaScript
Create Opportunity Line …
11 nodes10 edges

工作原理

  1. 1

    触发器

    工作流由 触发器 触发器启动。

  2. 2

    处理

    数据流经 11 个节点, connecting code, extractfromfile, googledrive。

  3. 3

    输出

    工作流完成自动化并将结果发送到配置的目标。

节点详情 (11)

HT

HTTP Request

httpRequest

#1
GO

Google Drive

googleDrive

#2
MI

Microsoft OneDrive

microsoftOneDrive

#3
SA

Salesforce

salesforce

#4
CO

Code

code

#5
OP

OpenAI

n8n-nodes-langchain.openAi

#6

如何导入此工作流

  1. 1点击右侧 下载 JSON 按钮保存工作流文件。
  2. 2打开你的 n8n 实例,依次点击 工作流 → 新建 → 从文件导入
  3. 3选择下载的 automate-invoice-processing-with-ocr-gpt-4-salesforce-opportunity-creation 文件并点击导入。
  4. 4为每个服务节点配置 凭证(API 密钥、OAuth 等)。
  5. 5点击 测试工作流 验证一切正常,然后激活它。

或直接在 n8n → 从 JSON 导入 中粘贴:

{ "name": "Automate Invoice Processing with OCR, GPT-4 & Salesforce Opportunity Creation", "nodes": [...], ...}

集成

codeextractfromfilegoogledrivegoogledrivetriggerhttprequestmicrosoftonedriveopenaisalesforce

获取此工作流

一键下载并导入

下载 JSON在 n8n.io 上查看
节点11
复杂度medium
触发器trigger
查看次数4

创建者

Le Nguyen

Le Nguyen

@leeseifer

标签

codeextractfromfilegoogledrivegoogledrivetriggerhttprequestmicrosoftonedriveopenaisalesforce

n8n 新手?

n8n 是一款免费开源的工作流自动化工具,支持自托管或使用云版本。

免费获取 n8n →

Related Invoice Processing Workflows

COCOEMEX+5
medium

Automate Custom QuickBooks Invoice PDFs & Email with n8n

Standard accounting templates often fail to reflect a premium brand identity. This sophisticated n8n workflow bridges the gap between financial record-keeping and professional client presentation. By moving beyond the native limitations of QuickBooks Online, this automation enables businesses to generate high-end, multi-page PDF invoices that align perfectly with their corporate styling. The process begins the moment a new invoice is generated in QuickBooks, triggering a webhook that captures real-time billing data. The workflow then utilizes advanced HTML-to-File conversion and custom Code nodes to structure data into a polished, branded layout. It handles complex logic such as line-item merging and multi-page formatting automatically. Once the document is rendered, the system bypasses generic 'no-reply' senders by routing the finalized PDF through your preferred email provider. This ensures a seamless, white-labeled experience for your clients while eliminating the manual overhead of exporting, styling, and attaching files. Ideal for agencies and service providers, this flow guarantees that your most frequent touchpoint—the bill—is as professional as your work. **Common Use Cases:** - High-end creative agencies requiring bespoke, white-labeled billing documents for premium clients. - Automated recurring subscription billing where custom tax disclosures or localized branding are required. - Service-based businesses needing to attach dynamic project reports or terms of service directly to QuickBooks invoices.

🔗 Webhook·12 nodes