Skip to content

Payment failure follow-up

Your billing system reports failed payments as business events. For each one, send the customer a link to pay, wait a day, remind them once, and hand the case to your collections team if the payment still has not arrived.

Messages go out through an MCP tool on your messaging service, here called send_whatsapp_template.

  1. Business event: event payment.failed, correlation keys customerRef, invoiceId. Only when input.amount > 0. Ignore repeats for 6h.
  2. Data mapper: amountText = str(round(input.amount, 2)).
  3. MCP tool: send_whatsapp_template with to = input.phone, template = "payment_failed_link", amount = amountText, link = input.payLink. Retries 3.
  4. Wait for event: event payment.received, correlation key invoiceId, time out after 24h.
    • received: go to step 7.
    • timeout: go to step 5.
  5. MCP tool: send_whatsapp_template with template = "payment_reminder".
  6. Wait for event: event payment.received, correlation key invoiceId, time out after 48h.
    • received: go to step 7.
    • timeout: go to step 8.
  7. End: outcome paid.
  8. Escalation: queue Collections, reason Invoice {{ input.invoiceId }}: {{ amountText }} unpaid after reminders, SLA 24h.
  9. End: outcome escalated.

Error paths:

  • Connect the On error port of the Escalation (SLA passed) to an Error handler that escalates to Collections leads, then ends with outcome escalation_overdue.
  • Connect the On error port of each MCP tool step to an Error handler that escalates to Collections and ends with outcome message_failed, so a person contacts the customer instead.

Your billing system sends this to POST https://api.nuacem.dev/workflow-api/public/v1/events:

{
"eventName": "payment.failed",
"eventId": "pay-evt-20931",
"correlation": {"customerRef": "C-1001", "invoiceId": "INV-5521"},
"data": {
"customerRef": "C-1001",
"invoiceId": "INV-5521",
"amount": 4999,
"phone": "+919800000000",
"payLink": "https://pay.example.com/INV-5521"
}
}

When the payment arrives, it sends:

{
"eventName": "payment.received",
"eventId": "pay-evt-20977",
"correlation": {"invoiceId": "INV-5521"},
"data": {"invoiceId": "INV-5521"}
}

See Business event.

  • The Business event trigger starts one run per failed payment. The event’s data becomes the run’s input. Ignore repeats for stops a burst of duplicate failures from messaging the customer twice.
  • The Data mapper prepares the amount as text for the message.
  • Each Wait for event ends early when the matching payment.received arrives, so the customer is not reminded after paying.
  • The Escalation opens a case for the collections team in Workflows → Tasks and waits until someone marks it done.
  1. Open Test workflow and start from the Business event trigger with the event data above. Choose Hours as seconds, and point the MCP tool at a sandbox.
  2. Let the first wait time out. The reminder step runs.
  3. In Waiting on you, send payment.received. The run ends as paid.
  4. Run again without sending the payment. The escalation appears as a task; complete it to finish the run.
  • Built-in messaging (beta): use Send message with an SMS fallback instead of the MCP tool. Test it end to end in the test window first.
  • Call before escalating (beta): add an Outbound call with a collections voice agent, and branch on completed, no_answer, busy or voicemail.
  • Different paths by amount: add a Decision after the trigger, for example to send high amounts straight to a person.
  • Remember the issue: Write context lastPaymentIssue for the customer, so later runs can check it with Read context.