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 channel

Under the USSD menu in your sandbox dashboard click Create Channel.

To create a channel you will need a callback 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.

  1. Initialize a node application via yarn init or npm init
  2. 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
  3. In the root directory (current directory) of the app, create a file named index.js and add the following code into the file.
  4. Create another file in the root of your project and name it app.js and add the following code into the file.
  5.  Modify your package.json file to include a script to run the app. The file should then look something like below.
  6.  In your root folder via the terminal type yarn start or npm start to start the app.
  7. Head to our simulator and choose the USSD option.
  8. Dial USSD — Service Code in the simulator which we generated earlier. For my case it is *384*77255#
  9. 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.

featured_image
About the Author

James Muigai

Software Engineer at Andela

More Insights

October 10, 2019

Africa’s Talking Node.js (express) USSD Application

James Muigai

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 channel

Under the USSD menu in your sandbox dashboard click Create Channel.

To create a channel you will need a callback 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.

  1. Initialize a node application via yarn init or npm init
  2. 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
  3. In the root directory (current directory) of the app, create a file named index.js and add the following code into the file.
  4. Create another file in the root of your project and name it app.js and add the following code into the file.
  5.  Modify your package.json file to include a script to run the app. The file should then look something like below.
  6.  In your root folder via the terminal type yarn start or npm start to start the app.
  7. Head to our simulator and choose the USSD option.
  8. Dial USSD — Service Code in the simulator which we generated earlier. For my case it is *384*77255#
  9. 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.

featured_image
About the Author

James Muigai

Software Engineer at Andela

Thanks for subscribing!

 

More Insights

Partners in Delivery: Andela’s Model of Remote Software Engineering Staff Augmentation

In the wake of the COVID-19 pandemic, businesses are looking to streamline operations and find new ...

4_June_2020

How to keep engaging your tech community in a fully-remote world

In-person (offline) tech community meetups have, for the longest time, been the major engagement pl...

29_May_2020

The complete guide to Debug Swift code with LLDB

This guide contains the following content to ease your journey to become an lldb ninja: — Obje...

27_May_2020

Tips for Handling Remote Team Emergencies

Guest post by Ashley Kent. If your company is in the process of transitioning to a remote team, ...

27_May_2020

Remote Engineering Staff Augmentation Aids the Race to Digitize

While the economic shock and aftershocks of the global pandemic continue to ripple through the econ...

26_May_2020

Partners

Tap into a global talent pool and hire the “right” developers in days, not months.

Developers

Accelerate your career by working with high-performing engineering teams around the world.

BECOME A DEVELOPER

Hire Developers

We take great pride in matching our developers with the best partners. Tell us about your team below!

preloader_image

Thank you for your interest

A member of our team will reach out to you soon.