Automate Invoice Processing with OCR, GPT-4 & Salesforce Opportunity Creation — n8n Workflow

Mittel Komplexität Auslöser11 Knoten🏷️ Invoice Processing👁 4 Aufrufevon Le Nguyen

Übersicht

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**

Verwendete Knoten

HTTP RequestGoogle DriveMicrosoft OneDriveSalesforceCodeOpenAI

Workflow-Vorschau

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

So funktioniert es

  1. 1

    Auslöser

    Der Workflow startet mit einem auslöser-Auslöser.

  2. 2

    Verarbeitung

    Die Daten fließen durch 11 Knoten, connecting code, extractfromfile, googledrive.

  3. 3

    Ausgabe

    Der Workflow schließt seine Automatisierung ab und liefert das Ergebnis an das konfigurierte Ziel.

Knotendetails (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

So importieren Sie diesen Workflow

  1. 1Klicken Sie rechts auf die Schaltfläche JSON herunterladen, um die Workflow-Datei zu speichern.
  2. 2Öffnen Sie Ihre n8n-Instanz. Gehen Sie zu Workflows → Neu → Aus Datei importieren.
  3. 3Wählen Sie die heruntergeladene Datei automate-invoice-processing-with-ocr-gpt-4-salesforce-opportunity-creation und klicken Sie auf Importieren.
  4. 4Richten Sie Anmeldedaten für jeden Dienstknoten ein (API-Schlüssel, OAuth usw.).
  5. 5Klicken Sie auf Workflow testen, um zu überprüfen, ob alles funktioniert, und aktivieren Sie es dann.

Oder direkt in n8n → Aus JSON importieren einfügen:

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

Integrationen

codeextractfromfilegoogledrivegoogledrivetriggerhttprequestmicrosoftonedriveopenaisalesforce

Diesen Workflow holen

Herunterladen und mit einem Klick importieren

JSON herunterladenAuf n8n.io ansehen
Knoten11
Komplexitätmedium
Auslösertrigger
Aufrufe4

Erstellt von

Le Nguyen

Le Nguyen

@leeseifer

Tags

codeextractfromfilegoogledrivegoogledrivetriggerhttprequestmicrosoftonedriveopenaisalesforce

Neu bei n8n?

n8n ist ein kostenloses Open-Source-Workflow-Automatisierungstool. Selbst hosten oder die Cloud-Version nutzen.

n8n kostenlos holen →

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