Hey, this is Steve with Dabble Lab and in this tutorial, I'll show you how to quickly create an Autopilot bot using the Twilio CLI and the Dabble Lab Autopilot Plugin for the Twilio CLI.
For starters, Twilio Autopilot is a platform for building ai bots that work with Facebook Messenger, Amazon Alexa, WhatsApp, Google Assistant, SMS messaging, Telephone Systems, and just about any other conversational channel you can think of. Getting started with Autopilot is super easy and with the Twilio CLI, you can jump-start your learning with fully-functional templates to get you going.
That's what we'll cover today and here's what you'll need to get setup.
Prerequisites
To follow along, you'll need a Twilio account, the Twilio CLI, and the Dabble Lab Autopilot plugin for the Twilio CLI.
Getting a Twilio Account
If you don't have a Twilio account you can use my referral link to get one. If you use that link, we'll both get a $10 Twilio credit. That's more than enough for you to complete this tutorial and for me to fund my next tutorial. So, it's a win/win :-)
Installing the Twilio CLI
The Twilio CLI lets you work with Twilio from your command line. To install the Twilio CLI, you'll need a recent version of Node.JS (10.x or later) and NPM (which is installed with node). You can verify that node is installed and get the version number by running the following command.
node --version
If you don't have node installed, or you don't have a current version, visit nodejs.org to download and install the latest version for whatever OS you're using (Mac,Linux,Windows).
With node installed, you can now proceed to install the Twilio CLI. The CLI install process is simple. You can just run the following command in most cases.
npm install -g twilio-cli
If you have any issues with the CLI installation, refer to the install documentation at twilio.com/cli.
Setting up a CLI Profile
After the Twilio CLI is installed you'll need to set up a profile so the CLI can access your Twilio account. To do that, you'll need your Twilio ACCOUNT SID
and AUTH TOKEN
. You can get those from the dashboard page of the Twilio Web Console.
After locating your ACCOUNT SID
and AUTH TOKEN
run the following command from your terminal or command prompt.
twilio login
You'll be asked for your ACCOUNT SID
and AUTH TOKEN
. Copy and paste the values from the web console when prompted. This will set up a default profile for the CLI.
Installing the Autopilot Plugin
After the CLI is setup you'll need to install the Dabble Lab Autopilot Plugin for the Twilio CLI. You can do that by running the following command.
twilio plugins:install @dabblelab/plugin-autopilot
After the plugin installation completes, you can verify the installation by running the following.
twilio autopilot --help
You should see a list of the commands provided by the autopilot plugin.
If you see that, we're ready to start building!
Using Autopilot Project Templates
The Autopilot plugin provides a ton of functionality but in this tutorial, we're just going to focus on creating and publishing a bot from a pre-built template.
The command we'll be using is the twilio autopilot:init
command. When you run that command, you'll be presented with a list of available templates.
For this tutorial, select the Appointment Schedule
template and hit enter.
When the command completes, you'll notice a new local project folder named twilio-appointment-scheduling-bot-template
is created.
That folder contains all of the bot's backend source code and a schema for creating the bot's conversational user interface. So, all you need to do is deploy the template and you'll have a bot that's ready for testing. To deploy the template, move into the project directory (cd twilio-appointment-scheduling-bot-template
) and then run the following command to start the deployment process.
twilio autopilot:deploy
The deployment process might take a minute or two but after it completes, you can run the following command to confirm it's deployed.
twilio autopilot:list
You should see your bot listed in the results.
If you do, you're ready to start testing.
Testing Your Bot with the Autopilot Simulator
After your bot is deployed, you can test it with the Autopilot simulator. You can access the simulator through the Autopilot Web Console.
Exploring what was Deployed
The Autopilot Plugin deployed Twilio Functions using the Twilio Serverless API for the bot's backend along with an Autopilot bot.
You can view everything that was deployed through the Twilio Web Console but any changes should be made locally then deployed again using the CLI.
In fact, changes to the backend (Twilio Functions) code can't be made through the web console at this time.
Making Changes to Your Bot
To make changes to your bot's Twilio Functions, you'll need to modify the code in your local project folder then use the autopilot:deploy
command again to deploy the changes.
All of the source code for the Twilio Functions can be found in the ./function/functions/
folder, inside the project root directory.
Changes to the bot can be made by modifying the bot's schema file which is located at ./model/schema.json
.
The goal of this tutorial was to just provide a quick introduction to using the Twilio CLI and the Dabble Lab Autopilot plugin to create bots from the command line. In future tutorials, I'll dive deeper into the bot code but hopefully, this was helpful.
For 200+ related tutorials on building bots and voice assistants, check out dabblelab.com/tutorials and youtube.com/dabblelab
Thanks for reading (or watching) and keep dabbling!