Posted in: Developers + APIs

Build a chatbot in ten minutes with Watson

We recently released the Watson Conversation service to make the difficult task of automatically understanding and responding to customers as simple as possible. The service provides a nifty GUI for training and configuring intents and dialog flow. As part of the launch, we’ve created some handy getting started resources, including a video, a demo, and a basic tutorial.

Being the type who likes things very simple, I felt it would be good to have an incredibly basic tutorial. What I am going to share with you is a super simple chat bot designed for customer service. When I say super simple, I mean exactly that—it doesn’t do much, but it provides an opportunity to learn the core functionality of the Conversation service with a few best practices thrown in.

Getting started on Bluemix

To get started with Conversation, you’ll need a Bluemix account. If you don’t have one already, you can sign up here (and get a free 30-day trial!). Once you have signed in, navigate to the catalog, scroll down to the Watson services, and select the Conversation tile. For this example, the Free plan will provide everything you need.

After you create an instance of the service, select it from the services section of your dashboard:

zach1

This will bring up a window with some links and information. Click on the Launch tool button to get started:

zach2

At this point it’s time to create a workspace. One workspace corresponds to one bot—it contains all the configuration information that gives your bot its unique personality. In this step you can give it a name, write a description, and choose from one of five languages currently supported:

zach3

Configuring intents

The first thing you’ll see when you open your new workspace is the intents tab. Intents are things that the chat users are looking to do: change passwords, get status updates, make complaints, etc. What’s really neat about managing intents is that you are actually training the system to understand what is needed without depending on the exact words. You give multiple training examples that correspond to specific actions or requests.

Creating new intents is easy. First, click on the Add intents button. Pick a simple name for the intent (we’ll use this later). All you have to do to finish is add examples of user requests that fit the category.

For this bot, start with the basics: hello and goodbye. You’re going to train some intents to recognize opening and closing statements in a conversation. Here’s what I trained on for #greetings:

And here is what I used for #goodbyes:

zach5

Once you have those pieces, start training for more specific requests. As this is a customer service bot, you can expect some form of customer complaint. Train for that with the intent #complaint:

zach6

This covers the generic requests for help. But you’ll need something to handle the next step—the specific task that the user is requesting help for. You’re only going to include one example in this bot (remember, it’s super simple). Here are the training examples for #return:

zach7

Almost finished with this step! The final piece is training an intent to catch everything else that someone might say. These examples should be varied both in length and content. Here is my #anything_else intent:

zach8

Preparing entities

Once you’ve finished training your intents, move to the Entities tab. Entities are the specific pieces of information we want to extract from the user response. You’ll want to group entities that might trigger a similar response in your dialog. In this customer service example, we want to put together a list of potential items that the customer may wish to return. Here are my @returnItems:

returnitems

Dialog flow

When your intents and entities are specified, you can move on to constructing the dialog flow. This is the most complicated piece of your bot, because conversations can go anywhere! You want to focus on providing answers for the tasks you can help with, and providing feedback when the conversation gets out of scope. The super simple customer service chat bot will be able to respond to greetings and goodbyes, as well as give direction when a customer has a complaint, including specific feedback when the customer is looking to return an item.

Once you are in the Dialog tab, click Start and you will see the first node. Type “#greetings” into the Enter a condition field, and “Hello!” into the Watson says field.

zach10

This bot is set up to respond only after the user has said something to kick it off. If you would prefer to have it initiate the conversation, you could replace the “#greetings” with “conversation_start”.

At this point, you can begin to test your bot. In the upper right corner of your workspace, there is a speech bubble with three dots. When you click on this, a chat window slides in from the right. This is a test interface for your currently constructed dialog. You can test the classification ability of your intents by trying out some greetings that weren’t included in your training examples:

zach11

You can see that this test tool not only gives the response you set in the dialog node earlier, it also let’s you see which intent best matches the input text. This is very useful for debugging!

Now it’s time to build the rest of your dialog. Your initial node has two plus signs, one to the right and one at the bottom. These represent two different ways to expand on the conversation. Clicking the plus sign at the bottom will create a parallel track of conversation, clicking the one on the right will create a dependent track of conversation.

Start by clicking the plus sign on the bottom of the #greetings node. In your new node, put “#complaint” in the condition field, and “Sorry to hear that, what can I help you with?” in the response.

zach12

