Skip to content

Every 15 minutes

Save invoice PDFs from Gmail to Drive, named by supplier and amount

Invoice and receipt PDFs in your inbox are saved to Drive as date_supplier_amount files, and the email is labelled as filed.

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

Send this to your assistant

Create a ClickRuntime automation: every 15 minutes, find new emails with invoice or receipt PDFs, save them to my Drive 'Invoices/2026' folder named date_supplier_amount, and label the email Filed.

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 freelance consultant pays for a dozen tools and services. Receipts arrive as PDFs named invoice.pdf or 2026-0042.pdf, and at tax time she downloads each one, renames it and drags it into a folder, one evening at a time.

Saving each receipt as it arrives with a name that says who, when and how much makes the archive usable at a glance and turns tax-time prep into sharing one folder.

What you get out of it

  • Files you can read from the name

    A name like 2026-10-14_Northwind_129.00 tells you what a file is without opening it, and sorts by date.

  • Your accountant gets one folder

    Share the Invoices folder once instead of forwarding emails or zipping attachments at year end.

  • Non-invoices are left alone

    Order confirmations, brochures and other PDFs are recognised and skipped, so the folder only holds real invoices.

  • Your inbox shows what is done

    Each processed email gets a label, so you can see what has been filed and archive it with confidence.

How it works

What happens, step by step

  1. Every 15 minutes ClickRuntime checks your Gmail for new emails with PDF attachments.

  2. It skips emails that already carry the Filed label.

  3. AI decides whether each attachment is an invoice or receipt and reads the supplier, date and total.

  4. Each invoice is saved to your Drive folder with a name like 2026-10-14_Northwind_129.00, and the email is labelled Filed.

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 Google Drive

What you get

RunsEvery 15 minutes
Save invoice PDFs from Gmail to Drive, named by supplier and amounttoday, 9:00Succeeded
Google Drive · Invoices/2026Saved 2026-10-14_Northwind-Hosting_129.00.pdf and 2026-10-15_Acme-Software_49.00.pdf

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 Drive 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_archived_to_drive_with_extracted_data.pyexample
import base64, json
from clickruntime import on_trigger, credentials, http, ai, report_fetched

G, FOLDER, LABEL = "https://gmail.googleapis.com/gmail/v1/users/me", "your-invoices-folder-id", "Label_Filed"
SCHEMA = {"type": "object", "properties": {"invoice": {"type": "boolean"}, "date": {"type": "string"},
          "supplier": {"type": "string"}, "amount": {"type": "string"}}, "required": ["invoice", "date", "supplier", "amount"]}

@on_trigger
def run(event):
    h = {"Authorization": f"Bearer {credentials.connection('google', 'work')}"}
    msgs = http.get(f"{G}/messages", headers=h, params={"q": "has:attachment filename:pdf -label:Filed newer_than:7d"}).json().get("messages", [])
    report_fetched(len(msgs))
    if not msgs:
        return {"new": 0}
    saved = 0
    for m in msgs:
        msg = http.get(f"{G}/messages/{m['id']}", headers=h).json()
        for part in [p for p in msg["payload"].get("parts", []) if p.get("filename", "").lower().endswith(".pdf")]:
            info = ai.generate(f"Email snippet: {msg['snippet']}\nFile: {part['filename']}\nIs this an invoice or receipt? Extract date (YYYY-MM-DD), supplier, total.",
                               json_schema=SCHEMA, max_output_tokens=80).json
            if not info["invoice"]:
                continue
            data = http.get(f"{G}/messages/{m['id']}/attachments/{part['body']['attachmentId']}", headers=h).json()["data"]
            name = f"{info['date']}_{info['supplier']}_{info['amount'] or 'unknown'}.pdf"
            http.post("https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart", headers=h, files={
                "metadata": (None, json.dumps({"name": name, "parents": [FOLDER]}), "application/json"),
                "file": (name, base64.urlsafe_b64decode(data), "application/pdf")})
            saved += 1
        http.post(f"{G}/messages/{m['id']}/modify", headers=h, json={"addLabelIds": [LABEL]})
    return {"checked": len(msgs), "saved": saved}

FAQ

Common questions

How does it know a PDF is an invoice?
AI reads the start of the email and the attachment name and decides whether it is an invoice or receipt, then pulls out the supplier, date and total.
What if it cannot read the amount?
The file is still saved, with 'unknown' in place of the amount, and you get an email listing it so you can check.
Can it file by year automatically?
Yes. It can save into a folder for the invoice's year, so January's files land in the new year's folder without changes.
What permissions does it need?
Gmail gmail.modify; Drive 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 “Save invoice PDFs from Gmail to Drive, named by supplier and amount” from your assistant

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