Developers
USSD lets customers use a menu on any phone by dialling a short code. It is perfect for balance checks, payments and registrations, especially for customers who are offline.
How a session works
When a customer dials your code, AvenoLink calls an endpoint on your server for every step. The request includes the session id, the phone number and a text value holding the choices made so far, joined by an asterisk.
- Reply with CON to keep the session open and show another menu.
- Reply with END to show a final message and close the session.
A minimal handler
JavaScript
export async function POST(request) {
const { text } = await request.json();
const steps = text ? text.split("*") : [];
if (steps.length === 0) {
return new Response("CON Welcome\n1. Check balance\n2. Buy airtime");
}
if (steps[0] === "1") {
return new Response("END Your balance is MWK 12,500");
}
return new Response("END Thank you");
}Design tips
- Keep menus to four or five options.
- Number every option so customers reply with a single digit.
- Answer quickly, because sessions time out fast.
- Always finish with END and say what happens next.
A
All articlesAvenoLink Team
Product and engineering