CORTEXFLOW · FREE FOREVER

Automation

Invoice Extraction & Reconciliation Pipeline

↓ Download workflow JSON

Import in n8n: Workflows → ⋯ → Import from file, then add your credentials. Free download with a free account.

How it works

  1. Gmail Trigger: Invoice Email — fires on new messages whose subject contains “invoice” and that have an attachment.
  2. Gmail: Download Attachment — downloads the invoice attachment from the email.
  3. OpenAI: Extract Invoice Data — reads the attachment and extracts the vendor name, amount, date, and invoice number as JSON.
  4. Set: Normalize Fields — cleans the extracted values into consistent fields and stamps the row status = pending.
  5. Google Sheets: Log Invoice — appends a row (date, vendor, amount, invoice number, status) to your spreadsheet.
  6. IF: Amount > 1000 — routes invoices over your approval threshold to a human gate; smaller invoices skip it.
  7. Gmail: Approval Request — emails finance the invoice details plus an approval link; the workflow pauses until finance responds.
  8. Wait: Finance Approval — finance opens the approval link and submits Approve or Reject on the form.
  9. IF: Finance Approved? — routes approved invoices to “reconciled” and rejected ones to “rejected”.
  10. Google Sheets: Mark Reconciled — updates the row’s status to reconciled for approved invoices.
  11. Google Sheets: Mark Rejected — updates the row’s status to rejected when finance rejects it.
  12. Google Sheets: Mark Auto-Reconciled — for invoices under the threshold, updates the row’s status to auto-reconciled.
  13. Slack: Notify — posts a message confirming the invoice was auto-reconciled without human review.

Set up steps

