Developers

Build a chatbot in ten minutes with Watson

Share this post:

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.

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

Then select the plan you wish to use, and click Create. For this example, the Lite plan will provide everything you need.

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 nine 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 Create New 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 Create and you will see two existing nodes, Welcome and Anything else. Welcome allows your bot to start the conversation right away. Anything else captures any input your user says that may not match any of your existing intents. Create a new node by clicking Add node. Type “#greetings” into the Enter a condition field, and “Nice to meet you. What can I do?” into the Enter a response field. You can name your node as well to help keep track of your nodes. Let’s name this one “Greeting response.”

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. The nodes have three dots on the right that gives you options to add additional nodes, a child node or new nodes above or below. These represent two different ways to expand on the conversation. Clicking the Add node below (or above) will create a parallel track of conversation, clicking the Add child node will create a dependent track of conversation.

Start by adding a node below 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 I added a child node to 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 add a child node to 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 Jump to…, and then clicked on the @returnItems:parrot condition and selected “If bot recognizes (condition)”. Because it is at the top, it will be evaluated first, followed by the other two conditions in order. If the @returnItems:parrot is recognized, then the appropriate response will be given. For more about the Jump to… functionality, please check out the documentation.

After the #return node, create one more parallel track (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:

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.

 


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


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


    Lisa Kay Davis

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


Neeraja Ganesan

Good tutorial Zach!


Neeraja Ganesan

The tutorial is on point!


    Lisa Kay Davis

    Thanks so much. Please share!


Rajesh

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


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


    Lisa Kay Davis

    Updated! Thanks, Tak.


Paul Zikopoulos

Well done!


Phil

Hi,

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


    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!


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


    Lisa Kay Davis

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


Elio Botogoske

Nice Tutorial. Thanks a lot Zack.

Comments are closed.

More Developers Stories
December 12, 2017

3 types of business chatbots you can build

No matter what type of bot you decide to build, it is important to give your bot some life and personality, make it useful, and make sure it’s easy to use. Our blog highlights the top three chatbots you can build for your business.

Continue reading

December 4, 2017

Freedom and flexibility with Speech-to-Text

When it comes to speech-to-text solutions, an out-of-the-box service isn't enough. IBM Watson's Speech-to-Text service helps provide the tooling and functionality to train Watson to learn your business.

Continue reading

December 1, 2017

The future of AI Revenue: Top 10 use cases for AI in the next decade

6 AI segments will account for a significant change in revenue for AI enterprise software. These functional areas are applicable to many use cases, industries, and generate benefits for both businesses and individuals. Here are the top ten use cases which will reap financial rewards for AI technology product and service companies, and a broad spectrum of benefits for everyone else.

Continue reading