Skip to content

Every 15 minutes

Log invoice emails as payables in Airtable

Invoices that arrive by email are read and added to your Airtable payables table with vendor, amount, due date and invoice number.

Runs
Every 15 minutes
Apps
Airtable, Gmail
AI
Yes, uses the built-in AI allowance
Access
Gmail gmail.readonly; Airtable write

Send this to your assistant

Create a ClickRuntime automation: when an invoice email arrives, pull out the vendor, amount, due date and invoice number, and add it to my Airtable AP table.

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

A bookkeeper for a small business receives supplier invoices by email all month. Each one needs to be opened, read and typed into the payables table before it can be scheduled for payment. On busy weeks invoices sit unlogged, and late fees follow.

This automation reads each new invoice email and its PDF, pulls out the key fields, and adds a row to your Airtable payables table. Your payables list stays current without anyone typing it in.

What you get out of it

  • Fewer late payments

    Every invoice is logged with its due date as soon as it arrives, so nothing waits in an inbox until after it is due.

  • Less typing, fewer typos

    Amounts and invoice numbers are copied straight from the document instead of retyped, which cuts the errors that cause payment mix-ups.

  • A payables view everyone can use

    Owners and accountants can see what is due this week in Airtable without asking for access to the inbox.

  • The original stays attached

    Each row links back to the email, so checking a figure against the actual invoice takes one click.

How it works

What happens, step by step

  1. Every few minutes ClickRuntime checks your Gmail for new emails with invoice attachments.

  2. Emails it has already logged are skipped.

  3. AI reads the invoice and picks out the vendor, amount, due date and invoice number.

  4. A new row is added to your Airtable payables table with a link to the email.

Before it runs live

  • Connect Airtable
  • Connect Google through your own Google app (a one-time, 10-minute setup), so it works with your own Gmail

What you get

RunsEvery 15 minutes
Log invoice emails as payables in Airtabletoday, 9:00Succeeded
Airtable · PayablesNew payable: Northwind Supplies · INV-20419 · $1,240.00 · due 4 Nov

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 Airtable and Gmail 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.
invoices_from_gmail_extracted_into_airtable.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, http, ai, state, report_fetched

AP_URL = "https://api.airtable.com/v0/appXXXXXXXXXXXXXX/Payables"
SCHEMA = {"type": "object", "properties": {k: {"type": "string"} for k in ("vendor", "amount", "due_date", "invoice_number")}}

@on_trigger
def run(event):
    gmail = build("gmail", "v1", credentials=Credentials(credentials.connection("google", "work")), cache_discovery=False)
    seen = set(state.get("seen") or [])
    msgs = [m for m in gmail.users().messages().list(userId="me", q="has:attachment filename:pdf (invoice OR bill) newer_than:2d")
            .execute().get("messages", []) if m["id"] not in seen]
    report_fetched(len(msgs))
    if not msgs:
        return {"logged": 0}
    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 = "\n".join(p.extract_text() or "" for p in PdfReader(io.BytesIO(base64.urlsafe_b64decode(data))).pages)[:6000]
        f = ai.generate(f"Extract invoice fields (due_date as YYYY-MM-DD):\n{text}", json_schema=SCHEMA, max_output_tokens=150).json
        http.post(AP_URL, headers={"Authorization": f"Bearer {credentials.secret('AIRTABLE_API_KEY')}"}, json={"typecast": True,
                  "records": [{"fields": {"Vendor": f.get("vendor"), "Amount": f.get("amount"), "Due": f.get("due_date") or None,
                               "Invoice #": f.get("invoice_number"), "Email": f"https://mail.google.com/mail/u/0/#all/{m['id']}"}}]})
        seen.add(m["id"])
    state.set("seen", list(seen)[-1000:])
    return {"logged": len(msgs)}

FAQ

Common questions

Which emails does it pick up?
Emails with a PDF or image attachment that mention an invoice or bill, or that are sent to a billing address you choose.
What if a field cannot be read?
The row is still created with what was found, and the missing fields are left empty for you to fill in, so no invoice is skipped.
Can it work with scanned invoices?
Yes, as long as the text is readable. Clear scans and photos work; very blurry images may need a field filled in by hand.
What permissions does it need?
Gmail gmail.readonly; Airtable 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 invoice emails as payables in Airtable” from your assistant

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