This application is an example of a USSD service using Africa's Talking, developed with Node.js, Express, and TypeScript. The service simulates a simple mobile banking application allowing users to check their balance, send money, and buy airtime.
- Interactive USSD menu
- Balance checking
- Money transfer
- Airtime purchase
- Integration with Africa's Talking API
- User Interaction: The user dials the USSD code (*123#) on their mobile phone.
- Mobile Network: The request is routed through the mobile network operator.
- Africa's Talking Gateway: The mobile operator forwards the request to Africa's Talking's USSD gateway.
- Your Application: Africa's Talking sends an HTTP POST request to your application's callback URL.
- Application Processing: Your application processes the request and determines the appropriate response.
- Response Chain: The response travels back through the same path to the user's phone.
- Session Management: For menu-based interactions, the session is maintained until completion or timeout.
The entire process typically completes within seconds, providing a responsive experience even on feature phones without internet connectivity.
The diagram below illustrates the flow of data in the USSD application:
- Node.js (v14 or higher)
- Africa's Talking account
- Ngrok or similar service to expose your local server to the Internet
-
Clone this repository:
git clone https://github.com/yaasiin-ayeva/ussd-africas-talking-app.git cd ussd-africas-talking-app
-
Install dependencies:
npm install
-
Configure environment variables:
- Copy the
.env.example
file to.env
- Fill in your Africa's Talking account information
- Copy the
- Log in to your Africa's Talking account
- Create a new USSD service
- Configure the callback URL to your server:
https://your-domain.com/ussd/callback
npm run dev
npm run build
npm start
To test the application with Africa's Talking, you need to expose your local server to the Internet. You can use Ngrok:
ngrok http 3000
Use the URL generated by Ngrok as the callback URL in the Africa's Talking console.
- Dial the USSD code (e.g.,
*123#
) - Navigate through the menu:
- Option 1: Check your balance
- Option 2: Send money (you'll need to provide the recipient's number and amount)
- Option 3: Buy airtime (you'll need to enter the amount)
Africa's Talking provides a USSD simulator in their console to test your application:
- Go to the USSD section of your Africa's Talking account
- Use the simulator with the service code you configured
- Interact with your application
To extend this application, you can:
- Add a database to store user information
- Implement user authentication
- Add more features like international money transfers
- Integrate other Africa's Talking services like SMS
To deploy on local mobile networks in African countries:
- Establish partnerships with telecom operators
- Obtain short codes through operators or Africa's Talking
- Comply with local telecom regulations
- Perform thorough testing across different networks
- Optimize for network reliability issues common in some regions