Mindket

Invoice PDFs from Gmail read by LlamaParse and OpenAI

Newversion 1 · updated

Overview

An n8n workflow that reads invoice PDFs from Gmail with LlamaParse, asks an OpenAI model to pull out the fields and adds a row to Google Sheets. It then labels the email as done.

Invoice PDFs from Gmail read by LlamaParse and OpenAI is an n8n workflow in the Finance & accounting category, listed by Mindket. It is free. This is version 1, last updated on . Download it on this page or copy its JSON, then import it into an n8n canvas. Nothing runs until you activate it in n8n.

At a glance

Runs in
  • A Gmail inbox: a shared invoices mailbox works well, narrowed to one sender
  • LlamaParse: it reads the PDF, and it spends credits for each page
  • An OpenAI model: it reads the markdown and returns the fields
  • Google Sheets: one row for each invoice, with the line items kept in one cell

Platform

Connects 4 apps

How it works

Trigger

A new invoice email

It checks Gmail every minute and starts for each new email from the chosen sender that has an attachment, and it reads:

  • The email and the names of its labels
  • Its first attachment, which has to be a PDF

Actions

  1. The email is skipped unless its first attachment is a PDF and it does not carry the label “invoice synced”
  2. The PDF is uploaded to LlamaParse, which turns it into markdown
  3. The job is checked every second until it ends, and a failed or cancelled job stops the run with an error
  4. The markdown is fetched as one piece of text
  5. An OpenAI model pulls out the invoice fields, shaped by a structured output parser
  6. The fields are added to Google Sheets as a row
  7. The email gets the label “invoice synced”

Result

One row in Google Sheets for each invoice, and the email labelled as done

Integrations

What you need before you start.

Gmail

Invoice source

Delivers the invoice emails with their PDFs, then receives the label that marks them as done.

NeedsA Gmail account connected to n8n and a label called “invoice synced”

LlamaParse

PDF reading

Turns the PDF into markdown, tables included.

NeedsA LlamaCloud account and an API key, with credits for each page

OpenAI

Field extraction

Reads the markdown and returns the invoice fields in a fixed shape.

NeedsAn OpenAI account and an API key

Google Sheets

Row storage

Adds one row for each invoice.

NeedsA Google account and a spreadsheet with matching column titles

Workflow check

Checked by Mindket on 13 Nov 2026

Steps
16 steps, starting on a Gmail event
AI
1 step calls an AI model: Apply Data Extraction Rules
Sign-ins
Signs in to: Gmail, api.cloud.llamaindex.ai, Google Sheets and OpenAI
API keys
No API key is left in the file
Step types
Mindket’s checker reads 12 of its 13 step types. It does not read: Gmail

Read from the workflow’s file, not from a run.

About

What it is

This n8n workflow turns invoice PDFs from Gmail into spreadsheet rows. It watches for emails from a sender you choose that carry an attachment, and it sends the PDF to LlamaParse to be turned into markdown. An OpenAI model then pulls out the invoice fields, such as the supplier, the dates, the line items and the totals. The workflow adds them to Google Sheets and labels the email, so that it is not handled twice. Eighteen nodes run the flow.

Who it suits

Finance and accounts payable teams that get invoices as PDF attachments from a few regular suppliers and want the details in a sheet. It suits invoices with tables of line items, which simple text extraction often flattens. Skip it if invoices arrive as images in the email body, because only the first attachment is read.

Who uses it, and how
IndustryWho uses itHow they use itExample
AccountingBookkeepersLog supplier invoices with their line items for postingA bookkeeper checks each new row against the invoice before posting.
OperationsBack-office teamsKeep a running list of what each supplier billedA team lead filters the sheet by supplier to see the month’s charges.
ProcurementPurchasing staffMatch invoices to purchase order numbersA buyer finds each purchase order number in the sheet.
SoftwareAutomation buildersUse it as a starting point for document extractionA builder swaps the sheet for an accounting tool.

