DEV Community

Serah Nderi
Serah Nderi

Posted on • Updated on

How to Create a Callback URL using Ngrok

A while back I came across the need to create a callback URL while consuming Africa’s Talking USSD API. This was my first time coming across it and I didn’t know how to go about it.
I thought that I’d need to host the project first so I ignored it for a while.

Until I attended one of their sessions and they mentioned ngrok.

Create an Ngrok Account

You’ll be led to this page after signup or login.

Ngrok Setup

If you’re a windows user, follow the instructions. For macOS users you don’t need to follow the instructions because the download isn't a zip file as per their documentation but a Unix Executable file.

Just download and fire it up.

Fire up Ngrok

After opening the downloaded unix file, open a new window on the terminaL, cd to the directory where you downloaded ngrok and run the following command:

./ngrok http <specify the port you want to use>

I used port 3000 so my command was:

./ngrok http 3000

It opens an ngrok session where you can copy your URL. Below is my expired URL.

Ngrok Callback URL

My call back URL is: https://1f9b-105-163-0-134.eu.ngrok.io

If you’re using Africa’s Talking API, create a channel and update the callback URL, save and start debugging. The details tab will let you know where your code is failing, though their error messages are pretty generic.

Africa's Talking

The disadvantage of using the free version of ngrok is that the URL expires after 2 hours thus you have to keep changing and updating it. Additionally, being on a free version means you have to keep that terminal open, else you lose the connection to ngrok.

This article first appeared on Medium.

Top comments (0)