How to build and deploy a Chatbot using IBM Watson Assistant

Cosmin Linca chatbot
September 16, 2020 - 20 min read
drawing

1. Introduction

"A computer would deserve to be called intelligent if it could deceive a human into believing that it was a human" — Alan Turing

You have certainly visited a site at least once and been automatically greeted by a chat or interactive pop-up that asked "How we can help you?" and was smart enough to answer almost any question. This type of interaction defines a chatbot, and is a trendy technology that has managed to change the business perspective and relationship with potential customers that a company has.

Why this method? How complicated is it to create a chatbot?

In the following, we hope to answer these and other questions, because we will present, both technically and practically, what are the steps to create a simple and useful chatbot, using one of the most powerful platforms in the industry, IBM Watson Assistant.

Table of Contents

  1. Introduction
  2. Chatbots
    2.1 What is exactly a chatbot?
    2.2 How to create a chatbot?
  3. IBM Watson Assistant
    3.1 Setup
    3.2 Design a hierarchical flow
    ​ 3.2.1 Intents
    ​ 3.2.2 Entities
    ​ 3.2.3 Dialogs
    3.3.Interact with your chatbot
    ​ 3.3.1 Test
    ​ 3.3.2 Deploy
  4. Conclusion

2. Chatbots

2.1 What is exactly a chatbot?

Let's start by defining what a chatbot is, even if intuition already tells us everything. A chatbot is a program/application/agent that is able to conduct a conversation, through voice or text, in a natural language closely to the entity at the other end, namely human being (although it would be interesting to see a discussion between two chatbots smiley ).

Thus, the main purpose of a chatbot is to represent a bridge between people and the services/interests represented by the entity that created that bot. Among the most important skills wherewith a bot can be designed are:

Therefore, developing a chatbot can increase a company's productivity in a short time, bringing many benefits. Let's not forget, once the bot has been developed, it will be available 24/7 (assuming that the site or service hosting the bot will have no problems).

2.2 How to create a chatbot?

So let's say we want a chatbot. How exactly do we build it? What would be the options? First of all, we have to agree on what kind of chatbot we want to have.

Basically, there are two types of chatbots:

Certainly, the best option would be the second one, because we want a bot as efficient as possible, which manage to replace as well as possible all the processes that a person could do.

Great, so we want a chatbot with artificial intelligence! How we will create it? There are also, two approaches.

The first would be to build it from scratch, through a deep learning model, using an appropriate dataset and appropriate machine learning methods, with a focus on classifying and understanding the text. A Python library known and often used is ChatterBot, representing a good starting point in the development of a bot through a custom implementation. We recommend the following article: How To Create A Chatbot with Python & Deep Learning In Less Than An Hour

It would definitely be a solution! However, the development time and resources used could be quite large, given the outcome of the process. It worth? Definitely it worth. The question is: "Isn't there an easier and faster method?" The answer is "Yes, there is!"

And so, let's talk about the second approach. Using a platform that allows the creation of chatbots with artificial intelligence is a viable solution. These types of platforms are, for the most part, extremely intuitive, and provide interactive tools and components for the user, in order to develop a chatbot. It does not require programming knowledge (except in some cases), but just a lot of imagination! smiley

The best known and used platforms are:

The downside is that developing a chatbot through these platforms is free, but using them in products costs money! Not all platforms are willing to offer the service for free, or if it offers it for free, it offers it with certain limitations.

This limitation was an important criteria in choosing the development platform. After an analysis and attempts to use several platforms, we chose to build our chatbot through IBM's platform, called IBM Watson Assisant.

3. IBM Watson Assitant

Watson Assistant is at the head of the tech industry of conversations through artificial intelligence. Platform is simple and intuitive, with extremely well-created documentation. In terms of costs, it offers a free plan (Lite plan), which allows 10,000 messages per month via chatbot, and the ability to integrate the bot with web services.

For more information we recommend the official documentation: https://www.ibm.com/watson/how-to-build-a-chatbot

3.1 Setup

To access the Watson Assitant platform, but also other services, you need to create an account on IBM Cloud: https://cloud.ibm.com/registration. After you have created your account and logged in, select "Watson" from the side menu, and in the dashboard displayed you will find in the "Getting Started" section, the option "Build a chatbot".

From here you will be directed to the initial configuration page of the chatbot (pricing plan, region, service name).

When you're ready, click "Create" and that's it! The bot is created and ready to be configured as you wish, through the dedicated platform.

3.2 Design a hierarchical flow

The process of learning for chatbot involves the development of several dialogue skills (up to 5 in the Lite version). A dialogue skill consists of Intents, Entities and Dialogs, these 3 components being the basis for learning of virtual assistant, through the IBM Watson Assitant platform.

3.2.1 Intents

An intent is a purpose or intention expressed by the user, such as asking a question - "How do I schedule a call?", or expressing an intention - "I would like to pay the bill".

By recognizing the desire of the user, the virtual assistant can choose the appropriate dialogue flow, and can formulate an appropriate response. Most of the time, the user's intention is cataloged by the bot in several categories, giving a probability to each option.

In the image below you can see several intents defined for the first dialog skill of the bot:

An advantage of using this platform is that it puts available a predefined range of intents, which can be used for free. (check Content Catalog section). Thus, the Bot Control category, and all associated intents, were added and learned by our assistant.

How exactly does an intent look like on the platform? You can see in the image below how an intent was defined for the flow of data responsible for information about AFM (Autonomous Fleet Management).

It is noticed that an Intent consists of name, description and user examples.

3.2.2 Entities

An entity is a class of data/information that is relevant to a user's purpose in expressing intent. By recognizing the entities, the virtual assistant can choose specific actions, in acomplish an intention.

For example, a user may want to know more about CodexWorks ("Tell me more about Codexworks"). At the same time, he may want information about the history of CodexWorks. ("Tell me more about Codexworks's history"). There is a difference between the two answers that must be provided. History is an entity, changing the context of the intention provided. For the user, the history becomes relevant, not the general information about CodexWorks.

In the image below you can see some entities defined within the platform:

3.2.3 Dialogs

A dialog is the component that uses discovered Intents and Entities based on inputs provided by user, in order to find and provide an appropriate response. The dialogs have a linear tree structure. Thus, a branch is created for each intent (or group of intents), together with the associated entities. Each dialog offers the possibility to prepare several answers, being provided only one answer (chosen sequentially, or randomly).

The image below shows a part of the tree structure of the dialogues for our bot, in which a well-established order of them can be observed. On the right you can see how the dialog for the Greetings use case is defined, and the possible answers that the bot can offer, if it recognizes in the user's input a form of greeting.

3.3 Interact with your chatbot

3.3.1 Test

After defining a few dialogues, the bot can already be successfully tested! His training is done in real time, immediately after adding a new element, of any type.

In the upper right corner you can see the Try it button that opens the chat for the bot you created, with which you can interact and see in which category maps the input (question or intention) provided by the user.

3.3.2 Deploy

An extremely valuable advantage of these platforms is that the deployment process is very simple. To create a deployment channel, go to the main panel of the platform and select Integrations. From there you will be able to create a new integration, with whatever service you want. The most common is Web chat.

In the panel that represents the chosen integration you can customize your bot with other services, or style it at the design level. When you are ready, in the Embed section you will find a js code section which is ready to be integrated in your page/site/service, from where it can be used as you wishl.

We integrated the chatbot in the code related to our site, www.codexworks.com, and the corresponding chat icon appeared immediately, the bot being ready to use smiley

4. Conclusion


References