Every 15 minutes
Turn emailed orders into purchase orders in Airtable
Each order that arrives by email becomes a purchase order record in Airtable with the items and quantities listed.
- 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 a customer or supplier emails an order, extract the items and quantities and create a PO record in my Airtable 'Purchase orders' table.
First time? Adding ClickRuntime to your assistant takes about two minutes.
Why use it
Why teams use this automation
A small wholesale bakery takes orders from cafes by email: "same as last week but 20 more croissants", a pasted table, a photo of a handwritten list. Every evening the manager reads the inbox, types each order into Airtable, and the kitchen plans the next day from that. A missed email means a cafe without bread.
Turning each order email into a structured record as it arrives keeps the order book current through the day. Wholesalers, workshops and small manufacturers use it to stop retyping orders and to plan production from an accurate list.
What you get out of it
Orders are logged as they arrive
The order book is up to date at any moment, not only after someone has worked through the inbox.
Fewer missed or mistyped orders
Items and quantities are copied from the email itself, which cuts the errors that come with retyping late in the day.
Production and purchasing plan from one list
With every order in Airtable, it is easy to total quantities per product and see what to make or buy.
Customers can keep ordering by email
Nobody has to learn a portal. They write the way they always have, and the order still ends up structured.
How it works
What happens, step by step
Every few minutes ClickRuntime checks your Gmail for new order emails.
It skips any email it has already turned into a purchase order.
AI reads the email and lists each item with its quantity and any delivery date.
A new purchase order record is created in your Airtable table.
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
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 Airtable and Gmail steps into one automation
Under the hood
The code that runs this automation
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build
from clickruntime import on_trigger, credentials, http, state, ai, report_fetched
BASE, TABLE = "appXXXXXXXX", "Purchase orders"
SCHEMA = {"type": "object", "properties": {"is_order": {"type": "boolean"}, "delivery_date": {"type": "string"},
"items": {"type": "array", "items": {"type": "object", "properties": {"item": {"type": "string"}, "qty": {"type": "number"}}}}}}
@on_trigger
def run(event):
gmail = build("gmail", "v1", credentials=Credentials(credentials.connection("google", "work")), cache_discovery=False).users()
seen = set(state.get("seen") or [])
msgs = [m for m in gmail.messages().list(userId="me", q="subject:order newer_than:2d").execute().get("messages", []) if m["id"] not in seen]
report_fetched(len(msgs))
if not msgs:
return {"summary": "Nothing new"}
for m in msgs:
msg = gmail.messages().get(userId="me", id=m["id"]).execute()
sender = next(h["value"] for h in msg["payload"]["headers"] if h["name"] == "From")
po = ai.generate(f"Extract the order lines from this email:\n{msg['snippet']}", json_schema=SCHEMA, max_output_tokens=400).json
if po.get("is_order"):
lines = "\n".join(f"{i['qty']} x {i['item']}" for i in po.get("items", []))
http.post(f"https://api.airtable.com/v0/{BASE}/{TABLE}", headers={"Authorization": f"Bearer {credentials.secret('AIRTABLE_API_KEY')}"},
json={"fields": {"From": sender, "Items": lines, "Delivery date": po.get("delivery_date"), "Email ID": m["id"]}})
seen.add(m["id"])
state.set("seen", list(seen)[-1000:])
return {"checked": len(msgs)}FAQ
Common questions
What does each purchase order record contain?
What if an email is not an order?
Can it handle orders with many lines?
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
Turn emails that ask for something into Airtable tasks
Emails that ask you to do something become tasks in Airtable, with a clear title, a due date and a priority.
See how it worksScreen CVs from email into an Airtable candidate list
Application emails become Airtable records with the candidate's details and a score for the role.
See how it worksLog 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.
See how it worksKeep exploring
Set up “Turn emailed orders into purchase orders in Airtable” from your assistant
Copy the prompt above, or connect your assistant first. Free plan, no credit card.