Skip to content

Every 15 minutes

Check emailed invoices against your purchase order sheet

Invoices arriving in Outlook are read, matched to your purchase orders in a sheet, and anything that doesn't match is flagged to you.

Runs
Every 15 minutes
Apps
Google Sheets, Outlook
AI
Yes, uses the built-in AI allowance
Access
Mail.Read; sheet edit

Send this to your assistant

Create a ClickRuntime automation: every 15 minutes, check Outlook for new emails with PDF attachments. If one is an invoice, read the PO number, supplier and total with AI, find the PO in my Purchase Orders sheet, mark it invoiced if the amount matches, and email me if it doesn't match or the PO isn't found.

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 small manufacturer's finance assistant matches every supplier invoice to a purchase order before it is paid. Invoices arrive by email as PDFs, and the matching means opening each one, finding the PO in a sheet and comparing amounts. Mistakes and overcharges slip through when the pile gets big.

Reading each invoice as it arrives and checking it against the PO sheet means the assistant only looks at the ones that don't match.

What you get out of it

  • Overcharges are caught

    Invoices that don't match the agreed amount are flagged before they are paid.

  • Matching done as invoices arrive

    The sheet shows which POs have been invoiced without anyone opening PDFs.

  • Attention where it is needed

    Only mismatches and unknown POs come to you; matched invoices are simply recorded.

  • Works with your existing sheet

    Your purchase order sheet stays the source of truth.

How it works

What happens, step by step

  1. Every 15 minutes, ClickRuntime checks Outlook for new emails with PDF attachments.

  2. It reads the text of each PDF and AI pulls out the PO number, supplier and total, or says it is not an invoice.

  3. The PO number is looked up in your Purchase Orders sheet.

  4. If the total matches, the PO is marked invoiced; if not, or the PO is missing, you get an email with the details.

Before it runs live

  • Connect your Google Sheets account and pick the spreadsheets it may use
  • Connect Outlook

What you get

RunsEvery 15 minutes
Check emailed invoices against your purchase order sheettoday, 9:00Succeeded
Email · Invoice mismatchInvoice mismatch: Acme Fasteners. PO-1184: invoice 2,460.00, PO 2,160.00

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 Google Sheets and Outlook 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.
match_emailed_invoices_against_my_po_sheet.pyexample
import base64
import io
from pypdf import PdfReader
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build
from clickruntime import on_trigger, report_fetched, http, credentials, ai, state, notify

api = lambda name, version: build(name, version, credentials=Credentials(credentials.connection("google", "work")), cache_discovery=False)

def graph(method, path, **kw):
    r = http.request(method, "https://graph.microsoft.com/v1.0" + path, headers={"Authorization": f"Bearer {credentials.connection('microsoft', 'work')}"}, **kw)
    return r.raise_for_status() or (r.json() if r.content else None)

pdf_text = lambda b64: " ".join(p.extract_text() or "" for p in PdfReader(io.BytesIO(base64.b64decode(b64))).pages)[:12000]

SHEET_ID = "your-spreadsheet-id"
SCHEMA = {"type": "object", "properties": {"invoice": {"type": "boolean"}, "po": {"type": "string"}, "supplier": {"type": "string"}, "total": {"type": "number"}}}

@on_trigger
def run(event):
    since = state.get("since") or "2026-01-01T00:00:00Z"
    msgs = graph("GET", "/me/messages", params={"$filter": f"hasAttachments eq true and receivedDateTime gt {since}", "$orderby": "receivedDateTime", "$top": 25})["value"]
    report_fetched(len(msgs))
    if not msgs:
        return {"summary": "No new attachments"}
    sheet = api("sheets", "v4").spreadsheets().values()
    pos = {r[0]: (n, r) for n, r in enumerate(sheet.get(spreadsheetId=SHEET_ID, range="Purchase Orders!A2:D").execute().get("values", []), start=2) if r}
    for m in msgs:
        for a in graph("GET", f"/me/messages/{m['id']}/attachments")["value"]:
            if a.get("contentType") != "application/pdf":
                continue
            inv = ai.generate(pdf_text(a["contentBytes"]), system="Is this an invoice? Extract PO number, supplier and total.", json_schema=SCHEMA, max_output_tokens=100).json
            n, row = pos.get(inv.get("po", ""), (None, None))
            if inv["invoice"] and row and abs(float(row[2]) - inv["total"]) < 0.01:
                sheet.update(spreadsheetId=SHEET_ID, range=f"Purchase Orders!D{n}", valueInputOption="RAW", body={"values": [["invoiced"]]}).execute()
            elif inv["invoice"]:
                notify.email_me(f"Invoice mismatch: {inv.get('supplier')}", f"PO {inv.get('po') or 'missing'}: invoice {inv['total']}, PO {row[2] if row else 'not found'}")
    state.set("since", msgs[-1]["receivedDateTime"])
    return {"checked": len(msgs)}

FAQ

Common questions

What if an invoice has no PO number?
It is treated as a mismatch and you get an email with the supplier and total, so you can find the right PO.
How close must the amounts be?
An exact match by default. You can allow a small difference for rounding or delivery charges.
Does it pay invoices?
No. It only checks and records them. Payment stays with you.
What permissions does it need?
Mail.Read; sheet edit. 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 “Check emailed invoices against your purchase order sheet” from your assistant

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