Africa’s Talking Node.js (express) USSD Application
The app developed here will help a user to view their phone number and account details (Account number and account balance).Follow this article to set up a simulator.After you have launched the simulator, go back to your sandbox dashboard and create a channel. A channel will help us to run our implementation. A channel will constitute a Service Code and Callback URL.A Service Code is the USSD code that we are going to type on our simulator and it will call the callback url upon hitting send. You can imagine a situation whereby someone is checking their balance. For instance, they will enter *144# and hit send. The *144# is a Service Code. Upon hitting send, a callback URL will be called, the URL endpoint will help to carry out the needed operations which will be to determine the actual calculation of the balance and return the results.How to create a channelUnder the USSD menu in your sandbox dashboard click Create Channel.

To create a channel you will need acallback URL. A callback URL will be called when a user sends a request using a service code.Create a callback URL
- Head to https://dashboard.ngrok.com/user/signup and create an account or login if you have one.
- Download and unzip ngrok which will help us to access our localhost server through the internet.
- After downloading the ngrok open a terminal window and navigate to the directory where you downloaded the setup.

- Copy the command shown in the above screenshot and enter it in the terminal. Note: The above command should be run int the directory where you downloaded the ngrok

- Run ./ngrok HTTP 3000 to start an HTTP tunnel to our localhost on port 3000. You will be able to see something like shown below.

- Copy the Forwarding URL. For my case it is http://b483439b.ngrok.io
- Paste the link in the callback URL field and input a channel of your choice and if the channel is not available you will get a suggestion as shown in the image below.

We should have something as shown below in our USSD — Service Codes.

Now that we have a channel fully configured we can start writing code.
- Initialize a node application via yarn init or npm init
- Install express, nodemon, body-parser and Africa's Talking dependencies via yarn add express nodemon Africa's Talking body-parser or npm install express Africa's Talking nodemon body-parser -— save
- In the root directory (current directory) of the app, create a file named index.js and add the following code into the file.

- Create another file in the root of your project and name it app.js and add the following code into the file.

- Modify your package.json file to include a script to run the app. The file should then look something like below.

- In your root folder via the terminal type yarn start or npm start to start the app.
- Head to our simulator and choose the USSD option.
- Dial USSD — Service Code in the simulator which we generated earlier. For my case it is *384*77255#

- The following screenshots show the results after dialing the USSD code.

Feel free to play around with the options provided. This means that our USSD app if fully functional.
Related posts
The latest articles from Andela.

How to hire a Python developer: A guide to finding the right fit

Top takeaways from Gartner IT Symposium
.png)
Android ML face detection with Camera X
We have a 96%+
talent match success rate.
The Andela Talent Operating Platform provides transparency to talent profiles and assessment before hiring. AI-driven algorithms match the right talent for the job.
