Every 15 minutes
Approve supplier invoices in Slack before they go into Xero
New supplier invoices are read and posted to Slack with Approve and Reject buttons, and approved ones become bills in Xero.
- Runs
- Every 15 minutes
- Apps
- Slack, Xero
- AI
- Yes, uses the built-in AI allowance
- Access
- chat:write; accounting.transactions
Send this to your assistant
Create a ClickRuntime automation: every 15 minutes, read new invoice emails with AI and post each to #finance with Approve and Reject buttons; when someone approves, create the bill in Xero.
First time? Adding ClickRuntime to your assistant takes about two minutes.
Why use it
Why teams use this automation
Spending approval in a small company usually means forwarding an invoice to the manager and waiting. The email gets buried, the supplier chases, and the bookkeeper can't enter the bill until someone says yes.
Putting the invoice in Slack with Approve and Reject buttons turns a forwarded email into a one-click decision, and the approved bill goes straight into Xero.
What you get out of it
Faster sign-off
Managers approve from Slack, often within minutes, instead of finding the email later.
Clear accountability
Each message records who approved or rejected the invoice.
Only approved spend is entered
Bills reach Xero only after a yes, so rejected invoices never clutter your payables.
No typing from PDFs
Supplier, reference and amount are read for you.
How it works
What happens, step by step
Every 15 minutes, ClickRuntime checks your inbox for new invoice emails.
AI reads each one and picks out the supplier, reference and amount.
It posts the invoice to #finance with Approve and Reject buttons.
When someone approves, the bill is created in Xero and the Slack message shows who approved it.
Invoices already posted are remembered, so nothing is posted twice.
Before it runs live
- Connect Slack, then invite the app to the channel (type /invite @ClickRuntime there)
- Connect Xero
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 Google Sheets
- Combine it with other Slack and Xero steps into one automation
Under the hood
The code that runs this automation
import json
from urllib.parse import parse_qs
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build
from slack_sdk import WebClient
from clickruntime import on_trigger, on_event, credentials, http, state, ai, report_fetched
XERO = "https://api.xero.com/api.xro/2.0"
TENANT = "your-xero-tenant-id"
def xero(method, path, **kw):
r = http.request(method, XERO + path, **kw, headers={"Accept": "application/json", "Xero-tenant-id": TENANT, "Authorization": "Bearer " + credentials.connection("xero", "company")})
return r.raise_for_status() or r.json()
@on_trigger
def run(event):
gmail, seen = build("gmail", "v1", credentials=Credentials(credentials.connection("google", "work")), cache_discovery=False), set(state.get("seen") or [])
msgs = [m for m in gmail.users().messages().list(userId="me", q="label:Invoices newer_than:3d").execute().get("messages", []) if m["id"] not in seen]
report_fetched(len(msgs))
if not msgs:
return {"summary": "Nothing new"}
for m in msgs:
snippet = gmail.users().messages().get(userId="me", id=m["id"]).execute()["snippet"]
f = ai.generate(f"Return JSON supplier, reference, amount from:\n{snippet}", max_output_tokens=80, json_schema={"type": "object",
"properties": {"supplier": {"type": "string"}, "reference": {"type": "string"}, "amount": {"type": "number"}}}).json
buttons = [{"type": "button", "text": {"type": "plain_text", "text": t}, "action_id": t.lower(), "value": json.dumps(f)} for t in ("Approve", "Reject")]
WebClient(token=credentials.connection("slack", "work")).chat_postMessage(channel="#finance", text=f"{f['supplier']} {f['reference']}: {f['amount']:,.2f}",
blocks=[{"type": "section", "text": {"type": "mrkdwn", "text": f"*{f['supplier']}* {f['reference']}: {f['amount']:,.2f}"}}, {"type": "actions", "elements": buttons}])
seen.add(m["id"])
state.set("seen", list(seen)[-500:])
return {"posted": len(msgs)}
@on_event
def clicked(event):
p = json.loads(parse_qs(event.body)["payload"][0])
action, f = p["actions"][0]["action_id"], json.loads(p["actions"][0]["value"])
if action == "approve":
xero("PUT", "/Invoices", json={"Invoices": [{"Type": "ACCPAY", "Status": "AUTHORISED", "Contact": {"Name": f["supplier"]}, "InvoiceNumber": f["reference"],
"LineItems": [{"Description": f["reference"], "Quantity": 1, "UnitAmount": f["amount"], "AccountCode": "400"}]}]})
WebClient(token=credentials.connection("slack", "work")).chat_update(channel=p["channel"]["id"], ts=p["message"]["ts"], blocks=[],
text=f"{f['supplier']} {f['reference']} {f['amount']:,.2f}: {action}d by <@{p['user']['id']}>")
return {"action": action}FAQ
Common questions
Is the bill created as approved or draft?
Can I restrict who approves?
What does the Slack app need?
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
Post overdue Xero invoices to Slack every weekday
Every weekday morning, your finance channel sees unpaid Xero invoices grouped by how late they are, with totals for each group.
See how it worksDraft a Xero invoice for each won deal and approve it in Slack
When a deal is won or an order arrives, a draft Xero invoice is created and posted to Slack, where one click approves it.
See how it worksLabel new emails automatically
New mail is sorted into labels like Inquiry, Invoice and Newsletter within minutes of arriving.
See how it worksKeep exploring
Set up “Approve supplier invoices in Slack before they go into Xero” from your assistant
Copy the prompt above, or connect your assistant first. Free plan, no credit card.