Building the USSD Relay Server & Gateway Integration
This page covers building the Node.js Express server that acts as the bridge between the Africa's Talking USSD gateway and the InclusiveDeFi contract on Rootstock Testnet. It also covers registering your USSD callback with Africa's Talking and exposing your local server to the internet using ngrok.
How the Relay Server Works
The relay server is a stateless HTTP server exposing a single POST /ussd endpoint. Each keypress on a user's feature phone triggers Africa's Talking to send an HTTP POST request to this endpoint. The server reads the accumulated session input from the text field, determines user intent, calls the appropriate contract function, and returns either a CON (continue) or END (terminate) response string.
This proof of concept includes no database, no session store, and no authentication layer. The entire session state lives in the text field of each incoming request.