You need solid n8n for this one: four credentials, a Gmail label, a sheet with matching column titles and a job check that loops until the job ends. The file gives no setup time.

Where to use it

n8n Cloud or a self-hosted n8n can run it, with accounts at LlamaParse, OpenAI, Gmail and Google.

  • A Gmail inbox: a shared invoices mailbox works well, narrowed to one sender
  • LlamaParse: it reads the PDF, and it spends credits for each page
  • An OpenAI model: it reads the markdown and returns the fields
  • Google Sheets: one row for each invoice, with the line items kept in one cell
  • Another destination: replace the Sheets node with a node for an accounting tool or a database

Setup

Download saves a zip with workflow.json and Mindket’s setup notes in your downloads folder. Four credentials and a prepared sheet make it run.

What you need first
NeedDetail
n8nA server or an n8n Cloud account
LlamaParseA LlamaCloud account and an API key
OpenAIAn account and an API key
GmailA Gmail account with a label called invoice synced
GoogleA spreadsheet whose first row holds the 14 field names
  1. In Gmail, create the label invoice synced.
  2. In n8n, create a workflow, open its menu, choose Import from File and pick workflow.json.
  3. Create a Header Auth credential for LlamaParse with the name Authorization and the value Bearer followed by your key. Choose it in the three LlamaParse nodes.
  4. Open OpenAI Model and connect your OpenAI account.
  5. Open Receiving Invoices, connect Gmail and replace <SUPPLIER_EMAIL_ADDRESS> with the sender’s address.
  6. In Add "invoice synced" Label, choose your label.
  7. In Append to Reconciliation Sheet, connect your Google account and choose the spreadsheet and sheet.
  8. Run one real invoice through and check each node’s output. Then save and press Publish at the top of the canvas (or Shift+P).

How to use it

Wait for the next invoice email from that sender, or run the workflow on a recent one. Within a minute n8n picks it up, sends the PDF to LlamaParse and waits for the job. The model then reads the markdown, a row appears in your sheet and the email gets the label. Compare the first rows with the invoices before you trust the flow.

What to change for a different result
To changeWhere
Which emails are readThe filters in Receiving Invoices
Which fields are extractedThe prompt in Apply Data Extraction Rules, the schema in Structured Output Parser and the sheet’s column titles
Which model reads the invoiceOpenAI Model
How the PDF is parsedThe configuration field in Upload to LlamaParse
Where the rows goAppend to Reconciliation Sheet

Example

A supplier emails invoice 4471 as a PDF with five line items and a purchase order number.

Within a minute the workflow sends the PDF to LlamaParse and waits until the job is done. The model reads the markdown and returns the supplier, the dates, the purchase order number and the totals. One row is added to the sheet, with the five line items in one cell, and the email gets the label invoice synced.

For newcomers and experts

If you are new. n8n draws a workflow as boxes joined by lines, and each box, a node, does one job. This one reads Gmail, sends the PDF to a reading service and checks again until the job is done. Then it asks an AI model for the fields and writes them to a sheet. Run it on one email and open each box’s output to follow the data.

For experts. LlamaParse is called with plain HTTP Request nodes on its v2 API, and the AI step is a basic chain with a structured output parser, not an agent.

Where to look closer
NodeWhat it doesWhat to know
Receiving InvoicesPolls every minute for new email with an attachment from one senderIt downloads the attachments as attachment_0, attachment_1 and so on
Email with Label NamesJoins each email with the names of its labelsCombine Label Names pools the names from every email in the poll into one list
Upload to LlamaParsePosts the first attachment to /api/v2/parse/uploadThe configuration field is a JSON string with a tier and a version
Is Job Ready?Routes on job.statusCOMPLETED moves on, FAILED and CANCELLED stop with an error, and PENDING and RUNNING wait a second and ask again
Get Parsed Invoice DataFetches the job with expand=markdown_fullThe answer holds the whole document as one string
Apply Data Extraction RulesA basic LLM chain with a structured output parserThe prompt carries the field list, and the model is gpt-6-luna
Append to Reconciliation SheetAppends a row by matching field names to column titlesAn object such as the line items is written to its cell as JSON text

