Implementation

ubf-to-twilio Module

This module implements the UBF SMS API for the Twilio backend. How Twilio features are used to achieve this is explained in this article. It is implemented as an npm package.

Go to the npm package page here.

Schema Validation

This is a self-contained software module, so it must verify its input rigorously. Remember how we said that we defined the Universal Bot Format as a JSON Schema intentionally? That is because we can use that same schema to validate the input to this module and hence guarantee that if anything passes the schema, it must be a valid bot design.

Usage Example

const api = require("ubf-to-twilio")

//Retrieve Twilio Client.
client = await api.tryConnectingToTwilio("TwilioAccountSid","TwilioAuthToken")

//List all Phone Numbers on an Account.
numbers = await api.getSMSAccountPhoneNumbers(client)

//Retrieve all Fully Initialised Bots on an Account.
bots = await api.getDeployedBots(client)

//Get back all Bots that have no linked Twilio Service.
unlinked_bots = await api.getUnlinkedBots(client)

//Upload your Chatbot.
assistant_id = await api.uploadNewBot(client, bot)

//Set the SMS webhook of a specific number.
api.changeBotPhoneNumber(client, assistant_id, "+447123456789")

//Simulate a Conversation with your Chatbot.
simulated_text = await api.simulateBot(client, assistant_id, "Text you want to simulate!")

//Remove your Chatbot.
api.removeBot(client, assistant_id)

Use This In Your Project!

This is a published, documented, and tested npm package!

In fact, since it’s been published, the package has been receiving roughly 200 weekly downloads, or 500 by the time of writing.