Every 10 minutes
Pull key fields from emailed invoices and POs
Purchase orders and invoices that arrive in Outlook are read for you, and the supplier, amounts and due date reach you in one summary.
- Runs
- Every 10 minutes
- Apps
- Outlook
- AI
- Yes, uses the built-in AI allowance
- Access
- Mail.ReadWrite
Send this to your assistant
Create a ClickRuntime automation: every 10 minutes, check my Outlook for emails with PO or invoice PDFs attached, extract the supplier, document number, line items, total and due date, and email me a summary.
First time? Adding ClickRuntime to your assistant takes about two minutes.
Why use it
Why teams use this automation
The finance assistant at a small construction supplier receives purchase orders, supplier invoices and subcontractor timesheets as PDF attachments on emails from dozens of senders, all in different layouts. Someone opens each attachment, finds the PO number, amounts, dates and hours, and types them into a spreadsheet or the accounting system. It is slow, tedious and error-prone, and a mistyped digit leads to a mismatched order or a wrong payment.
Every 10 minutes, new Outlook messages that have attachments are listed, and each attachment is downloaded. ClickRuntime's built-in AI reads it and extracts fields such as document type, number, counterparty, date, amounts and hours. The result is sent to you by email or Slack, and the original message can be moved to a folder to show it was processed.
It suits back-office teams in construction, wholesale, staffing and services businesses that handle paperwork by email.
What you get out of it
Keying errors fall
Pulling numbers straight from the document avoids transposed digits and missed decimals. A clerk then compares the extracted figures to the document, which is faster and more accurate than typing from scratch.
Documents are recognized on arrival
An email with a purchase order, an invoice or a timesheet gets identified as such, so the right person sees it immediately. Nothing sits in a general inbox while the sender wonders whether it arrived.
Layout variety is not a problem
Dozens of suppliers use dozens of layouts. Reading documents with AI does not need a template per sender, so a new supplier works from the very first invoice. That flexibility matters for a small firm that cannot dictate formats to suppliers or subcontractors.
Month-end closes faster
When every document is already summarized into fields throughout the month, there is no stack of unopened attachments to type up on the last day. That reduces the stress of close and lets the team spend the final days on checks instead of typing.
Processed mail is easy to tell apart
Moving handled messages into a folder keeps the inbox focused on what still needs human attention, and it gives you a record of what was processed and when. It also provides a handy audit trail of which documents were seen and when.
How it works
What happens, step by step
Every 10 minutes, ClickRuntime checks your Outlook inbox for new emails with attachments. Emails it has already read are skipped.
It opens each attached purchase order, invoice or timesheet.
AI picks out the document type, supplier, amount and due date.
You get one summary with a line per document, and if you choose, the emails are moved to a folder once they are read.
Before it runs live
- Connect Outlook
What you get
Build your own
Need it to work differently?
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 Outlook steps into one automation
Under the hood
The code that runs this automation
import base64
from datetime import datetime, timezone
from clickruntime import on_trigger, credentials, http, state, ai, notify, report_fetched
GRAPH = "https://graph.microsoft.com/v1.0"
DONE_FOLDER_ID = "AAMkAD...processed"
@on_trigger
def run(event):
h = {"Authorization": f"Bearer {credentials.connection('microsoft', 'work')}"}
since = state.get("since") or datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
msgs = http.get(f"{GRAPH}/me/messages", headers=h, params={
"$filter": f"receivedDateTime gt {since} and hasAttachments eq true",
"$select": "id,subject,from,receivedDateTime", "$orderby": "receivedDateTime asc"}).json()["value"]
report_fetched(len(msgs))
if not msgs:
return {"summary": "Nothing new"}
lines = []
for m in msgs:
for att in http.get(f"{GRAPH}/me/messages/{m['id']}/attachments", headers=h).json()["value"]:
if att.get("contentType") != "application/pdf" and not att["name"].lower().endswith((".txt", ".csv")):
continue
text = base64.b64decode(att["contentBytes"]).decode("latin-1")[:12000]
f = ai.generate(text, system="Extract fields from this purchase order, invoice or timesheet.", max_output_tokens=200,
json_schema={"type": "object", "properties": {"type": {"type": "string"}, "supplier": {"type": "string"},
"total": {"type": "string"}, "due_date": {"type": "string"}}}).json
lines.append(f"{f['type']}: {f['supplier']}, {f['total']}, due {f['due_date']} ({att['name']})")
http.post(f"{GRAPH}/me/messages/{m['id']}/move", headers=h, json={"destinationId": DONE_FOLDER_ID})
state.set("since", msgs[-1]["receivedDateTime"])
notify.email_me(f"{len(lines)} documents read", "\n".join(lines))
return {"documents": len(lines)}FAQ
Common questions
Which document types can it handle?
What happens if a field cannot be read?
Does it only look at attachments?
What permissions does it need?
Does it need AI?
How many runs does it use?
Can I change how it works?
Related
You might also like
Sort new Outlook mail into categories
Each new email is tagged Action, Info, Newsletter or Junk, and newsletters are moved out of your way.
See how it worksHave reply drafts ready for customer questions
Routine customer questions get an AI-written reply saved in Drafts, ready for you to check and send.
See how it worksFile Outlook attachments in OneDrive
Attachments you receive are saved to OneDrive in a folder per sender.
See how it worksKeep exploring
Set up “Pull key fields from emailed invoices and POs” from your assistant
Copy the prompt above, or connect your assistant first. Free plan, no credit card.