Good to know

The workflow spends LlamaParse credits on every PDF and sends invoices to two outside services.

  • Not run: Mindket made no call to LlamaParse, OpenAI, Gmail or Google. It read LlamaParse’s documentation, OpenAI’s pages and n8n’s node code
  • First attachment only: if an email has a logo image before the PDF, Should Process Email? skips it
  • Failed jobs: a failed or cancelled LlamaParse job stops the run with an error, and the email stays without its label
  • Endless loop: the status check repeats every second until the job ends, and nothing limits how often
  • Credits: LlamaParse’s pricing page lists the tier used here at 3 credits a page, and its tiers page says parsing the same file again within 48 hours costs none
  • Shared pool: two or more emails in one poll share a single list of label names, so one email that has the label can make the others skip
  • Your data: each PDF goes to LlamaParse, the extracted text goes to OpenAI and the rows go to Google, and invoices can hold names, addresses and bank details
  • Credentials: the JSON holds none

README and files

README

Invoice PDFs from Gmail read by LlamaParse and OpenAI

An n8n workflow that watches Gmail for invoice emails with a PDF. It turns the PDF into markdown with LlamaParse, asks an OpenAI model to pull out the invoice fields and adds them as a row in Google Sheets. Then it labels the email, so the same one is not handled twice.

What is inside

  • workflow.json: the workflow as n8n exports it, 27 nodes. 18 of them run and nine are sticky notes. It holds no credential.
  • README.md: these notes.

What we changed from the original copy

  • The original called LlamaParse's v1 API. It now uses the v2 API for the upload, the job check and the result, with the tier cost_effective. LlamaParse's migration page says v1 still works for the foreseeable future, and that new features are v2 only.
  • The job check reads job.status and knows the v2 states. RUNNING joins PENDING on the waiting branch. FAILED and CANCELLED now go to a new node, Stop on parse failure, so a failed job shows as an error. Before, they led nowhere.
  • The result is fetched with expand=markdown_full, and the prompt reads that field.
  • The original used the OpenAI text-completion node with gpt-3.5-turbo-1106. OpenAI's deprecations page, read on 12 November 2026, lists that model as shut down on 28 September 2026. The node is now the OpenAI Chat Model with gpt-6-luna.
  • The fixed temperature of 0 is gone, because OpenAI's page for gpt-6-luna says nothing about a temperature setting.
  • The sender filter, the label id and the spreadsheet belonged to the original author. They are now <SUPPLIER_EMAIL_ADDRESS>, <YOUR_INVOICE_SYNCED_LABEL_ID> and <YOUR_SPREADSHEET_ID>.
  • A typo in the prompt is fixed, the sticky notes lose their outside links, and the old note about 1,000 free PDFs a day is replaced with LlamaParse's current pricing.
  • Nothing else. The label check, the structured output parser and the sheet mapping are as they were.

Before you start

  • An n8n instance, on n8n Cloud or your own server.
  • A LlamaCloud account and an API key. LlamaParse's billing page lists a Pay as you go plan at $0 a month with 10,000 free credits each month. Its pricing page lists the cost_effective tier at 3 credits a page, so that is about 3,300 pages.
  • An OpenAI account with an API key.
  • A Gmail account with a label called invoice synced, and a Google spreadsheet.
  • The sheet's first row holds 14 column titles. They must match the 14 field names in Structured Output Parser exactly, so open that node and copy them from its schema.

Set it up

  1. In Gmail, create the label invoice synced.
  2. In n8n, create a workflow, open its menu and choose Import from File. Pick workflow.json.
  3. Create a Header Auth credential for LlamaParse. Give it the name Authorization and the value Bearer followed by your key. Choose it in Upload to LlamaParse, Get Processing Status and Get Parsed Invoice Data.
  4. Open OpenAI Model and connect your OpenAI account. Keep gpt-6-luna or pick another chat model.
  5. Open Receiving Invoices, connect your Gmail account and replace <SUPPLIER_EMAIL_ADDRESS> with the sender's address. Use the same account in Get Labels Names and Add "invoice synced" Label.
  6. In Add "invoice synced" Label, choose your invoice synced label.
  7. In Append to Reconciliation Sheet, connect your Google account and choose your spreadsheet and sheet.
  8. Run it on one real invoice and check each node's output. Then save and press Publish at the top of the canvas (or Shift+P).

