The moment it happens
Draft 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.
- Runs
- The moment it happens
- Apps
- Slack, Xero
- AI
- Not needed
- Access
- accounting write; chat:write
Send this to your assistant
Create a ClickRuntime automation: when my CRM sends a won deal or order to this link, create a draft Xero invoice and post it to #finance with an Approve button that authorises it.
First time? Adding ClickRuntime to your assistant takes about two minutes.
Why use it
Why teams use this automation
Sales closes a deal in the CRM and tells finance in a message. Finance re-creates the details in Xero, sometimes days later, sometimes with the wrong amount. Invoices go out late and nobody is sure which deals have been billed.
Drafting the invoice the moment the deal is won removes the hand-off. Posting it to Slack lets someone check the draft and approve it with a click, so speed doesn't cost accuracy.
What you get out of it
Invoice the day the deal closes
Billing promptly brings payment forward and avoids awkward 'we forgot to invoice you' emails.
A check before it goes out
The draft is reviewed in Slack before it's approved, catching wrong amounts or contacts.
Sales and finance stay in sync
Everyone can see which won deals have been invoiced.
No re-typing
Customer, items and amounts come straight from the deal.
How it works
What happens, step by step
Your CRM or order form sends each won deal to your automation's link.
ClickRuntime creates a draft invoice in Xero for the customer and items.
It posts the draft to #finance in Slack with an Approve button.
When someone clicks Approve, the invoice is approved in Xero and the message is updated.
Before it runs live
- Connect Slack, then invite the app to the channel (type /invite @ClickRuntime there)
- Connect Xero
- Paste your automation's link into the other app's webhook settings
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
- Add an AI step, for example to summarize, sort or draft a reply
- 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 slack_sdk import WebClient
from clickruntime import on_event, credentials, http
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_event
def handle(event):
if (event.header("content-type") or "").startswith("application/x-www-form-urlencoded"):
p = json.loads(parse_qs(event.body)["payload"][0])
inv_id = p["actions"][0]["value"]
inv = xero("POST", f"/Invoices/{inv_id}", json={"Invoices": [{"InvoiceID": inv_id, "Status": "AUTHORISED"}]})["Invoices"][0]
WebClient(token=credentials.connection("slack", "work")).chat_update(channel=p["channel"]["id"], ts=p["message"]["ts"], blocks=[],
text=f"{inv['InvoiceNumber']} for {inv['Contact']['Name']} approved by <@{p['user']['id']}>")
return {"approved": inv["InvoiceNumber"]}
deal = event.json
inv = xero("PUT", "/Invoices", json={"Invoices": [{"Type": "ACCREC", "Status": "DRAFT", "Contact": {"Name": deal["name"], "EmailAddress": deal.get("email")},
"LineItems": [{"Description": i["name"], "Quantity": i.get("qty", 1), "UnitAmount": i["price"], "AccountCode": "200"} for i in deal["items"]]}]})["Invoices"][0]
text = f"Draft {inv['InvoiceNumber']} for {deal['name']}: {inv['Total']:,.2f}"
WebClient(token=credentials.connection("slack", "work")).chat_postMessage(channel="#finance", text=text, blocks=[
{"type": "section", "text": {"type": "mrkdwn", "text": text}},
{"type": "actions", "elements": [{"type": "button", "text": {"type": "plain_text", "text": "Approve"}, "style": "primary", "value": inv["InvoiceID"]}]}])
return {"draft": inv["InvoiceNumber"]}FAQ
Common questions
What should the webhook send?
What does Approve do in Xero?
Can I edit the draft before approving?
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 worksApprove 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.
See how it worksPost new orders and sign-ups to Slack
When something happens in your shop, app or form, the details land in the right channel straight away.
See how it worksKeep exploring
Set up “Draft a Xero invoice for each won deal and approve it in Slack” from your assistant
Copy the prompt above, or connect your assistant first. Free plan, no credit card.