Reads PDF invoices and documents that arrive by email, pulls out the fields you choose with OpenAI, checks the totals, and adds a row to a Google Sheet. Rows it is unsure about are marked CHECK for a person to review.
What it does
- Email trigger (IMAP): watches a mailbox, such as invoices@, and downloads attachments
- Has PDF?: skips emails without a PDF in the first attachment
- Extract PDF text: turns the PDF into text
- Extract fields: asks OpenAI for supplier, invoice number, dates, subtotal, tax, total and currency
- Check and flag: marks the row CHECK when confidence is low or subtotal plus tax does not equal the total
- Append to sheet: adds the row to the Documents tab
What you need
- An n8n instance
- An IMAP mailbox the documents arrive in
- An OpenAI API key
- A Google account for Sheets
Setup
- Import
workflow.jsoninto n8n. - Add your IMAP credential to New email (IMAP).
- Create a Header Auth credential for OpenAI (name
Authorization, valueBearer <your key>) and select it on Extract fields (OpenAI). - Create a Google Sheet with a tab named
Documentsand headers: received, from, subject, file, supplier, invoice_number, invoice_date, due_date, subtotal, tax, total, currency, review. - Paste the sheet URL into Append to sheet and add your Google credential.
- Send a test email with a PDF invoice attached, then activate.
Make it yours
- Change the field list in Build extraction request for orders, applications or statements.
- Scanned documents need an OCR step before extraction.
- Send rows marked CHECK to Slack or email for review, or post approved rows to QuickBooks or Xero.
Notes
- No credentials are included. Every value marked
REPLACE_MEorREPLACE_WITH_...must be set before you activate the workflow. - Test with sample data first. Check each step's output in n8n before you point real traffic at it.
Importing it
In n8n, open a new workflow, choose the … menu at the top right, then Import from file and pick the downloaded workflow.json. You can also open the file, copy everything and paste it onto an empty canvas. New to n8n? Start with what n8n is and how templates work.
Background reading: Document processing.
Want it set up and running in your own n8n? Send us a short brief.
Pushbuild · Automate your business with Pushbuild: pushbuild.com/