ml-connector
FreshBooksTwilio

FreshBooks and Twilio integration

FreshBooks holds your invoices, payments, bills, and clients. Twilio sends SMS and email notifications to your team and customers. Connecting them lets you notify clients and staff automatically when invoices are created or overdue, when payments arrive, when bills need approval, or when vendors change. ml-connector listens for FreshBooks events, transforms them into Twilio messages, and tracks delivery so nothing gets lost.

How FreshBooks works

FreshBooks exposes invoices, payments, bills, bill vendors, clients, expenses, chart of accounts, items, journal entries, and time entries via REST APIs at https://api.freshbooks.com, organized by accounting account (accounting namespace) and business (time-tracking namespace). Authentication uses OAuth 2.0 user-delegated authorization through https://auth.freshbooks.com/oauth/authorize, which requires user interaction and returns a bearer token tied to the authorizing user's permissions. FreshBooks delivers real-time webhooks for invoice, payment, bill, client, and expense events via POST to a registered endpoint, with HMAC-SHA256 signature validation. Webhook payloads arrive as application/x-www-form-urlencoded data, not JSON, and include object_id, account_id, business_id, and event identity fields. Delivery is not real-time (can take seconds to minutes), and non-2xx responses or timeouts beyond 10 seconds trigger retries until persistent failures disable the callback.

How Twilio works

Twilio exposes SMS and email APIs as part of a broader communications platform, with Messages, Calls, IncomingPhoneNumbers, and Verify endpoints at https://api.twilio.com/2010-04-01 and https://messaging.twilio.com/v1 for messaging services. Authentication uses HTTP Basic Auth with either Account SID and Auth Token, or API Key SID and API Secret, both supported at the same endpoints. Twilio accepts webhook callbacks for incoming messages, message status (queued, sending, sent, delivered, failed, read), voice calls, and call status, with HMAC-SHA1 signature validation using the Auth Token as the key. Request bodies use application/x-www-form-urlencoded format, not JSON. Twilio delivers webhooks via POST and expects 200 OK or 2xx response; delivery is not guaranteed exactly-once, so handlers must be idempotent.

What moves between them

FreshBooks invoices, payments, bills, clients, and expenses trigger events that ml-connector captures via webhook or scheduled polling. For each event, ml-connector matches FreshBooks data to Twilio recipient lists (clients, staff email addresses, or phone numbers) and message templates (invoice created, overdue notice, payment received, bill approval request, vendor change alert). ml-connector then sends SMS or email notifications via Twilio, records the Twilio message ID, and polls Twilio's message status endpoint to capture delivery confirmation (sent, delivered, failed). If a message fails, ml-connector logs the error with full context so the notification can be re-sent manually or retried. Data flows one direction: FreshBooks events trigger Twilio messages, but Twilio message replies do not flow back into FreshBooks.

How ml-connector handles it

ml-connector stores FreshBooks OAuth credentials (refresh token) and Twilio API Key, refreshing the FreshBooks token when it expires and using Twilio HTTP Basic Auth on each request. It subscribes to FreshBooks webhooks for invoice, payment, bill, and client events, validates each webhook's HMAC-SHA256 signature against the registered secret, and parses the application/x-www-form-urlencoded payload to extract object_id and account_id. For each event, ml-connector looks up the corresponding FreshBooks object via REST (invoice details, client contact info, bill vendor email), maps it to message template placeholders (invoice number, amount due, due date, client name, vendor name), and resolves Twilio recipients by matching FreshBooks client email or phone to a configured recipient list. It then calls Twilio's Messages endpoint with the populated template, receives the message SID, and stores it in the audit trail. ml-connector polls Twilio's message status endpoint periodically to capture delivery status (delivered, failed, undelivered) and logs final status. If Twilio returns 429 (rate limit), ml-connector backs off and retries. If a message fails, ml-connector flags the record as failed-delivery so the event can be retried or escalated to manual follow-up. Because FreshBooks webhooks can arrive out of order or be delayed, ml-connector deduplicates by (object_id, account_id, event_type) to avoid sending duplicate notifications.

A real-world example

A mid-sized accounting firm handles invoicing and expense management for 50+ clients using FreshBooks. Before integration, the firm manually called or emailed clients when invoices were overdue and when bill vendors were added or changed, creating delays and inconsistent follow-up. Staff also missed payment confirmations and had to check FreshBooks daily for outstanding bills needing approval. With FreshBooks and Twilio connected, the firm now sends automatic SMS overdue reminders to client contacts 5 and 10 days past due, email confirmations to clients when payments arrive, and text alerts to approvers when new vendor bills arrive. The firm also sends vendor change notifications via email so clients know their invoices may be processed differently. Monthly manual outreach dropped by 70%, follow-up is instant and consistent, and the team spots payment issues before month-end close.

What you can do

  • Send SMS and email notifications from FreshBooks invoice, payment, bill, and client events to configured recipient lists.
  • Map FreshBooks invoices, amounts due, and due dates into Twilio message templates for overdue reminders, new invoice notices, and payment confirmations.
  • Authenticate FreshBooks via OAuth 2.0 user delegation and Twilio via HTTP Basic Auth with API Key, refreshing tokens as needed.
  • Validate FreshBooks webhook signatures (HMAC-SHA256) and Twilio message status callbacks (HMAC-SHA1) to ensure authenticity.
  • Track Twilio message delivery status (sent, delivered, failed) and log failed notifications for manual retry or escalation.

Questions

Can ml-connector send Twilio messages only to certain clients or vendors?
Yes. ml-connector resolves FreshBooks client email and phone number to a configurable recipient list per client or vendor, so you can target notifications to specific contacts. You can also use message templates with conditional logic to send different messages to clients versus internal staff based on the event type.
What happens if a FreshBooks webhook arrives late or a Twilio message fails to deliver?
ml-connector deduplicates FreshBooks events by (object_id, account_id, event_type) to prevent duplicate messages if a webhook is delayed or resent. If a Twilio message fails, ml-connector logs the failure with full context (invoice number, client, reason) so you can retry manually or configure an alert. Retries are tracked in the audit trail.
Does ml-connector support other notification channels besides SMS and email?
ml-connector currently supports Twilio SMS and email (via Twilio Messaging Services). Twilio also provides voice and video APIs, which can be integrated if your use case requires automated invoice-related voice calls or video notifications, but the standard integration focuses on SMS and email for invoicing workflows.

Related integrations

Connect FreshBooks and Twilio

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

Get started