Contact Centres

Fix a failed top-up or bundle purchase through AI chat

Workflow purpose

This guide demonstrates how to use Proto's AI agent to fix one of the most frustrating problems in prepaid mobile: money has gone, but the airtime or data bundle hasn't arrived.

The workflow finds the transaction in your billing system by reference, or by number, amount and time, and replies according to what actually happened – credited late, still pending, failed and already refunded, or failed with the money still missing. When the payment went through but delivery didn't, it re-triggers delivery once, after checking the line hasn't already been credited. When it can't fix the problem, it opens a refund request with a clear timeline.

For top-ups paid with mobile money, the workflow also checks the wallet provider's side, because the money can leave the wallet without the operator ever receiving it.

Who can benefit from this guide:

  • Mobile network operators handling top-up and bundle complaints
  • Mobile money providers selling airtime from the wallet
  • Billing and revenue assurance teams reducing manual refunds
  • Customer care teams with high volumes of missing-credit calls
  • Regulators who expect complaints resolved within a set time

Fix a failed top-up

This workflow traces a failed top-up or bundle, re-delivers it once and raises a refund request if money is still missing. See how to build a failed top-up workflow.

Just starting with the platform?
For initial setup of your AI agent – including workspace setup, agent training, and channel deployment – please start here. This workflow guide assumes your AI agent is set up and ready for more advanced configurations.

1. Create a trigger

Start the flow when a person says they paid but didn’t get what they paid for.

  • Navigate to the Workflows tab in the AI agent settings.
  • Click New workflow and select Message received as the Workflow type.
  • Name the trigger (e.g. “Failed Top-up”) and add a short description (e.g. “Triggers if a subscriber says a top-up, recharge or bundle purchase failed, that money or airtime was deducted but no credit or bundle arrived, or that their data hasn’t renewed after paying.”).
  • Add training phrases (e.g. “I topped up but got nothing”, “My bundle didn’t activate”, “Money was deducted but no airtime”, “Recharge failed”, “My data plan hasn’t renewed even though I topped up”).

The balance and bundles workflow also jumps here when a purchase times out, with its order reference already set in order_ref.

2. Find out what failed and how it was paid

The answer decides which systems the AI agent checks.

Add a Send message action with quick replies:

“I’m sorry about that – let’s find the payment. What didn’t arrive?”

Quick replies: Airtime top-up | Data or voice bundle | Bundle bought for someone else

Add a Set variable action: purchase_type = {_user_input}. Then add a second Send message with quick replies:

“How did you pay?”

Quick replies: From my airtime | Mobile money | Bank card | Scratch card or voucher

Store the answer in payment_method. Paying from airtime only applies to bundles, so if purchase_type is Airtime top-up, leave that quick reply out by sending a separate message without it.

3. Collect the transaction details

Ask for what the person can see on their phone, and let them skip what they can’t.

Add a Branch action: if order_ref already has a value (the person came from the balance and bundles workflow), skip straight to Step 4.

Otherwise, add an Ask survey action. Action title: Failed payment details

Field Variable Type Invalid reply
The number that should have been credited msisdn Phone Please enter the full number, including the country code
Amount you paid amount Number Please enter the amount as a number, e.g. 500
When you paid (e.g. today at 9:30) paid_at Text Please tell us roughly when you paid
Transaction or receipt reference order_ref Text Please enter the reference from your payment message

Turn on Enable skip for the reference. On WhatsApp, add quick replies to the first field with {_channel_profile.phone_number}, so most people can tap their own number.

4. Look up the transaction

Search your billing system before saying anything about what happened.

Add a Send API action:

  • HTTP method: GET
  • URL endpoint: your billing system’s transaction search endpoint, with msisdn, amount, paid_at and order_ref as parameters
  • Headers: the authorisation key your system requires
  • Resulting variable: txn_search

On Success, parse it with Set variable: txn_search = _.json_parse(txn_search). Your endpoint should match by reference when there is one, and otherwise by number and amount within a few hours of paid_at. Then add a Branch on _.len(txn_search["results"]):

Matches Next
1 Set txn = txn_search["results"][0] and continue
More than 1 Send message: “I found more than one payment. Which one is it?” Quick replies {txn_search["results"][0]["label"]}, {txn_search["results"][1]["label"]} and {txn_search["results"][2]["label"]} – empty ones are dropped. Set txn from the one chosen
0, paid by mobile money Continue to Step 5 – the money may not have reached the operator
0, any other method Send message: “I can’t find a payment of {amount} to {msisdn} around that time. Please check the reference on your payment message.” Allow one retry with a Jump to Step 3, then go to Step 7

Under Error and Timed out, don’t guess – open the refund request in Step 7 with the tag lookup-failed.

5. Check the wallet side for mobile money

Find out whether the money left the wallet, and where it went.

For mobile money payments, add a Send API action with GET to the wallet provider’s transaction status endpoint, passing order_ref or msisdn, amount and paid_at. Store it in wallet_txn and parse it.

