Blog

How to Extract Data from Invoice PDFs in Email Automatically (Accounts Payable Workflow)

Tutorial

ยท

Quick answer: To extract data from invoice PDFs in email automatically, forward your accounts inbox to a BuildShip Email Trigger, convert each PDF attachment to text with the File to Markdown tool (it uses OCR when needed), pull out supplier, invoice number, dates and totals with an AI extract node, and check the result against your ledger and purchase orders in Google Sheets. Log a row with a status of matched, duplicate or needs review, and send anything unusual to a named approver in Slack. The workflow never pays or approves an invoice. One thing to test first is exactly how the emailโ€™s attachment reaches the File to Markdown step.

An emailed invoice PDF is read into structured fields, checked for duplicates and purchase order matches and logged, with unusual ones sent to an approver

Invoices arrive as PDFs in a shared inbox. Whoever has time retypes them into a spreadsheet, and the numbers go wrong in the usual ways: a digit swapped, a supplier spelled two different ways, the same invoice entered twice because it was emailed twice.

The retyping is slow, but it isnโ€™t the real risk. The real risk is the checking that comes after it: is this a duplicate, does it match a purchase order, is the total within what we agreed? That is the part that matters, and it is also the part that gets skipped when the month is closing and everyone is tired.

A workflow can do the typing and the first pass of checking, and hand the judgement to a person. That is the right division of labour.

What the workflow should decide, and what it shouldnโ€™t

It should be allowed to:

  • Read an invoice and write down what it says.

  • Notice that this supplier and invoice number already exist in your ledger.

  • Compare the total to the purchase order and see whether it is within the tolerance you set.

  • Put an honest status on the row.

It should never pay, approve or send anything to a supplier. Every mismatch, duplicate and unusually large invoice goes to a named approver, with the extracted values next to the original PDF so the person can check the modelโ€™s reading rather than trust it.

What you need

  • A BuildShip workspace. You can start a 7-day trial (a card is required).

  • A dedicated email address that your accounts inbox forwards invoices to (the Email Trigger provides one).

  • A Google Sheet with a ledger tab and a purchase-orders tab.

  • A Slack channel for approvals, such as #finance-approvals.

Build it step by step

1. Catch the email

The Email Trigger gives your workflow an address of its own. Forward invoices there. The docs describe the subject, body and attachments arriving in the request, which is where the PDF comes from. For another take on email-driven work, see how to trigger an AI agent when an email arrives.

2. Turn each PDF into text

Loop over the attachments and run each PDF through the File to Markdown tool from BuildShipโ€™s templates. It handles PDF, DOCX and CSV, and uses OCR when the file is a scan.

Here is the step Iโ€™d test first, before building anything else. The trigger passes attachments in the request, and how the file is handed to File to Markdown depends on what you get. Send one real invoice (a fake one, see below) and look at the payload in the run log. Adjust the hand-off from what you see, not from what you assumed.

3. Extract the fields

Use an AI extract node, such as LLM Extract, to return JSON with supplier, invoice number, invoice date, due date, currency, subtotal, tax, total and purchase order number. If a field isnโ€™t clearly there, leave it blank and mark the row for review. A blank is a better answer than a plausible guess.

I wouldnโ€™t make any promises about accuracy on messy scans. Test on your real suppliersโ€™ invoices, including the ugly ones, and see.

4. Check against your records

Read your ledger and purchase-orders sheets with Google Sheets Get Sheets (or Supabase Get Row if your records live there). Three checks:

  • Is there already a row with the same supplier and invoice number? Then itโ€™s a duplicate.

  • Does the purchase order number exist?

  • Is the total within the agreed amount? A tolerance of 2 percent is a reasonable starting number, and it is yours to set.

5. Log a row with an honest status

Use Google Sheets Add Row to write every field, a status of matched, duplicate or needs review, and a link to the PDF.

6. Ask the approver

For duplicates, needs-review rows and anything above the amount you choose, send a Slack Message (or a Gmail Send Email to the approver only) with the extracted values and the PDF link. The person sees what the workflow read, next to the original.

7. Look ahead once a week

A second workflow on a Custom Schedule trigger can list invoices due in the next seven days from the ledger, so due dates stop being a surprise.

Flow from an invoice email through PDF conversion, field extraction, duplicate and purchase order checks, a ledger row and an approver message

The workflow never pays or approves anything. It logs, checks and asks.

Prompt to start from in BuildShipโ€™s AI builder

Build a workflow with an Email Trigger. For every PDF attachment, convert it to text using the File to Markdown template node. Then use an AI extract node to return JSON with: supplier, invoice_number, invoice_date, due_date, currency, subtotal, tax, total, po_number. Check my Google Sheet โ€œledgerโ€ for an existing row with the same supplier and invoice_number and mark it โ€œduplicateโ€ if found. Check my Sheet โ€œpurchase-ordersโ€ for po_number and compare the total with the agreed amount (allow 2 percent difference); if it does not match, mark โ€œneeds reviewโ€. Add a row to the โ€œledgerโ€ sheet with all fields, the status, and a link to the PDF. If the status is duplicate or needs review, or the total is above 5000, send a Slack Message to #finance-approvals with the extracted fields and the PDF link. Never approve or pay anything. If any field is unclear, leave it blank and mark โ€œneeds reviewโ€.

Where people stay in charge

The workflow never pays or approves anything. Matched invoices are logged. Mismatches, duplicates and large amounts are routed to a named approver, with the extracted values beside the original so the person can check the reading. If the approver disagrees, the sheet is the record, and the run log shows exactly what the workflow saw.

What Iโ€™d test first

Generate two or three fake invoices as PDFs with a made-up supplier and made-up numbers: one clean match, one duplicate of it, and one whose total doesnโ€™t match its purchase order. Put matching rows in your test sheets and send them to the workflowโ€™s address. You should see one matched row, one duplicate held for approval and one needs-review message. Donโ€™t use real supplier documents until the whole path, including the attachment hand-off, works with the fake ones.

FAQ

Can BuildShip read invoice PDFs from email?

BuildShipโ€™s Email Trigger receives emails with attachments, and the File to Markdown tool converts PDFs to text, using OCR when needed. How the attachment passes from one to the other is worth testing with one invoice before you build the rest.

Does it approve or pay invoices?

No. It extracts, checks and logs. Mismatches, duplicates and large amounts go to a named approver.

What happens if the model canโ€™t read a field?

The field is left blank and the row is marked needs review, so a person looks at it.

Can it check invoices against purchase orders?

Yes. Keep your purchase orders in a Google Sheet or a database, and compare the total against the agreed amount with a tolerance you choose.

How much does it cost to try?

BuildShip plans start with a 7-day trial, and a card is required to start it. See the pricing page for plans and credits.

Start building

The quickest way to learn this is to build it. Start your 7-day trial (a card is required) and start with three fake invoices. For an earlier take on invoices and Gmail, see how to automate invoice management in Gmail, and for pulling data out of receipts, read extract and chat with data from receipts.

You might also like

All it takes is an idea.

Imagine. Build. Ship.

Subscribe to our newsletter

Stay in the loop with product updates and news.

ยฉ 2026 BuildShip, Rowy Inc.

All it takes is an idea.

Imagine. Build. Ship.

Subscribe to our newsletter

Stay in the loop with product updates and news.

ยฉ 2026 BuildShip, Rowy Inc.

All it takes is an idea.

Imagine. Build. Ship.

Subscribe to our newsletter

Stay in the loop with product updates and news.

ยฉ 2026 BuildShip, Rowy Inc.