Bluemix

How to get started building Chatbots using Watson and Bluemix

Share this post:

Over the last two months I have been running a series of Chatbot webinars showcasing how you can get started building your own chatbot from scratch using IBM’s cloud platform and Watson services.

I wanted to write this blog for people who missed those sessions to provide guidance on how you can get started TODAY.  At the end I will provide an number of links to get you started as well as a webinar recording.  This is a simple guide to help you get started, see the links for more in depth instructions.  Note: The webinar recording shows a demo of the below.

1.1 Bluemix
First and foremost, you will need a Bluemix Account (sign up here). Bluemix is IBM’s cloud platform and allows you to host your applications as well as make use of over 150 micro services as well as infrastructure offerings.

Once you have an account you will be able to access the services you require to get started building your chatbots. The main service you will need is ‘Watson Conversation’, which is the core service that allows you to build your chatbot solution.

You will need to create a service instance of conversation – simply click on the service in the ‘Catalogue’. You will then need to name your service instance and decide its location (I don’t change credentials). You will also need to pick your plan (LITE & Standard are available by default). Once you are done click create, and you will now be taken to your dashboard where your instance will be available. Click on the service and then Launch when given the option.

1.2 Watson Conversation Service – Workspace
You will now need to create a new Workspace, a workspace is where you create and train the chatbot. Usually you will start with 1 workspace per chatbot, but there are scenarios where you would want multiple workspaces per chatbot. For example, you could have a chatbot operating in multiple languages, then you would want a workspace for each language. You could also have a larger chatbot covering a number of knowledge areas; in this instance you could put our Watson Natural Language Classifier in front and then have multiple workspaces that specialise in different knowledge areas.

For now, click create new Workspace, and give it a name and description. Please note, the languages on the dropdown menu are the currently supported languages the Chatbot understands, and operates in.

1.3 Watson Conversation Service – Intents
The three key elements of a chatbot are intents, entities and dialogue – these are used to train what it understands and how it responds. In order to explain this, we will assume that we are making a chatbot for an online electronic store that sells various electronic goods.

First, we will start with intents; an intent the aim of the user’s input/question.  Example; #Tell me about your @travel offers.  In that example, the bold is the intent, the italic is the entity. Thus, the intent is Tell me about (i.e. you want information about something specific.  The specific part is the entity).

What you need to do is to anticipate what a user’s input and intents will be.

Let’s make some intents now.

First off we start with #Greeting – Most users will input some form of greeting when interacting with a chatbot, therefore it is important to be able to respond to this. You need to provide a minimum of 5 values, value being an example of the intent Greeting.

#Greeting
Value: Hello
Value: Hi
Value: Hey
Value: Howdy
Value: Good Morning

Let’s create some more intents:

#Whatdoyoudo
Value: What do you sell
Value: What can I buy
Value: What do you have
Value: What can I get here
Value: What are your offerings

This intent is to understand what your company and also chatbot is capable of providing.

#tellmeabout
Value: Tell me about
Value: What are the options
Value: I want to know
Value: I need info about
Value: I need to know about

This intent is to understand more about something specific (i.e. an entity).

#Thankyou
Value: Thanks
Value: Cheers
Value Thank you
Value: Grand
Value: Appreciate it

Many users will input some form of thanks. It is recommended that you create intents to recognise this so your chatbot can response.

1.4 Watson Conversation Service – Entities
An entity is a portion of the user’s input that you can use to provide a different response to a particular intent, or – as I like to call it – the WHAT. If we take the example I used before: #Tell me about your @travel offers.  The bold is the intent, the italic is the entity, i.e. the “What”.

Before we create an entity let’s look at ‘Use System Entities’. These are Pre-Built entities by IBM that you can use if you wish. I recommend you do as it saves you having to create them yourself.  Pre-built entities like time, date and numbers are the ones I often use.

Let’s create an entity. First you need to give it a name, I call this the group name. For this example we will call it @Products. Now you need to enter values and synonyms. The values are the specific items within the group, i.e. in this case a phone. The synonym is the different ways a user might input the value.

