Skip to content

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.

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

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

  1. Your CRM or order form sends each won deal to your automation's link.

  2. ClickRuntime creates a draft invoice in Xero for the customer and items.

  3. It posts the draft to #finance in Slack with an Approve button.

  4. 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

RunsThe moment it happens
Draft a Xero invoice for each won deal and approve it in Slackjust nowSucceeded
Slack · #financeDraft INV-0435 for Acme Ltd: 6,000.00 [Approve]

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
  • 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

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.
create_a_draft_xero_invoice_and_confirm_in_slack.pyexample
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?
The customer's name and email, and the line items with prices. CRMs and form tools can send these when a deal changes to won.
What does Approve do in Xero?
It changes the invoice from draft to awaiting payment, exactly as approving it in Xero does.
Can I edit the draft before approving?
Yes. Open it in Xero, make changes, then click Approve in Slack.
What permissions does it need?
accounting write; chat:write. Nothing else in your accounts is used.
Does it need AI?
No. It runs without AI, so it doesn't use your plan's AI allowance.
How many runs does it use?
One run for each event the app sends.
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 “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.