1.0.0 • Published 1 year ago
ussd-composer v1.0.0
USSD Composer
A utility for composing and managing USSD flows and menus in Node.js applications.
Installation
npm install ussd-composerUsage
const { USSDComposer } = require('ussd-composer');
const menu = new USSDComposer('Welcome to Our Service')
.addOption('Check Balance', () => 'Your balance is $100')
.addOption('Transfer Money', () => 'Enter amount to transfer');
// In your USSD handler
app.post('/ussd', async (req, res) => {
const { sessionId, serviceCode, phoneNumber, text } = req.body;
const response = await menu.render(text);
res.send(response);
});API
USSDComposer
constructor(title): Create a new USSD composer with the given titleaddOption(text, handler): Add a menu option with text and a handler functionsetTitle(title): Set or update the menu titlerender(input): Render the menu or process a selection based on input
License
MIT
1.0.0
1 year ago