Elarian
A convenient way to interact with the Elarian APIs.
Project Status: Still under ACTIVE DEVELOPMENT, APIs are unstable and may change at any time until release of v1.0.0.
Install
You can install the package from npm by running:
$ npm install elarian
Usage
const { Elarian } = require('elarian');
const elarian = new Elarian({
apiKey: 'YOUR_API_KEY',
orgId: 'YOUR_ORG_ID',
appId: 'YOUR_APP_ID',
});
elarian.on('ussdSession', async (notification, customer, appData, callback) => {
const {
input,
sessionId,
} = notification;
let {
name,
state = 'newbie',
} = appData || {};
const menu = {
text: null,
isTerminal: true,
};
switch (state) {
case 'veteran':
if (name) {
menu.text = `Welcome back ${name}! What is your new name?`;
menu.isTerminal = false;
} else {
name = input.text;
menu.text = `Thank you for trying Elarian, ${name}!`;
menu.isTerminal = true;
await customer.sendMessage(
{ number: 'Elarian', provider: 'telco' },
{ body: { text: `Hey ${name}! Thank you for trying out Elarian` } },
);
}
break;
case 'newbie':
default:
menu.text = 'Hey there, welcome to Elarian! What\'s your name?';
menu.isTerminal = false;
state = 'veteran';
break;
}
callback(menu, { state, name });
});
elarian
.on('connected', () => {
console.log('App is running!')
})
.on('error', (error) => {
console.error(error);
})
.connect();
See example for a full sample app.
Documentation
Take a look at the product documentation. For detailed info on this SDK, see the reference.
Development
Run all tests:
$ npm install
$ npm test
See SDK Spec for reference.
Issues
If you find a bug, please file an issue on our issue tracker on GitHub.
Known Issues
resumable
connection options prevents app from connecting