Turn signed SignWell contracts into draft Xero invoices

By General Input

The moment a customer signs, the invoice is drafted in Xero with the right amount and due date, and your finance channel gets the details.

Integrations

  • SignWell
  • Xero
  • Slack Bot

Type

Deterministic Code

Categories

  • Finance
  • Operations

When a customer signs a contract in SignWell, I want the invoice raised in Xero the same minute, instead of waiting for someone to notice the signed document and key it into the accounting system by hand. Build this as a code workflow: every step is a fixed mapping from signed document fields to invoice fields, with no matching ambiguity.

Trigger the workflow with a webhook on the SignWell document_completed event. That is the event SignWell fires once every signer has finished, and it carries the id of the completed document.

Before doing anything else, check the document name against a contract naming pattern and stop the run if it does not match. Only billable paperwork should ever reach Xero, so NDAs, consent forms, and other non billable documents are ignored. Default the pattern to names containing Contract, Service Agreement, MSA, or Order Form, case insensitive, and keep it in one clearly marked place at the top of the workflow so it is easy to edit.

For documents that pass the filter, call SignWell Get Document with the document id from the webhook payload. Read the signer name, signer email, and company from the recipients, and read the completed field values off the document: the agreed amount, the plan, the billing term, and the payment terms. Note that fields on a SignWell document is a two dimensional array with one inner array per file, so flatten across the files and match values by their field label or api id rather than assuming a flat structure or a fixed position.

Then set up the customer in Xero. Look the contact up first with List Contacts filtered on the signer email so a repeat customer is reused rather than duplicated, and only call Create Contacts when there is no match. Use the company name from the document as the contact name when there is one and fall back to the signer name, and set the signer name and email as the contact's primary person. Every Xero call needs the tenant id of the target organisation.

Raise the invoice with Create Invoices as an accounts receivable invoice in DRAFT status, never approved or sent, so a human approves it before it reaches the customer. Build the line item from the plan and the agreed amount read off the contract. Put the SignWell document id into the invoice reference field so finance can reconcile any invoice back to the exact signed contract later. Derive the due date from the payment terms field on the document rather than hardcoding it: read the terms, for example Net 15, Net 30, or Due on receipt, and add the matching number of days to the completion date, falling back to Net 30 only when the field is empty.

Finish by posting to the finance channel with Slack Bot Send a Message, showing the customer, the invoice amount, the due date, and the invoice reference, plus a note that the invoice is sitting in draft and needs approval.

If the agreed amount or the payment terms field is missing or cannot be parsed, do not guess. Skip the invoice and post a Slack message naming the document and the missing field so someone can finish it manually.

Related prompts

Explore more prompts
Call overdue Xero customers with an AI collections agentA brand asset library your marketing team actually searchesTurn Mailjet email clicks into ranked HubSpot follow-upsClean out the Looker dashboards and Looks nobody opensLiveKit live operations console for room moderationWake up dormant Keap leads with a researched reasonLiveChat coverage board for planning next week's shiftsPhone routing control panel for LiveKit voice agentsLinkedIn Ads budget pacing dashboard for every client accountGive your team Looker numbers without buying more seats