ml-connector
XeroTwilio

Xero and Twilio integration

Xero keeps your accounting records current. Twilio delivers messages to customers and team members. Connecting them means invoice reminders go out automatically when invoices are issued, payment confirmations reach customers as soon as payment is received, and overdue notices alert the accounting team without manual effort. ml-connector watches Xero for accounting events and pushes the right notifications through Twilio at the right moment.

How Xero works

Xero is a cloud accounting platform exposing invoices, contacts, purchase orders, payments, accounts, tracking categories, items, manual journals, credit notes, and bank transactions through the Xero Accounting API via REST with JSON or XML responses. Xero authenticates via OAuth2 Authorization Code flow with access tokens that expire in 30 minutes and refresh tokens that expire in 60 days. Xero publishes webhook events for Create and Update actions on invoices, payments, contacts, credit notes, manual journals, purchase orders, and bank transactions; webhooks contain resource IDs only, so ml-connector follows up with a GET to fetch the full record. Delta sync is also available via If-Modified-Since headers for polling. Each request requires the Xero-tenant-id header to target the specific organization, and the API enforces 5 concurrent calls, 60 per minute per tenant, and 5000 per day per tenant.

How Twilio works

Twilio is a cloud communications platform that exposes SMS, voice, email, and verification APIs through multiple REST endpoints authenticated with HTTP Basic Auth using Account SID and Auth Token or scoped API Keys. Twilio supports real-time webhooks for incoming messages, message status changes (queued, sent, delivered, failed, read), incoming calls, call status changes, verification status updates, and usage alerts. Messages are sent via REST POST to the Messages endpoint and can target phone numbers or email addresses depending on the channel. Twilio uses application/x-www-form-urlencoded request format, not JSON, and expects a 200 OK response within an unspecified timeout window. Webhook signatures are validated using HMAC-SHA1 with the Auth Token as the key. Twilio does not guarantee exactly-once webhook delivery, so handlers must be idempotent.

What moves between them

The main flow runs from Xero to Twilio. When an invoice is created or issued in Xero, ml-connector reads the invoice details and the associated contact information, then sends an SMS or email notification through Twilio to the contact's phone number or email address. When a payment is received in Xero, ml-connector sends a payment confirmation. When an invoice remains unpaid past a threshold, ml-connector sends an overdue reminder. Contact changes in Xero can trigger updates to Twilio's stored contact preferences if a two-way sync is configured. The sync is driven by Xero webhooks for near-real-time notifications, with optional polling fallback for missed events.

How ml-connector handles it

ml-connector listens for Xero webhook events on invoices, payments, and contacts, validating the webhook signature using the signing key obtained from Xero's Developer portal. When an event arrives, ml-connector retrieves the full record from Xero using OAuth2 bearer token authentication, extracting the invoice amount, customer contact, and accounting details. It then constructs a message (SMS or email) using a configurable template with variables like invoice number, amount, and due date, and sends the message through Twilio via HTTP Basic Auth. Xero's 30-minute token expiry is handled by caching the refresh token and requesting a new access token before it expires. Twilio message status callbacks are received via webhook and logged for audit purposes. Rate limits are managed by queuing messages when Xero's 60-per-minute threshold is approached. Idempotency is enforced using Xero's invoice ID or payment ID as the dedup key so retries do not trigger duplicate messages.

A real-world example

A mid-sized service firm uses Xero for accounting and invoicing across multiple customer segments. Previously, the accounting team sent invoice reminders manually via email or SMS when invoices were issued and again when they became overdue, a labor-intensive task that often slipped during busy periods. With Xero and Twilio connected, each new invoice automatically triggers a professional SMS notification to the customer with the invoice number and due date, sent within seconds of invoice creation. Payment confirmations go out automatically when payments are received. Overdue invoices trigger reminder SMS to both the customer and the accounting team. The team now spends zero time on manual notifications, customers receive timely reminders without personal follow-up, and cash collection improves because overdue items are escalated immediately.

What you can do

  • Send invoice notifications and payment confirmations via Twilio SMS or email when Xero accounting events occur.
  • Trigger overdue payment reminders based on invoice due dates and payment status in Xero.
  • Map Xero contacts to Twilio phone numbers and email addresses for targeted notifications.
  • Validate Xero webhook signatures and handle OAuth2 token refresh to maintain secure, uninterrupted communication.
  • Deduplicate messages using Xero invoice and payment IDs so retries do not send duplicate notifications.

Questions

Can ml-connector send different message templates based on invoice type or customer segment?
Yes. Templates are configurable per integration and can include Xero fields like invoice number, amount, due date, and tracking categories. Messages can be branched by customer type or region using Xero contact attributes or tracking category assignments, so overdue notices to corporate customers differ from reminders to retail customers.
Does the integration respect Xero's rate limits and Twilio's delivery guarantees?
ml-connector queues messages when Xero's 60-per-minute-per-tenant rate limit is approached and backs off gracefully. Twilio does not guarantee exactly-once delivery, so ml-connector deduplicates using Xero's invoice and payment IDs so retries do not create duplicate SMS or email messages.
What happens if a Xero webhook is missed or Twilio fails to deliver a message?
ml-connector logs all events in its audit trail and can replay missed messages on demand. Xero webhooks are validated by signature before processing. If Twilio delivery fails, the system retries with exponential backoff and logs the failure so the team can review what was not sent and manually re-send if needed.

Related integrations

Connect Xero and Twilio

Free to use. Add your credentials, ping your real systems, and see if we fit.

Get started