Finance & Back Office

Get invoices out of email and into a sheet

A scheduled job that reads invoice mail and appends a row per line item.

Time
20 minutes
You work in
Chat
Connect first
GmailGoogle Sheets

Before you start

  • Gmail connected
  • Google Sheets connected, with a sheet whose headers you have set

This is the least glamorous playbook here and the one people are most relieved by. Someone, every month, opens forty emails, opens forty PDFs, and types numbers into a spreadsheet.

The mechanism is worth understanding because it generalises: mail in, structured rows out, and a human checking the exceptions rather than the whole pile.

Connect Gmail and Google Sheets

Both from Integrations. Gmail is a first-party connector and a button. Google Sheets is served through the managed catalog, so search for it.

Build the sheet first, with real headers

Create the sheet before you write any prompt, and set the header row exactly as you want it. The headers are the schema. An employee appending to a sheet with vague headers produces vague columns.

Something like: Date | Vendor | Invoice number | Description | Amount | Currency | Due date | Source email.

That last column matters more than it looks. It is what makes a wrong row debuggable three weeks later.

Do one message by hand first

Before scheduling anything, run it once against a single known invoice.

Prompt
Find the most recent email in my inbox that contains an invoice.

Extract every line item, and tell me: the vendor, the invoice number,
each line item with its amount, the currency, the total, and the due
date.

Show me what you found before writing anything to the sheet. If any
field is missing or ambiguous, say which one rather than guessing.

You are checking two specific things: that the totals match the document, and that it says "missing" rather than inventing a due date that is not written anywhere.

Watch the currency. It is the field most likely to be silently assumed, and the one that produces the most expensive kind of wrong. A sheet mixing currencies without a column that says so is worse than no sheet.

Turn it into a scheduled job

Once one invoice works, schedule it.

Prompt
Every weekday at 6am, search my mail from the last 24 hours for
invoices.

For each one, append a row per line item to the Invoices sheet, matching
the existing headers exactly. Put the Gmail message link in the Source
email column.

Do not write a row if the vendor, the amount or the currency is missing
or ambiguous. Instead, list those messages back to me with what was
unclear.

Never modify or delete an existing row. Only append.

If there were no invoices, say so and stop.

The append-only rule is deliberate. A job that can rewrite history is a job that can quietly destroy a month of reconciliation, and there is no version of this task that needs it.

Read the exceptions, not the sheet

Each run tells you what it skipped. That list is the job.

If the same vendor turns up in the exceptions every month, their invoice template is the problem, and the fix is a line in the prompt describing that one vendor's layout rather than a general instruction to try harder.

What good looks like

Month-end reconciliation starts from a sheet that is already ninety percent populated, and the ten percent you touch is a list someone handed you rather than something you had to find.