Codementor Events

How I Developed a USSD Skeleton App in Laravel

Published Oct 06, 2017
How I Developed a USSD Skeleton App in Laravel

Hello all!

In my programming experience, I was once tasked with a job to develop a USSD application for a client who had a fintech start up and wanted his clients to be able to apply for microloans via feature phones, so he needed a USSD application developed.

He had an open source platform known as Mifos, which would be used for loan management. I was quite interested in getting the job, because it would be my first time developing a USSD application.

I had to learn a lot to deliver the right product for my client.

Luckily for me, we have a third party company that provides an API for USSD development (Africasistalking).

I used their USSD API and decided to develop the product using Laravel and MySQL. This was very successful and the client was quite happy with my work.

I have to admit that the logic on the USSD was quite tough on me, but luckily, I managed to complete it.

Afte this whole struggle, I decided to share an open source project on USSD that could help other developers get started easily developing a USSD application.

I put the whole source code on GitHub. I am always ready to assist in this kind of development. Hope this gets to help more developers.

Discover and read more posts from samuel nyaga
get started
post comments2Replies
Parables Boltnoel
3 years ago

@SHEI TIJANI MUTARU

Follow these steps:

  1. Create a new Laravel application

  2. Install the laravel/ussd package https://sparors.github.io/ussd-docs/

  3. Create a simple state by following the docs on laravel/ussd just make sure to start your first state with CON and your last state starts with END

  4. Create a controller by running php artisan make:controller -i UssdController

5.Create a post route preferable in your routes/api.php file and pass in your controller Route::post('/ussd', UssdController::class);

  1. Format your response from the machine in your controller to like below
   $ussd = Ussd::machine()
            ->setFromRequest([
                'phone_number' => 'phoneNumber',
                'input' => 'text',
                'network' => 'networkCode',
                'session_id' => 'sessionId'
            ])
            ->setInitialState(Welcome::class)
            ->setResponse(function (string $message, string $action) {
                return $message;
            });
        return $ussd->run();
  1. deploy your laravel app and create your channel on https://account.africastalking.com/apps/sandbox/ussd/channel/create

Use the hosted-app-remote-url/api/ussd route as your callback route

  1. Test and enjoy… Share the word… AfricaIsTalking indeed
SHEI TIJANI MUTARU
3 years ago

My greetings brother, I am working on a similar application can you help. Thank you