Lesson 1: A Step by Step Tutorial on How to Create a USSD Menu Using Africa’s Talking Gateway in Laravel 5.8 and PHP 7.2.10

Lesson 1: A Step by Step Tutorial on How to Create a USSD Menu Using Africa’s Talking Gateway in Laravel 5.8 and PHP 7.2.10

Hello and welcome to this PHP/Laravel tutorial series, my name is Henry Mbugua and I will be taking you through the various aspects and new answers of how to build real-time interactive text-based solutions that can be accessed on every type of mobile phone, including feature phone, thus a USSD menu. Every time you dial *ABC# to check your bundle balance or to buy bundles on your phone, you are using a more than one-decade old technology called USSD (Unstructured supplementary service data) which has revolutionized how business is done in Kenya and across Africa as a continent. Learn more about USSD technology.

Why Build A USSD Menu?

According to Africa Internet User Stats, Internet penetration in Africa is very low compared to the rest of the world and that is one of the main reasons why USSD is very important in the Africa market. From Banking to the Transport Industry, USSD is playing a key role in the business economy and return on investment can be measured in terms of customer satisfaction and operational efficiency. Furthermore, USSD codes work across all cellular networks. A good example is how we use *544# in Kenya to buy bundles or check data balances, now you can imagine how much income is generated by Safaricom using USSD menu.

What USSD menu will we be building?

Now that we have a quick overview of what the USSD menu can do to a business income. We are going to describe what we will build in this tutorial series. Let’s assume that at HLAB, we offer online courses for the Django web framework and Laravel web framework. We are going to create a USSD menu that allows users to register using first name, last name, email, and select which framework they would learn. We will also ask the user to select the mode of preferred payment and Lastly, we will learn how to store that data in the database. The following is a breakdown of what we will build:

  • A USSD menu that helps register for online classes.
  • The USSD menu we comprise of nested steps so as to see how we track the steps.
  • Learn how to save the USSD response in our database.
  • Lastly, we will learn how to create an STK push from USSD.

Setting up a development environment

The next step is to set up our Laravel development environment. In this tutorial, I am assuming that you have either Xampp, Lamp, Wamp or Mamp installed. We will also need a composer installed to manage Laravel dependencies. The following are important links to get you started:

Now that we are already set up for Laravel development, I am going to launch my terminal and navigate to a folder that I want to create this Laravel project. I am going to run the following command to create a new Laravel project:

composer create-project --prefer-dist laravel/laravel hlab_ussd

It will take a while depending on your internet connection to create a Laravel project, here is a sample output of my terminal:

Laravel Installation
Laravel Installation

Now that we have installed Laravel in our machine, let’s spin up our development server that comes built-in in Laravel. I am going to cd into the Laravel application folder and run the following command:

php artisan serve

Here is a screenshot of my terminal:

Laravel development server
Laravel development server

From my terminal, I am able to tell the Laravel application is running on When I navigate to my browser I get the following:

Laravel default landing page

Great, now we have a newly created Laravel application.

Africa’s Talking Account

We will be using Africa’s talking USSD gateway, for that we will need an account with Africa’s Talking. To create an account/login follow this link, to follow along on this tutorial series, ensure you have an account with Africa’s Talking.

Africa's Talking Landing Page
Africa’s Talking Landing Page

Goal Achieved in this lesson

In this lesson, we have achieved the following:

  • We have learned the importance of USSD in a business setup.
  • We have learned what we are going to build in this tutorial series.
  • We have learned how to create a Laravel project.
  • We have learned that we will need Africa’s Talking account

With that, we conclude this lesson, in lesson 2 we are going to start to build our USSD menu from the ground up.

Facebook Comments

Close Menu