You’ll need:

  • n8n (self-hosted or cloud)
  • A Gmail account — connect via OAuth in n8n
  • An OpenAI account — get an API key at platform.openai.com → API keys
  • A Google account with a spreadsheet — connect via OAuth in n8n
  • A Slack workspace — connect via OAuth in n8n
  1. Download the workflow JSON using the download button on this page.
  2. In n8n, go to Workflows → ⋯ → Import from file and select the JSON.
  3. Create your Gmail credential — in n8n go to Credentials → New → Gmail OAuth2, complete the OAuth flow, save. Open Gmail Trigger: Invoice Email, Gmail: Download Attachment, and Gmail: Approval Request, and select the credential.
  4. Create your OpenAI credential — in n8n go to Credentials → New → OpenAI, paste your API key, save. Open OpenAI: Extract Invoice Data and select your credential.
  5. Create your Google Sheets credential — in n8n go to Credentials → New → Google Sheets OAuth2, complete the OAuth flow, save. Open the three Google Sheets nodes, select the credential, pick your spreadsheet, and set the sheet name (the template uses columns: date, vendor, amount, invoice_number, status — create these as the header row).
  6. Create your Slack credential — in n8n go to Credentials → New → Slack OAuth2, complete the OAuth flow, save. Open Slack: Notify, select the credential, and set the channel (e.g., #finance).
  7. Set your finance email — open Gmail: Approval Request and change the recipient to your finance team’s email address.
  8. Set your approval threshold — open IF: Amount > 1000 and change 1000 to whatever amount should require human approval.
  9. Activate the workflow (toggle, top-right), then send yourself a test invoice email.

The approval email contains a link built from {{$execution.resumeUrl}}. Clicking it opens an Approve/Reject form — submitting the form resumes the workflow exactly where it paused.

Customize it

  • Change the email filter — open Gmail Trigger: Invoice Email and edit the q filter (e.g., from:[email protected] has:attachment) to match how your invoices arrive.
  • Handle PDFs — if your invoices arrive as PDFs, add an Extract from File node between Gmail: Download Attachment and OpenAI: Extract Invoice Data so the AI reads the PDF text.
  • Change the threshold currency — the template compares a plain number; make sure the amount the AI extracts is in your base currency, or add a conversion step in Set: Normalize Fields.
  • Add a receipt for rejected invoices — connect a Gmail send node after Google Sheets: Mark Rejected to notify the vendor.

Workflow nodes

This workflow is built from 13 nodes. Here's what each one does:

#NodeTypeWhat it does
1 Gmail Trigger: Invoice Email Gmail Trigger Starts the workflow when a new email arrives in Gmail.
2 Gmail: Download Attachment Gmail Sends or reads email through your Gmail account.
3 OpenAI: Extract Invoice Data OpenAI Sends a prompt to OpenAI and returns the AI's answer.
4 Set: Normalize Fields Set Holds editable configuration values — fill in your own settings here before activating.
5 Google Sheets: Log Invoice Google Sheets Reads from or writes to a Google Sheet — this workflow's log and state store.
6 IF: Amount > 1000 IF Splits the flow into branches based on a condition.
7 Gmail: Approval Request Gmail Sends or reads email through your Gmail account.
8 Wait: Finance Approval Wait Pauses the workflow until a condition or time is met.
9 IF: Finance Approved? IF Splits the flow into branches based on a condition.
10 Google Sheets: Mark Reconciled Google Sheets Reads from or writes to a Google Sheet — this workflow's log and state store.
11 Google Sheets: Mark Rejected Google Sheets Reads from or writes to a Google Sheet — this workflow's log and state store.
12 Google Sheets: Mark Auto-Reconciled Google Sheets Reads from or writes to a Google Sheet — this workflow's log and state store.
13 Slack: Notify Slack Posts messages or reads data in Slack.

Setup instructions

1. Add your credentials

In n8n go to Credentials → New, create each credential below, then open the named node and select it:

NodeCredential to add
Gmail Trigger: Invoice Email Gmail OAuth2
Gmail: Download Attachment Gmail OAuth2
OpenAI: Extract Invoice Data OpenAI API
Google Sheets: Log Invoice Google Sheets OAuth2
Gmail: Approval Request Gmail OAuth2
Google Sheets: Mark Reconciled Google Sheets OAuth2
Google Sheets: Mark Rejected Google Sheets OAuth2
Google Sheets: Mark Auto-Reconciled Google Sheets OAuth2
Slack: Notify Slack OAuth2

How this workflow starts

  • Gmail Trigger: Fires automatically on its event — activate the workflow and connect the service.

Use cases

Vendor invoices arrive as email attachments and die in inboxes — or get entered by hand, slowly and with typos. This template turns the inbox into a pipeline: Gmail Trigger: Invoice Email fires on messages whose subject contains "invoice" with an attachment, Gmail: Download Attachment grabs the file, and OpenAI: Extract Invoice Data reads it into structured JSON — vendor name, amount, date, invoice number. Set: Normalize Fields cleans the values and stamps the row status = pending, then Google Sheets: Log Invoice appends it to your spreadsheet. The IF: Amount > 1000 gate routes big invoices to a human: Gmail: Approval Request emails finance the details plus an approval link, Wait: Finance Approval pauses until the Approve/Reject form is submitted, and the row becomes reconciled or rejected. Small invoices skip the gate entirely and land as auto-reconciled, with a Slack: Notify post to your finance channel confirming the auto-reconciliation.

Small business owner drowning in vendor bills

A 10-person company gets 40–60 vendor invoices a month — software subscriptions, suppliers, contractors — and the owner currently forwards them to the accountant in batches. With this pipeline, every invoice email is extracted and logged within minutes of arrival: the spreadsheet becomes the live payables list with vendor, amount, date, and invoice number in clean columns. Anything under your threshold (default $1,000, adjustable in IF: Amount > 1000) reconciles itself; anything over pauses for your approval via the email link, which opens an Approve/Reject form and resumes the workflow the moment you submit. Practical tip: send a test invoice email right after activation and check the extracted fields — one test catches attachment-format quirks before real money flows through.

Restaurant group with invoices from many locations

Three locations mean invoices from produce suppliers, linen services, and maintenance vendors arriving in one shared inbox — the classic pile nobody owns. The Gmail trigger's q filter can be narrowed per workflow (e.g. from:[email protected] has:attachment), so you can run one pipeline per location or per vendor category, each logging to its own sheet tab. The extraction handles varied layouts, though the guide notes adding an Extract from File node before OpenAI: Extract Invoice Data if your invoices arrive as PDFs. The approval gate is the control that matters in food businesses with tight margins: the manager approves anything over the threshold from their phone via the email link. Tip: normalize currency in Set: Normalize Fields if any vendors bill in another currency, so the >1000 comparison always runs in your base currency.

Startup finance lead building controls from day one

A startup's first finance hire needs audit trails, not spreadsheets-by-email. This workflow gives you both: every invoice logged with a status trail — pending → auto-reconciled / reconciled / rejected — and the Slack notification to #finance announcing each auto-reconciliation keeps the team informed without meetings. The human gate on large invoices is your segregation of duties: the person who received the invoice isn't the person who approved it. Because approval happens through the $execution.resumeUrl link, there's a timestamped record of who approved what and when. Practical variation: connect a Gmail send node after Google Sheets: Mark Rejected to notify the vendor automatically — the rejection reason can ride along, closing the loop instead of leaving the vendor guessing.

Ecommerce brand reconciling supplier and ad invoices

An ecommerce brand's payables are supplier invoices, freight bills, and agency retainers — high volume, mixed formats. The AI extraction shines here because supplier invoices rarely share a layout: the model reads vendor, amount, date, and invoice number regardless of template, which is exactly what breaks brittle template-based parsers. Set the approval threshold to match your delegation policy — maybe $500 for a lean team — and everything above it waits for the founder's tap. The sheet becomes the month-end close input: filter by reconciled and auto-reconciled for the booked payables, investigate the pending stragglers. Tip: review the extracted amounts for your first 20 invoices against the PDFs; the one field AI occasionally misreads is the total when invoices show subtotals and tax prominently — a quick spot-check habit beats a painful month-end surprise.

Agency owner who wants payables off their plate

Agency owners often approve every invoice personally because they don't trust the process — which doesn't scale past a dozen vendors. This template is the trustable middle: small recurring invoices (hosting, SaaS seats, freelancers under threshold) reconcile automatically with a Slack paper trail, and only the big ones interrupt you. The approval email contains the invoice details inline, so the decision takes 20 seconds from your phone. Practical tip: keep the finance approval email recipient as a distribution list, not one person — approvals shouldn't stall when someone's on leave.

← All templates