@Products
Value:
Phone.  Synonyms: iphone, Mobile, telephone, cell,
Value: Computer. Synonyms: PC, Mac, Desktop, Laptop
Value: Tablet.  Synonyms: iPad, Nexus
Value: Stereo.  Synonyms: HiFi
Value: TV.  Synonyms: Television

As you can see I have 5 product lines (values) within the group (@products) and I have included different ways people might input those values.

Now let’s go and put it all together

1.5 Watson Conversation Service – Dialogue
A dialog uses intents, entities, and context from your application to define a response to each user’s input. Creating a dialog defines how your bot will respond to what your users are saying.

Click ‘create’ – you will see two boxes appear, these are called ‘nodes’.  A node is a set of conditions and responses.  The first node is Welcome, the second is Anything_else.

Welcome node is a default node and used at the start of a conversation, meaning that it will activate when somebody first logs into the chatbots. The Anything_else node is used when the chatbots doesn’t understand an input. Both use default conditions. Note that Anything_else has multiple responses; you can ‘Set to Random’ to randomize the responses (which I do).

Now let’s create our first node – Note: Your new node will be created under the currently selected node (highlighted blue) so select Welcome node first.

Node: Greeting
Condition (if bot recognizes): #Greeting
Response 1 (enter a response): Hi, how can I help you today?
Response 2: Hello!  How can I be of assistance?
Set to Random

The name of the node is just for you to make it easier to see. The If the Bot Recognizes portion is the ‘condition’ so we input # and you will see all your intents, select greeting.

Now you need to input the response the chatbot will answer with. I put in a few and set to random. The chatbots will now respond to a greeting. Let’s make some more.

Node: What do you do
Condition: #whatdoyoudo
Response: We offer a range of items including phones, computers, tv’s etc.

This node is to answer the #whatdoyoudo intent. For this basic example we are doing, I am hardcoding in the response. If you click on the three dots you will be able to open JSON Editor and use that to connect back to data source or database for other responses, but for this example we will simply write them in.

Node: Tell me about products
Condition #tellmeabout AND @Products
Response: Please check out our online catalogue for more info.

We want this node to respond to a specific question. First, you add the condition #tellmeabout; then you press + to add the AND and then input @. This will bring up all your entities and values. Usually, you would want a response to each entity value (i.e #tellmeabout AND @Products:Phones) and do one for each value to give a specific response. However, for this example we will use the whole product group so select @Products.

Node: Thank you
Condition: #Thankyou
Response: You are very welcome!

This is just a simple response if somebody thanks the bot. So now, let us test.

1.6 Watson Conversation Service – Test
Click on the little dialogue icon in top right – Ask Watson. This will allow you to test how your chatbot performs. Please input the following dialogue

Hello
What can I buy?
I want to know more about your iphones
Thank you!

As you type the input you should see the corresponding dialogue node highlight in blue, and you will see the intent and entity the chatbot is picking up in the chat box. If it does not understand, it will default to the anything else n

And there you have it, a very simple but working chatbot.

Please do not hesitate to contact me with any questions at EVANJONE@ie.ibm.com

Useful links

Cloud Platform Services Advisor

More Bluemix stories

Data Democratization – making data available

One of the trending buzzwords of the last years in my world is “Data Democratization”. Which this year seems to have been complemented by “Data Fabric” and “Data Mesh”. What it is really about the long-standing challenge of making data available. It is another one of these topics that often gets the reaction “How hard […]

Continue reading

How to act in the new regulation of financial sector

Our world is changing. Because of that regulators around the world are taking ambitious steps to improve the sustainability of the financial sector and guide capital towards sustainable economic activity. Especially in EU we are seeing a high level of regulations. These regulatory interventions present complex and sensitive legal challenges for financial sector firms, which […]

Continue reading

Private cloud or public cloud? New server technology offers more choice

In September, we launched the new IBM Power E1080 high-end server, for corporate use based on the  new Power10 architecture, the Power E1080. The server can – among many other things – handle a large number of applications and workloads securely, at scale and with highest availability. Going into the spring of 2022, we will […]

Continue reading