Skip to content

Every 10 minutes

Log PDF invoices from Gmail in a spreadsheet

Every invoice that arrives by email is added as a row in your Invoices sheet with supplier, date, number and total.

Runs
Every 10 minutes
Apps
Gmail, Google Sheets
AI
Yes, uses the built-in AI allowance
Access
Gmail gmail.modify; Sheets read+write

Send this to your assistant

Create a ClickRuntime automation: watch my Gmail for emails with PDF invoices, pull out supplier, date, invoice number and total, and add a row to my Invoices sheet.

Paste it into your assistant. It tells you what it will send or change before it runs live.

First time? Adding ClickRuntime to your assistant takes about two minutes.

Why use it

Why teams use this automation

The owner of a small design studio gets invoices from software vendors, freelancers and printers, all as PDF attachments in her inbox. At the end of each month she opens every one, types the totals into a spreadsheet for her bookkeeper, and still misses a few that were buried under newsletters.

Logging each invoice as it arrives gives you a complete list of what you owe and a tidy record for your accountant, without opening a single PDF. Freelancers, small businesses and office managers use it to keep their books up to date through the month instead of catching up at the end.

What you get out of it

  • Month-end takes minutes, not an afternoon

    The sheet already holds every invoice, so preparing for the bookkeeper is a matter of checking the list rather than building it.

  • Fewer missed invoices

    Invoices are picked up as they arrive, even when the email is buried under other messages. Late fees from forgotten bills become rare.

  • Spending is visible as it happens

    A running list of supplier totals shows where money goes each month, which helps when deciding which subscriptions to cut.

  • Your accountant gets a clean list

    Supplier, date, number and total in consistent columns is exactly what a bookkeeper needs to reconcile payments.

How it works

What happens, step by step

  1. Every few minutes ClickRuntime checks your Gmail for new emails with a PDF attachment.

  2. It skips emails it has already handled, which it marks with a Gmail label.

  3. AI reads the invoice and picks out the supplier, date, invoice number and total.

  4. A new row with those details is added to your Invoices sheet.

Before it runs live

  • Connect Google through your own Google app (a one-time, 10-minute setup), so it works with your own Gmail
  • Connect your Google Sheets account and pick the spreadsheets it may use

What you get

RunsEvery 10 minutes
Log PDF invoices from Gmail in a spreadsheettoday, 9:00Succeeded
Google Sheets · InvoicesNorthwind Print Co. | 2026-10-14 | INV-2291 | 480.00 EUR

Build your own

Need it to work differently?

This template is a starting point. Copy the prompt and change it, or describe a different automation from scratch, with your own conditions, more apps or an AI step. Your assistant writes it, tests it and runs it on ClickRuntime.
  • Your own rules

    Conditions, thresholds, filters and exceptions, written the way you'd explain them to a colleague.

  • Any number of apps

    One automation can read from one app and update several others. Over 248 apps are ready, and anything with an API works too.

  • AI where it helps

    Summaries, classification, extraction and drafts use ClickRuntime's built-in AI, with no extra key.

  • On a schedule or on each event

    Runs as often as every 5 minutes, or the moment an app sends an event, and keeps track of what it already handled.

Changes you can ask for

  • Act only on the items that match your own rules, and skip the rest
  • Change what the AI looks for, or how it writes the result
  • Add another app, for example also send it to Slack
  • Combine it with other Gmail and Google Sheets steps into one automation

Under the hood

The code that runs this automation

This is the Python script that runs each time the automation starts. Your AI assistant writes it for you when you send the prompt, and you allow each step in your assistant. To change how the automation works, describe the change to your assistant and it updates the script for you. For every function it can use, see the script reference.
invoice_emails_to_a_spreadsheet.pyexample
import base64, io
from pypdf import PdfReader
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build
from clickruntime import on_trigger, credentials, ai, report_fetched

SHEET_ID, LABEL_ID = "your-spreadsheet-id", "Label_Invoices"
SCHEMA = {"type": "object", "properties": {k: {"type": "string"} for k in ["supplier", "date", "number", "total"]}}

@on_trigger
def run(event):
    creds = Credentials(credentials.connection("google", "work"))
    gmail, sheets = build("gmail", "v1", credentials=creds, cache_discovery=False), build("sheets", "v4", credentials=creds, cache_discovery=False)
    msgs = gmail.users().messages().list(userId="me", q="has:attachment filename:pdf -label:invoices-logged newer_than:7d").execute().get("messages", [])
    report_fetched(len(msgs))
    if not msgs:
        return {"summary": "Nothing new"}
    for m in msgs:
        msg = gmail.users().messages().get(userId="me", id=m["id"]).execute()
        part = next(p for p in msg["payload"].get("parts", []) if p.get("filename", "").lower().endswith(".pdf"))
        data = gmail.users().messages().attachments().get(userId="me", messageId=m["id"], id=part["body"]["attachmentId"]).execute()["data"]
        text = "".join(p.extract_text() or "" for p in PdfReader(io.BytesIO(base64.urlsafe_b64decode(data))).pages)[:6000]
        f = ai.generate(f"Extract supplier, date, invoice number and total from this invoice:\n{text}", json_schema=SCHEMA, max_output_tokens=150).json
        sheets.spreadsheets().values().append(spreadsheetId=SHEET_ID, range="Invoices!A:D", valueInputOption="USER_ENTERED",
            body={"values": [[f.get("supplier"), f.get("date"), f.get("number"), f.get("total")]]}).execute()
        gmail.users().messages().modify(userId="me", id=m["id"], body={"addLabelIds": [LABEL_ID]}).execute()
    return {"logged": len(msgs)}

FAQ

Common questions

Which emails does it look at?
New emails with a PDF attachment. Those that are not invoices, such as brochures or reports, are skipped, and each processed email gets a label so it is never logged twice.
What if an invoice has no clear total?
The row is still added with the fields it could read, and the missing ones are left blank so you can fill them in from the PDF.
Can it save the PDF too?
Yes. It can also save each invoice PDF to a Drive folder and put the link in the row, so the original is one click away.
What permissions does it need?
Gmail gmail.modify; Sheets read+write. Nothing else in your accounts is used.
Does it need AI?
Yes. It uses ClickRuntime's built-in AI, so you don't need an OpenAI or Anthropic key. Every plan includes a monthly AI allowance.
How many runs does it use?
One run each time it checks. Checks that find nothing new and stop right away aren't counted.
Can I change how it works?
Yes. Describe the change to your AI assistant, for example a different schedule, channel or filter. It updates the automation, tests it and tells you what changed.

Set up “Log PDF invoices from Gmail in a spreadsheet” from your assistant

Copy the prompt above, or connect your assistant first. Free plan, no credit card.