/
USSD Simulator

USSD Simulator

Ā 

UI options

  • Caller phone: using international format ( + ).

  • Short code: USSD code user contacts with.

  • Developer options: Toggling the switch to ā€˜onā€™ will enable:

    • URL: backend endpoint where the payload is sent.

    • Session ID: readonly field, generated on each ā€œcallā€.

    • Request logger: displays JSON response for each request.

  • Input: userā€™s answer for each interaction

  • Send: performs a new request with provided input (can be triggered by pressing ā€˜Enterā€™ while input typing on input field)

  • Message box: displays backend message response (breaklines are replaced for <br> tags)

  • Call: (green) performs the initial request to the USSD backend endpoint. It creates a new session ID.

  • Hang up: (red) ends current session and clears Message and Logger boxes.

USSD Request payloads: (USING bLive Format)

Each call to the backend performs a GET request with the following parameters:

  • ms: caller phone (msisdn) in format 257xxxxxxxx

  • op: operator friendly name (Fixed value for demo)

  • inp: user input (empty string for first request)

  • kw: A parameter used in bridge system to differentiate services (Fixed value for demo)

  • tx: transaction number or session identifier

Ā 

The expected response to each request will be a JSON object with the next parameters:

  • session: transaction number or session identifier

  • msisdn: phone number (msisdn) in format 257xxxxxxxx

  • code: (optional) short code (Null for demo)

  • message: text to be displayed to the user

  • type:Ā 

    • REQUEST: continue session

    • END: end session

PARSING bLive format request payload

In order to be aligned with previous code, an aux function can be:

const parseInputBLIVE = (data) => { Ā Ā Ā Ā let sessionId = data.tx Ā Ā Ā Ā let phoneNumber = data.ms[0]!=='+'?`+${data.ms}`:data.ms Ā Ā Ā Ā let shortCode = null Ā Ā Ā Ā let userInput = data.inp Ā Ā Ā Ā return { Ā Ā Ā Ā Ā Ā Ā Ā sessionId, Ā Ā Ā Ā Ā Ā Ā Ā phoneNumber, Ā Ā Ā Ā Ā Ā Ā Ā shortCode, Ā Ā Ā Ā Ā Ā Ā Ā userInput Ā Ā Ā Ā } } data: req.query (url parameters from GET request)

Ā 

NOTES

  • DHIS2 Requests: since the phone number (msisdn) coming from the provider input misses the + character for international format, this should be added and encoded when requesting phone number fields in DHIS2, e.g. if phone number at provider input is 12345678, requests to DHIS2 needs to be %2B12345678 (URL Encoded)

USSD SIMULATOR Repository

USSD Simulator demo can be found at: https://github.com/fernandogmz/USSD_Simulator

  1. Clone repository

  2. Install dependencies

  3. Run project with ā€œnpm startā€

Related content