...
UI options
Caller phone: using international format ( + ).
Short code: USSD code user contacts with.
Developer options: turn on to enable 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.
...
Code Block |
---|
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
CORS issues: since the requests are performed from/to, for local development a header can be added to the response from the backend: Access-Control-Allow-Origin : *
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)Input fields can have hardcoded values for quick demo but can be edited except SessionID field.
USSD SIMULATOR Repository
...