Add a Branch:

Wallet result Billing result Meaning
Debited Found Payment reached the operator – carry on with the billing status in Step 6
Debited Not found Money left the wallet but didn’t reach the operator – set txn_status = failed-not-refunded and go to Step 7
Reversed to wallet Any Set txn_status = failed-refunded
Not debited Not found Send message: “This payment wasn’t taken from your wallet, so nothing was charged. You can try again.”

Keep the wallet provider’s reference in wallet_ref, because the refund team will need it to reconcile with the provider.

6. Reply based on what happened

Give each outcome its own answer, in plain words.

Add a Branch on txn["status"] (or txn_status from Step 5):

Status Reply
delivered “Good news – your {purchase_type} arrived at {txn[“delivered_at”]}, a little later than usual. Your balance now shows it.“ Offer a quick reply, Check my balance, that Jumps to the balance workflow
pending “Your payment went through and the credit is still being processed. It usually arrives within 30 minutes. If it hasn’t by {txn[“expected_by”]}, message us again and I’ll take it further.“
failed-refunded “The {purchase_type} failed, and the {amount} was returned to your {payment_method} on {txn[“refunded_at”]}. You don’t need to do anything.“
failed-not-refunded Continue to Step 7 if the payment can’t be delivered, or to the re-delivery below if it can

For a pending status older than your billing system’s normal delay, treat it as stuck: set txn_status = failed-not-refunded and continue.

When txn["can_redeliver"] is true, add a re-delivery. First, add a Branch that stops if redelivery_attempted is already Yes – the AI agent re-triggers delivery once per transaction, never twice. Then add a Send API action with GET to the transaction endpoint again, to check the line hasn’t been credited since the first lookup. Only if it still hasn’t, add a Set variable action (redelivery_attempted = Yes) and a Send API action:

  • HTTP method: POST
  • URL endpoint: your billing system’s re-delivery endpoint
  • Body: txn["id"] as the idempotency key, and msisdn
  • Resulting variable: redelivery

On Success, send: “Done – I’ve re-sent your {purchase_type} to {msisdn}. It should show in your balance within a few minutes.” Under Error and Timed out, don’t try again – continue to Step 7.

7. Raise a refund request

When money is missing and can’t be delivered, give the refund team a complete case and the person a clear timeline.

Add a Create ticket action:

  • Assignee: your billing or refunds team
  • Subject: Failed {purchase_type} – {msisdn} – {amount}
  • Description: the payment method, amount, time, billing reference, wallet reference (wallet_ref), the status found and whether a re-delivery was tried
  • Full name and Email: collect them first with a short Ask survey (full_name, Text; email, Email, with Enable skip); Phone number: {msisdn}
  • Auto-apply tags: failed-top-up, plus mobile-money, redelivery-failed or lookup-failed where they apply
  • Custom fields: payment method (single select), amount and billing reference, so the team can reconcile in batches

Add a Send message:

“I’ve raised a refund request – your reference is {_new_ticket.short_id}. Refunds are usually completed within 3 working days, back to the {payment_method} you paid with. A member of our team will reply to you here if they need anything.”

There’s no automatic message when the ticket status changes, so the refunds team replies from the ticket in the Inbox when the refund is done. To hold the team to the timeline, set the teamspace’s overdue rule in Settings › Tickets › Overdue rules – for example, Apply overdue status after 3 days with Exclude weekends on. The rule applies to every ticket in the teamspace, so use an Inbox view filtered on the failed-top-up tag to keep these cases together.

8. Hand over repeated failures

A second failure is a pattern, not bad luck – put a person on it.

Your transaction search can return recent failures for the number. Add a Branch before Step 7’s message: if txn_search["recent_failures"] is 3 or more in the last 30 days, or the person has said it’s happened before, add repeat-failure to the tags and add a Send message: “This has happened to you more than once, so I’m passing you to our team to look at your line.” Then add a Live agent handoff to your billing team with Live agent availability check on.

Under If there is no live agent online, send: “Our team is offline now. Your case {_new_ticket.short_id} is marked as a repeat problem and they’ll reply here as soon as they’re back.”

Repeated failures can point to a problem with the line, the payment channel or a vendor – the live agent sees the whole chat in the Inbox and can check all three.

9. Test the flow

Validate every path before going live using the AI agent tester side panel.

  • Test each billing status – delivered, pending, failed and refunded, failed and not refunded – and check the reply for each.
  • Trigger a re-delivery, then try the same transaction again and confirm the AI agent doesn’t re-deliver a second time.
  • Simulate a mobile money payment that left the wallet but isn’t in billing, and confirm the ticket carries the wallet reference and the mobile-money tag.
  • Return two matching transactions, then none, and check the selection quick replies and the retry message.
  • Build and test in an undeployed version – Duplicate the live version first – then click Deploy when every path passes.

Finalise the AI agent deployment by configuring your preferred channels and languages.