Workflow 02 / Finance

Invoice OCR to Google Sheets

Supplier PDFs read, checked and filed. Doubtful ones go to a human review tab.

Trigger
New PDF in a Drive folder
Size
11 nodes, 4 credentials
Typical build
8 working days
Tools
n8n, Google Drive, OpenAI API, Google Sheets, Slack

Example scenario: Logistics company, about 900 supplier invoices a month, one finance team

The problem

Finance typed 900 supplier PDFs a month into the accounts-payable ledger. Each invoice took four to six minutes, typos caused duplicate payments twice a quarter and month-end close slipped by three days.

What the workflow does

The solution

n8n watches a shared Drive folder. Each new PDF is downloaded, its text is extracted and an LLM returns ten structured fields. A validation step checks the mandatory fields, that every amount is a real number, that net plus VAT equals the total and that confidence is at least 0.85. A lookup then checks whether the same supplier and invoice number are already in the ledger. Clean, new invoices go straight to the ledger; anything doubtful or duplicated lands in a review tab with the reason and pings the AP channel.

The flow

Drawn from the real JSON

Node names, order and branches are read from the exported file at build time, so this diagram can never drift from what n8n will show you. Dashed lines are connections; amber ones leave an IF, a Switch or an error output.

Download n8n JSON
TriggerAI stepApp actionTransformBranch
11 nodes

Scroll sideways to see all branches

truefalse1. Drive: New Invoice PDFDrive01New Invoice PDF2. Drive: DownloadDrive02Download3. Extract PDF TextExtract03Extract PDF Text4. LLM: Extract FieldsLLM04Extract Fields5. Parse InvoiceCode05Parse Invoice6. Sheets: Find DuplicateSheets06Find Duplicate7. IF: Valid & NewIF07Valid & New8. Sheets: AP LedgerSheets08AP Ledger9. Sheets: Review QueueSheets09Review Queue10. Drive: Move to ProcessedDrive10Move to Processed11. Slack: #ap-reviewSlack11#ap-review

Node by node

#NodeTypeWhat it does
01Drive: New Invoice PDFTriggerWatches the inbox folder for new PDFs, every 5 minutes
02Drive: DownloadApp actionDownloads the file as binary
03Extract PDF TextTransformExtracts the text layer of the PDF
04LLM: Extract FieldsAI stepChat completion (gpt-4o-mini), JSON-only output
05Parse InvoiceTransformParses the LLM answer and checks mandatory fields, finite amounts and the VAT balance.
06Sheets: Find DuplicateApp actionLooks up an existing row in the "Invoices" tab
07IF: Valid & NewBranchTrue if valid && !json['Invoice #'] is true
08Sheets: AP LedgerApp actionAppends a row to the "Invoices" tab
09Sheets: Review QueueApp actionAppends a row to the "Needs review" tab
10Drive: Move to ProcessedApp actionMoves the PDF to the Processed folder
11Slack: #ap-reviewApp actionPosts a message to #ap-review

How a run goes

  1. Google Drive trigger polls the AP inbox folder every 5 minutes for new PDFs.

  2. The file is downloaded as binary and the PDF text is extracted in n8n.

  3. The LLM returns supplier, invoice number, dates, currency, net, VAT, total, PO and a confidence value.

  4. A Code node parses the JSON and lists every issue: missing fields, non-numeric amounts, totals that do not balance, low confidence.

  5. Google Sheets looks up the supplier and invoice number in the ledger to catch duplicates.

  6. IF valid and new: append to the AP ledger and move the PDF to "Processed".

  7. Otherwise: append to the "Needs review" tab with the reason and post the PDF link to Slack.

Tools and credentials

Credentials are referenced by name inside the JSON. Create each one in n8n under Credentials, using these names, and the nodes connect automatically.

Credential nameWhat you need
Google Drive – FinanceGoogle OAuth client with the Drive API enabled
OpenAI – FlowforgeAPI key from platform.openai.com
Google Sheets – OpsGoogle OAuth client with the Sheets API enabled
Slack – Flowforge BotBot token with the chat:write scope

Setup in about 30 minutes

  1. Import the file. In n8n open Workflows, then Import from file, and pick invoice-ocr.json. The workflow arrives inactive.

  2. Create the 4 credentials listed above with exactly those names.

  3. Replace the placeholders with your own IDs:

    • REPLACE_WITH_INBOX_FOLDER_ID in “Drive: New Invoice PDF”
    • REPLACE_WITH_LEDGER_SHEET_ID in “Sheets: Find Duplicate”
    • REPLACE_WITH_LEDGER_SHEET_ID in “Sheets: AP Ledger”
    • REPLACE_WITH_LEDGER_SHEET_ID in “Sheets: Review Queue”
    • REPLACE_WITH_PROCESSED_FOLDER_ID in “Drive: Move to Processed”
  4. Adapt it to your business.

    • Create two Drive folders, Inbox and Processed, and paste their IDs into the trigger and the move node.
    • Create the ledger sheet with an "Invoices" tab and a "Needs review" tab; column headers must match the field names in the Sheets nodes. The duplicate lookup reads the "Supplier" and "Invoice #" columns of the Invoices tab.
    • Scanned PDFs have no text layer: add an OCR step (for example Google Vision) before "Extract PDF Text" if your suppliers send images.
    • Tune the 0.85 confidence limit in the "Parse Invoice" Code node after the first 50 invoices.
  5. Connect error reporting. Import error-reporter.json once, then open this workflow’s Settings and choose it as the Error workflow. Failed runs are posted to Slack and logged, with a link to retry.

  6. Test, then activate. Run the first node with sample data, check each output in the execution view, then switch the workflow to active. Keep the test run for your records.

Example figures for the scenario above, not guarantees

What this kind of build changes

900invoices a month handled without typing
96%straight-through, no human touch
70 hfinance time saved monthly
0duplicate payments, caught by the supplier and invoice number lookup

Use it, or have it built for you

The JSON is free to import and adapt. If you would rather have it wired to your own stack and tested on your data, a single flow like this is a fixed-price project.