Next you’ll want to create a node for the specific complaint of wanting to return something. When I did this initially, I clicked the plus sign on the right side of the #complaint node, assuming the specific request to return something would happen after making a basic complaint statement. In my testing, I realized that it is likely a user would request to return something without ever making a generic complaint statement. A return request shouldn’t be dependent on a complaint statement, so I revised the dialog to make returns a parallel track:

zach13

There’s a lot going on here, so I’ll explain one node at a time. The first node (#return) does not have a response. This is because you want the response to be specific to the item being returned. Unlike the situation mentioned previously, this time you do have a true dependency and should use the plus sign on the right side of the #return node. I created the @returnItems:parrot node to handle the situation where the user is requesting to return a parrot, the @returnItems:(video cassette) node to handle the user returning a movie, and the true node to handle all other returns.

If I had only done this, the conversation would stop once the #return condition was satisfied. To keep it going to the next level, I clicked on the three dots at the top right corner of the #return node, selected Continue from…, and then clicked on the @returnItems:parrot condition. Because it is at the top, it will be evaluated first, followed by the other two conditions in order. For more about the Continue from… functionality, please check out the documentation.

After the #return node, create two more parallel tracks (at the first level) for #goodbyes and #anything_else. This will cover all the use cases your bot can handle!

zach13

Testing and revising

When you’ve finished configuring your bot, you’ll want to test to make sure it does the job it’s supposed to. Using the testing tool discussed earlier, act as if you are a user who needs support help. Make sure you try out some statements that aren’t exactly the same as your training data. Here’s an example of a conversation that went as expected:

zach15

Here’s an example where the return request wasn’t properly recognized:

zach16

To improve your bot, add this statement to the list of examples in the #return intent. As soon as you make this change, you’ll see this banner in your test tool to let you know the system is updating:

zach17

When the updates are complete, you’ll see this:

zach18

If you test again, the system will now recognize requests for switching as returns:

zach19

Next steps

You now have a trained chat bot. The next step is to imbed this into an application and connect with other services. To do this, you’ll want to use the Conversation API. I won’t go into all the details here, but we’ve got some great sample applications and documentation to help you get started. If you run into any troubles, make sure you connect with us on our support forums or Slack.

 

Start building your bot

Sign up for a free 30-day trial of Watson Conversation on Bluemix.

Previous Post

Next Post

Add Comment
18 Comments

Leave a Reply

Your email address will not be published.Required fields are marked *


Igor Ramos

Nice tutorial, Zach! Any chance you and post the JSON for it. I want to import it into my Watson Conversation workspace. Thanks

Reply

Swarnalata Patel

Thanks a lot Zach. Excellent tutorial. I built my first chat bot. The chat bot is about Cognitive Legal Advisor. I will work on improving it and also embedding it to an application. Thanks.
The link of my chat bot is: https://www.ibmwatsonconversation.com/us-south/8d5bb005-b14f-4674-800e-75b4519613f0/workspaces/7c83abe8-b97d-42a8-92d4-f32f01e6976c/intents

Reply

    Lisa Kay Davis

    Great work! Thanks for sharing. Keep us posted on the results.

    Reply

Neeraja Ganesan

Good tutorial Zach!

Reply

Neeraja Ganesan

The tutorial is on point!

Reply

    Lisa Kay Davis

    Thanks so much. Please share!

    Reply

Rajesh

Nice tutorial.. I have trained my bot through conversation api. Please share the steps to run…

Reply

Tak y. Kim

Thanks for good tutorial, Zach.
And I guess there is a missing screenshot for @returnItems in this post. (Please check the following images after “Here are my @returnItems” sentence.)

Tak

Reply

    Lisa Kay Davis

    Updated! Thanks, Tak.

    Reply

Paul Zikopoulos

Well done!

Reply

Phil

Hi,

How do I provide url of my website in conversation so that user can click to open the website

Reply

    Lisa Kay Davis

    Hi Phil. Thanks for stopping by. URL handling depends on the UI that is being used with conversation. The sample applications we have for conversation will convert HTML to clickable link. Hope that helps!

    Reply

Simon Pumphrey

The sign-up page (https://console.ng.bluemix.net/registration/) appears to be broken – it won’t let me input into the fields to create a new account

Reply

    Lisa Kay Davis

    Hi Simon- Sorry to hear that. The link is active. Can you try another browser?

    Reply

Elio Botogoske

Nice Tutorial. Thanks a lot Zack.

Reply

Shamane

How to publish this as an API ? Is there any documentation

Reply