
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
hubtel-ussd
Advanced tools
Based on Hubtel's USSD API
This package helps you to build maintainable and scalable USSD applications by breaking down your "long switch" statement USSD application into modules
Check out this link to know how you can acquire a USSD code from Hubtel.
Install the package from npm
npm install --save hubtel-ussd
Check the example folder for an example using expressjs
//app.js
const Hubtel = require('hubtel-ussd');
const HubtelUSSD = new Hubtel();
const HubtelRequest = Hubtel.Request;
//route which serves as the endpoint to your ussd application
app.post('/', (req, res) => {
// we use underscorejs to convert the request body to an array and use the spread operator
let request = new HubtelRequest(... _(req.body).toArray());
/**
* Pass the instance of the HubtelRequest (request) as the first parameter to HubtelUSSD.process
* create a folder for our sequences
* and require the seqeunces into an array as the second parameter for HubtelUSSD.process
**/
let ussdResponse = HubtelUSSD.process(request,[
require('./my_sequence_dir/sequence1'),
require('./my_sequence_dir/sequence2'),
require('./my_sequence_dir/sequence3')
]);
res.json(ussdResponse);
});
});
Done :blush:
ResponseTypes is an object with two properties response and release for indicating the type of response in a sequence.
const hubtel = require('hubtel-ussd');
const ResponseTypes =hubtel.ResponseTypes;
ResponseTypes.response // 'Response'
ResponseTypes.release // 'Release'
HubtelUSSD is a class with one method process which takes two parameters a Request (an instance of HubtelUSSDReqeust) and
an array of sequence;
const Hubtel = require('hubtel-ussd');
const HubtelUSSD = new Hubtel();
const HubtelRequest = Hubtel.Request;
let request = new HubtelRequest(/** populate properties **/);
let response = HubtelUSSD.process(request,[/** an array of sequence **/);
//response is an instance of HubtelUSSDResponse
All seqeunces must have a handle method and must return an instance of HubtelUSSDResponse (Response).
The package automagically injects a ussdRequest parameter into the handle method of each sequence. This ussdRequest is an
instace of HubtelUSSDRequest which grants access to all properties and methods in the request.
//sequence1.js
const hubtel = require('hubtel-ussd');
const Response = hubtel.Response;
const ResponseTypes = hubtel.ResponseTypes;
class Sequence1{
/*
* A ussdRequest object which is an instance of HubtelUSSDRequest
* this gives us access to methods such as {mobile,sessionId,serviceCode,type} etc
**/
handle(ussdRequest){
//ussdRequest.mobile --- returns the mobile number of the user performing the request. etc
return new Response('Welcome to Freebie Service.\n1. Free Food\n2. Free Drink\n3. Free Airtime',ResponseTypes.response);
}
}
module.exports = Sequence1;
Visit Hubtel's USSD Api documentation page for the list of methods on the request and response classes
npm test
This project is licensed under the MIT License
FAQs
An unofficial nodejs wrapper for processing hubtel ussd requests
We found that hubtel-ussd demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.