How a run goes

  1. Receiving Invoices checks every minute for new email from that sender with an attachment, and downloads the attachments.
  2. Split Out Labels, Get Labels Names, Combine Label Names and Email with Label Names look up the names of the email's labels and attach them to it.
  3. Should Process Email? lets the email through when its first attachment is a PDF and its labels do not include invoice synced.
  4. Upload to LlamaParse sends that attachment with the tier cost_effective and gets a job id back.
  5. Get Processing Status asks for the job, and Is Job Ready? routes it. A finished job moves on, a failed or cancelled one stops, and a pending or running one goes to Wait to stay within service limits, which waits a second and asks again.
  6. Get Parsed Invoice Data fetches the whole document as one markdown string.
  7. Apply Data Extraction Rules gives the markdown and the field list to the model, and Structured Output Parser shapes the answer.
  8. Map Output keeps the parsed object. Append to Reconciliation Sheet adds one row, and Add "invoice synced" Label labels the email.

Change the look

  • Which emails are read: the filters in Receiving Invoices.
  • Which fields are extracted: the prompt in Apply Data Extraction Rules, the schema in Structured Output Parser and the column titles in your sheet.
  • Which model reads the invoice: OpenAI Model.
  • How the PDF is parsed: the configuration field in Upload to LlamaParse. LlamaParse's tiers page lists fast, cost_effective, agentic and agentic_plus, and advises pinning a dated version for production.
  • Where the rows go: Append to Reconciliation Sheet. You can swap it for an accounting tool or a database.

Good to know

  • Not run: Mindket made no call to LlamaParse, OpenAI, Gmail or Google. It read LlamaParse's documentation, OpenAI's pages and n8n's node code on 12 November 2026.
  • Only the first attachment is read. If an email has a logo image before the PDF, Should Process Email? skips it.
  • A failed or cancelled LlamaParse job stops the run with an error, and the email stays without its label. Check Executions for those.
  • The status check repeats every second until the job ends, and nothing limits how many times it repeats.
  • Credits are spent for each page. LlamaParse's tiers page says parsing the same file again within 48 hours costs no credits.
  • Two or more emails in one poll share a single pool of label names, so one email that already has the label can make the others skip. This comes from reading the wiring, not from a run.
  • Your data: each PDF goes to LlamaParse, the extracted text goes to OpenAI, and the rows go to Google. Invoices can hold names, addresses and bank details.
  • Credentials: the JSON holds none. LlamaParse, OpenAI, Gmail and Google Sheets each need their own n8n credential.
Files
NOTICE.md  642 B
README.md  6 KB
workflow.json  29 KB

3 files, 36 KB, downloaded as a zip.

What’s new

  • Version 1 · 2026-11-12

Reviews

No ratings yet

Write a review

No reviews yet.

More from Mindket

See all from Mindket

Nanosaur2-670M

well9472 · Kit

Makes illustrations from text prompts with a small 670M-parameter diffusion model, run through ComfyUI. Built as a low-budget research model for people who wan…

New

Reads handwritten Arabic text from images and returns it as text. A fine-tuned PaddleOCR-VL model for people digitizing Arabic handwriting.

New

Makes video clips from a text prompt or an image plus text, at up to 720P and 24 frames per second, in the Diffusers format for a single consumer GPU.

New

Similar in Finance & accounting

See all in Finance & accounting

Kronos-mini

NeoQuasar · Kit

Forecasts financial candlestick series with a 4.1M-parameter foundation model trained on data from over 45 exchanges. For quant researchers and developers who…

New