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:
This will bring up a window with some links and information. Click on the Launch tool button to get started:
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:
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:
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:
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:
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:
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:
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.
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:
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.
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:
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!
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:
Here’s an example where the return request wasn’t properly recognized:
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:
When the updates are complete, you’ll see this:
If you test again, the system will now recognize requests for switching as returns:
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.