Twilio Payment Reminder and Dunning SMS
For invoices that become overdue in Dataverse (or QuickBooks/Xero), the flow runs a staged SMS dunning sequence via Twilio (gentle, firm, final) with a secure pay link, stops on payment, escalates unresolved accounts to a collector, and logs every message. Recovers receivables on the channel customers actually read.
Provided as-is, without warranty of any kind. Review and test each pattern in a non-production environment before deploying it to live automations. See our Terms.
Overview
This flow recovers overdue receivables with a staged SMS dunning sequence on Twilio. Once a day it scans Dataverse for unpaid invoices whose due date has passed and advances each one through a respectful escalation ladder — gentle → firm → final notice — texting the customer a secure pay link at each stage. Invoices that pass an escalation threshold are handed to a collections specialist by email. Each invoice's dunning stage and last-reminder timestamp are written back to Dataverse so the sequence advances one step per stage and never repeats a message.
Why it matters: Email dunning gets ignored; SMS gets read. A staged text sequence with a one-tap pay link recovers more invoices, faster, than email alone — and the write-back makes the cadence idempotent and auditable.
Status: Built as a FlowLibs reference implementation. Ships Off; going live requires only connection authorization and environment-variable configuration.
Use Case
A finance/AR team wants overdue invoices chased automatically by SMS with a clear, configurable escalation ladder and a pay link, stopping the moment an invoice is marked Paid, and escalating the worst offenders to a human collector.
Flow Architecture
Recurrence Daily Dunning Run
Recurrence (Day/1, 08:00 ET)Daily dunning cadence that scans for overdue invoices.
Initialize configuration variables
Initialize variableSets configurable stage thresholds (gentle 3 / firm 10 / final 20 / escalate 30 days) and binds the four environment variables (Twilio from number, collector email, invoice table, pay-portal base URL) to working variables.
List Overdue Unpaid Invoices
Dataverse ListRecordsQuery invoices where status = Unpaid and due date has passed.
Apply to each Invoice
Foreach (concurrency 1)For each overdue invoice: compute days overdue and the target stage, build the pay link (stored link or portal base + invoice number), and — only when the computed stage is greater than the stored stage — route via a Switch to the gentle / firm / final reminder SMS (Twilio SendMessage). On the final stage, if days overdue ≥ the escalation threshold, email the collections specialist (Outlook SendEmailV2). Finally write the new stage + last-reminder timestamp back to the invoice (Dataverse UpdateRecord) for idempotency and audit.
Environment Variables
| Schema name | Type | Default | Description |
|---|---|---|---|
| flowlibs_TwilioFromNumber | String | +15551234567 | Verified Twilio sender number (E.164). (reused) |
| flowlibs_DunningCollectorEmail | String | collections@yourcompany.com | Collections specialist mailbox for final escalations. |
| flowlibs_DunningInvoiceTable | String | flowlibs_dunninginvoices | Entity set name queried by ListRecords. |
| flowlibs_DunningPayPortalBaseUrl | String | https://pay.yourcompany.com/invoice/ | Pay-portal base URL; invoice number is appended to build a link when none is stored. |
Connectors & Connections
| Connector | API name | Actions used |
|---|---|---|
| Twilio | shared_twilio | SendMessage |
| Microsoft Dataverse | shared_commondataserviceforapps | ListRecords UpdateRecord |
| Office 365 Outlook | shared_office365 | SendEmailV2 |
Note — All connections are referenced as solution connection references; the flow is portable between environments as long as a connection is mapped at import time.
Customization Guide
Almost every realistic variant of this flow can be implemented by changing environment variable values. A few cases require small edits inside the flow definition — those are called out explicitly below.
- Source of truth
- Point ListRecords (and the table) at a different invoice store, or read overdue status from QuickBooks/Xero instead of Dataverse.
- Pay link
- Store a real Stripe/PayPal pay link in flowlibs_paylink per invoice, or change flowlibs_DunningPayPortalBaseUrl to your portal.
- Stage cadence
- Tune the gentle/firm/final/escalate day thresholds in the four Initialize variable actions.
- Message wording
- Edit the three Twilio SMS bodies and the escalation email HTML to match brand voice and compliance disclosures.
- Promise-to-pay / replies
- Add an inbound-SMS flow that sets a promise date and pauses reminders by advancing flowlibs_dunningstage.
Key Expressions
The flow is intentionally light on Power Fx / WDL gymnastics — the heaviest expressions are the branch-name concatenation and the approval outcome check. They are listed below in the order they appear in the flow.
EXPR.01Days overdue
Whole days past due (ticks diff ÷ ticks-per-day).
EXPR.02Stage number
Maps days overdue to stage 3 (final) / 2 (firm) / 1 (gentle) / 0 (none).
EXPR.03New-stage guard (If)
Acts only when the computed stage exceeds the stored stage (no repeat sends).
EXPR.04Pay link fallback
Uses the stored pay link, else builds one from the portal base URL + invoice number.
EXPR.05Overdue-unpaid filter (ListRecords $filter)
Selects unpaid invoices whose due date has passed; an invoice marked Paid drops out automatically.
Customize & download
Generate a ready-to-import copy of this solution with your environment-variable values baked in — available on Base, Pro, or Team.
Upgrade to customize
Comments
Sign in to join the conversation.
Sign inNo comments yet. Be the first to share your experience with this flow.