Build a Watson IBM conversational bot in 15 minutes
Watson is a question answering system, also know as QA, developed by IBM (named after its IBM’s first CEO Thomas J. Watson) and capable to answer questions posed in natural language. Watson has a variety of applications and domains such as Healthcare , IoT, Education, Financial Services, Marking and Customer Engagement and recently Weather Forecasting. Having come across chatterbots (or chatbots) in the past and always being interested in the long lasting debate around Artificial Intelligence and Thinking Machines (the Turing Test, John Searle’s Chinese Room and many more), I wanted to try out the IBM Watson Conversational Bot and build a simple bot that can have an application in a customer service type of scenario.
Setting up a Free Account on Bluemix
It is possible to set up a free Bluemix account to experiment with Watson Conversation. Bluemix is the IBM Cloud Platform as a Service and signing up here you can build your bot by picking Conversation from the IBM Bluemix Catalog. The Lite Pricing Plan (Free) will cover all you need to get started with the bot, for example up to 5 workspaces, up to 25 intents and entities (we will clarify later in this entry what they are). It also includes 10.000 API calls per months (POST message method calls only).
After selecting the Lite Pricing Plan, a Conversation instance will be created and you will be presented with some info on Conversation and on the right side of the new window the option to launch the instance (via the “Launch tool” button).
Creating a Workspace
The very first step into this journey is to create a workspace where you project will reside. Each workspace corresponds to one and only one bot. The below screenshot shows a newly created Workspace named “My First Bot project”
An intent is a task/goal that the user wants to perform or achieve and is expressed by a particular user’s input . For example, changing their password, downgrading their price plan or making a complaint. When planning the intents in your bot application, it is important to consider what the customer/user would like to do in a specific scenario and, in turn, what the bot itself will be able to handle.
In our example, we will configure 4 classes of intents. 2 for opening and closing statements (greeting the customer’s adviser and parting at the end of conversation) and 2 that would cover requests on the customer’s account.
This is the overall UI the user will be presented with showing “Intents”, “Entities” and “Dialog”:
Here are (some) intents for the class #greetings:
Here some of those for the class #goodbyes:
Now that we have covered opening and closing statements in a conversation, we can include some intents for the class #account:
Still we need to include some training example for out bot to handle the next step in our conversation/dialog. Here some example under the class #account_changes
There is a last step that in this example will pretty much cover anything else and nothing really specific to what normally a customer would like to ask, but still we need to catch other possible things that can be asked or said. This will be done under the class #anything_else
An entity is a term or an object as part of the customer’s input that is aimed at clarifying the intent behind it. When usually intents are verbs (close, pay, change), entities are nouns (an account, a bill, a plan). Ideally, you should group entities that are likely to trigger a similar response throughout your dialog. For example, @customerDetailsChanges, will include all elements in the customer’s address that might need amending or changing as well various operations on the account such as close, pay, change plan etc under the category @accountMaintenance:
Building and Testing the Dialog Flow
After specifying intents and entities, it is now the time to plan our dialog’s flow. From the Dialog Tab, we are going to set a very basic and initial dialog with the #greetings intent. We create a new node called “Greeting response” and let’s add a new response condition that, if matches the existing intents, it will be prompted to the customer.
On the right side of your workspace there is a speech bubble with three dots. When you click on it, it will open a chat window from where you can test the current built dialog. As you can see from the below screenshot, “Hi” is correctly recognised as part of the class of intents called #greetings and the response “Hi, how can I help?”.
Having started off with #greetings, now we need to build the rest of the dialog. We will need to add 3 additional nodes:
- Account Management.
- Account Change Requests
- Goodbye response
#Account Management’s node targets the intent #account and the entity @accountMaintenance as set earlier in this entry.
Furthermore, we will need to create a node for the specific request the customer would like to enquiry about (e.g. change of address), as follows:
We also need to add another node called “Goodbye response” to wrap up the interaction with the customer:
Now, let’s test the dialog Greeting response -> Customer Details Changes -> Goodbye response, as follows:
Finally, let’s try out the bot that consists of Greeting response -> Account Management -> Goodbye response, as follows:
There are a few directions you can go from here . First of all, the above bot is a very basic one, so you can enrich it by planning some additional potential scenarios and including more potential responses and interactions. You can look at using Jump to actions, add variation to your responses or add response conditions (e.g. using context variables). You can also use the Conversation REST API to modify your dialog programmatically, meaning that you will not need to use the Conversation tool UI. Once you are satisfied with your bot, you can also deploy your application by connecting the workspace to an interface customers will use. For example, you can test your bot on Slack in just a few simple steps. Finally, you can use the Watson SDK to develop your own web application and then your using with your service or integrating with 3rd party services.