In this tutorial, we will go over the complete process of setting up a basic bot on Twilio Autopilot using the Jovo Framework. This can then be deployed to various platforms and devices, for example we can create a phone number and deploy the bot as IVR.
- Introduction
- Creating a Jovo Project
- Creating your Twilio Autopilot Bot
- Testing your Twilio Autopilot Bot
- Next Up
Introduction
The Twilio Autopilot platform allows you to build, train, and deploy bots that work across web and mobile chat, SMS, WhatsApp, and your contact center. Its biggest strength is the wide variety of channels it provides for your users to access your bot, especially ones that involve phone numbers (calls & SMS). Besides that, the platform is deeply integrated with the other products of Twilio.
In this tutorial, we will first create an Autopilot bot, modify its language model, and create a Jovo project to handle the requests.
Creating a Jovo Project
New to Jovo? You can also learn more in our Getting Started guide.
Before everything else, create a new Jovo project and install the jovo-platform-twilioautopilot
package as a dependency. Jovo provides a Twilio Autopilot "Hello World" template that can get you started quickly:
If you take a look at the src/app.js
file in your project, you can see that the platform is added as plugin:
That's all you need to do on the Jovo side. Now, it's time to create the bot.
Creating your Twilio Autopilot Bot
First, open up the Twilio Console. On there, open up the list of products and select Autopilot:
Now, select Build from Scratch and give your bot a name:
A basic bot has four tasks (intents). We will add another one called "MyNameIsIntent". After that, it's time to add the utterances for that intent:
Since we want the user to parse their name when they trigger the "MyNameIsIntent", we have to first define the necessary field (slot). Simply name it "name" and set the field type to "Twilio.FIRST_NAME":
After that, we add the utterances in the Samples tab. In each utterance, we mark the field using curly brackets:
Now we have to define how the fulfillment of the task will work. The Autopilot platform allows you to either provide a static JSON as a response for each task or lets you set an endpoint to which the request will be sent to. In our case, it's the latter.
To set the fulfillment of our task, switch over to the program task tab. You can find it right next to the Fields and Samples tabs.
We will use the Jovo Webhook as our endpoint. To get the URL, run the jovo run
command in the root directory of your project and copy it from your terminal:
After that, set the JSON of your Autopilot bot's task to:
Now press the red Save button at the bottom of the page. Last but not least, you have to add the same JSON to the other tasks so these are redirected to your Jovo project's endpoint as well.
After you're done with that, press the Build model button right next to the Save button for all of your changes to take effect.
Testing your Twilio Autopilot Bot
If you haven't done so already, run your Jovo Webhook using the jovo run
command:
After that, open the platform's simulator:
In the simulator, you can test your bot. Currently, only two tasks (intents) are working, namely LAUNCH
and MyNameIsIntent
. The others are not included in your project's handler yet. Here's how a possible interaction will look like:
Next Up
While we got the basic project working, the Twilio Autopilot platform provides a couple of other features, that we should have a quick look at. But, before that, we have to talk about a small issue with the Jovo Framework integration.
Incoming requests from Twilio Autopilot don't specify whether the request is from a new session or an existing one. Parts of the Jovo functionality depend on that information, e.g. the NEW_SESSION intent. To be able to use the functionality without the parameter, you have the option to save the current session's ID in your database. The new entries would have the following scheme:
You can enable it in your project's config.js
file:
Now back to Twilio Autopilot's features. All of the Autopilot specific objects and functions are accessed using the $autopilotBot
object. Some of them are directly integrated into the framework. For example, adding a card to your response:
The others (e.g. collect, redirect, handoff) can be accessed using the setActions()
function. It allows you to define the array of actions that make up the response to the platform's request yourself:
That's all you need to build your Autopilot bot. You can find a more detailed explanation of the integration in our docs.