Build an IVR with Jovo, Watson Assistant and Twilio Autopilot — Part 1 of 2

Son Le Thanh (Son)
Leo & Rome
Published in
9 min readJun 14, 2020

With the popularity of chatbot in the past few years, more and more businesses have been deploying chatbots to serve customers. However, telephone is still the ubiquitous interface. The consumer behaviour is still looking up for a phone number listed on the businss’s website and dial to make inquiries.

‌In this tutorial, I will show you how to build a simple customer service voice bot surfaced via phone number to answer common inquiries related to your business.

I will split this tutorial into 2 parts. In part 1, I will build a voice bot on top of Twilio Autopilot and Jovo framework without using Watson Assistant.

In part 2, we will extend the bot by moving the conversation logic into Watson Assistant.

‌This is the overall architecture of the final solution.

These are the components that we need for this tutorial.

‌A virtual phone number for your customers to dial. You can buy a phone number via Twilio.

Twilio Autopilot — a Naturual Language Understanding (NLU) platform to build conversations. This product acts as the layer to convert consumer’s speech into text and convert response in text from the conversation layer into speech to reply back to consumer.

Jovo Framework — open source framework for developers to build cross-platform voice applications. This component acts as the orchestration layer to connect the Twilio Autopilot and Watson Assistant components together.

Watson Assistant — a cloud-based natural language understanding platform from IBM that allows you build and deploy enterprise-grade converstional chat and voice bots.

Let’s get started with Jovo Framework

Head over to Jovo.tech website and click on Get Started under menu on the top For Developers

Over here, you will find all the steps to get started witht this frame work. Firstly, you need to install Jovo CLI by running this command

$ npm install -g jovo-cli

After you have installed Jovo CLI, you need to create a project from the terminal console interface. Give your project a name for examle demo-ivr-tutorial

jovo new demo-ivr-tutorial

Jovo CLI will create a new project based on the helloword template

Open the project using your favorite IDE and let’s take a look at the folder structure

Run and Test the Code

Within the project’s directory, execute this command

jovo run

Jovo will create a localhost server and expose a webhook URL running on Jovo cloud environment. You will need to copy this webhook URL and paste into Twilio Autopilot editor in later steps.

For now, you can enter . to open Jovo Debugger in your browser. You can also copy and paste the link into your browser to open it.

You can play around with built-in flow

Your first Jovo app is working fine as of now.

Go back to terminal console window, under the folder of your project, enter this command to install the library for Twilio Autopilot into our project

Include Twilio Autopilot in app.js

Open file app.js in your code editor and include the declaration of Autopilot library at the top. We also need to include a new instance of Autopilot in the app initialization code block.

App logic

This is the default app logic when you create a voice bot with hello world template. When the app is started via LAUNCH() method, the phrase Hello World! What’s your name? will be spoken as the welcome message. If user says something that matched intent name MyNameIsIntent, bot will reply Hey <the name introduced by user>, nice to meet you!

The name introduced by user is defined via value this.$input.name.value inside the line this.tell(‘Hey ‘ + this.$inputs.name.value + ‘, nice to meet you!’);

Intent data model

You can find phrases (aka utterances) defined for each intent inside file /demo-ivr-tutorial/models/en-US.json

Create a bot with Twilio AutoPilot

Head over to Twilio website and login with your account. Select All Products & Services

Click Autopilot

Click Build a bot and Start from scratch buton

Give it a name and click on Create bot button

There are several tasks already created by the default template. This task concept is similar to intent concept in other chatbot platforms such as Watson Assistant.

You might want to click on Train hyperlink of a task for example greeting to view trained examples (aka phrases or utterances)

You can keep adding on new examples to an existing task or create new tasks and give examples into each new task created. Each time you make some changes to a task, you need to click on Build model to get the underlying machinde learning get trained on the changes you have made.

Create new task MyNameIsIntent in Autopilot

As you might notice, Autopilot default tasks do not have anything similar to MyNameIsIntent defined in Jovo. You need to create a new task with the name MyNameIsIntent (case sensitive).

Click on Add a task button

Enter the name MyNameIsIntent and click on Add button

Next, you need to click on Train to give sample phrases. You might want to copy the same phrases under this intent from the /models/en-US.json file in Jovo.

Because we need to get the value of name mentioned by user, we need to put value of name within { and }

A pop-up window is automatically opened and you need to scroll down and select field Twilio.FIRST_NAME

Then click Add field type button

Click Add sample button to add this sample phrase into the list of trained examples for this task

Just giving one sample phrase is not enough, you need to give a few more phrases that a person might say in a conversation when she wants to introduce her name. For example, the next phrase is hi i am {na . As you have deined the value of name in earlier step, when you type the { character and enter na, the value of name automatically appears for you to select.

This is the list of samples that I have created for this task. Remember to click on Build model button to train the underlying machine learning model on these new samples.

Program the handler logic for tasks

Go back to task list and click on the Program link under MyNameIsIntent task

When someone says phrase that matched this intent, our bot will respond “This is your new Task”.

We do not want it answer like that, instead we will let our Jovo app handle the answering. Change the the value of this action like this. You need to copy the value of webhook URL that Jovo has generated for you in the step Run and Test the code at the beginning of this tutorial

Then click Save button to save changes.

Configure how your Autopilot bot triggered

Click on the 3 dot … icon on the left bar to reveal shortcuts to all products and select Studio

Select the plus icon to create a new flow

Give the new flow a name and click on Next

Leave the default flow Start from scratch selected and click on Next

We will configure that whenever there is an incoming call, the call will be handed over to the Autopilot bot that we have built in earlier step.

Under the Widget Library navigation bar on the right, scoll down to the bottom and select Send to Autopilot and drop it underneath existing Trigger card

Connect Trigger card to autopilot_1 card by click the first link and drag it into autopilot_1 card. Once these 2 cards are connected, the link turns into an arrow like below.

Click on autopilot_1 card to select it and on the right bar, select demo-ivr-tutorial bot that you have built under Autopilot step above.

Click Save button then click Publish button at the top

Make an incoming call to the Autopilot bot

Go back to Autopilot screen and select your bot demo-ivr-tutorial. On the left nav bar, click on Simulator

Click on the phone icon to switch to simulating a voice call

Click on the phone icon in the middle to start making a voice call

Twilio will prompt for permission to use microphone, click on Allow button

You will hear a man voice start the conversation by asking you ‘Hello world, what’s your name?’. After that message, you can say phrase like ‘my name is Peter’ assuming that Peter is your name. The bot will respond back ‘Hey Peter, nice to meet you’ and end the call.

Switch back to the window that you opened Jovo Debugger in early step of the tutorial, you could see a record of the last conversation being captured.

Congratulation! You have built the first IVR bot by integrating Twilio Autopilot with Jovo platform.

In part 2 of this tutorial, I will show you how to extend the bot by integrating Watson Assistant into the Jovo app.

--

--

Son Le Thanh (Son)
Leo & Rome

I am a geek, my background was in software development but I enjoyed building community and creating useful content. I am the father of two boys.