0% found this document useful (0 votes)
148 views

IBM Chatbot Tutorial

Watson Conversation service is used to create a chatbot. The document provides steps to: 1) Register for Bluemix and create an account and organization. 2) Create a Watson Conversation service on Bluemix and build out the service with intents, entities, and dialog. 3) Connect the chatbot to a web front end by using GitHub to fork a repository, linking it to a Bluemix toolchain, and updating the code with Conversation credentials.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
148 views

IBM Chatbot Tutorial

Watson Conversation service is used to create a chatbot. The document provides steps to: 1) Register for Bluemix and create an account and organization. 2) Create a Watson Conversation service on Bluemix and build out the service with intents, entities, and dialog. 3) Connect the chatbot to a web front end by using GitHub to fork a repository, linking it to a Bluemix toolchain, and updating the code with Conversation credentials.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 29

TUTORIAL: ChatBot with Watson Conversation

1) Bluemix Registration:

Go to https://www.blueix.net and click on “Create a free account”

Obs.: If you already have Bluemix registration jump to step 2.

Fill out the form, as the example above, and click on “Create Account”. A e-mail form
confirmation will be send to you, check it out.
Open the e-mail sent, and click on the link to confirm as the below screenshot:

Click on the “Confirm Account”.


Your account has been confirmed succesfuly. Click in the login and insert your credentials. In
case you ae a IBMer, the system will send you to IBM system to login with IBM Credentials.

As soon as you login in the system you have create an organization name, for instance your
name, or the name of company, etc, and click “Create”
The second step before you can start your first application or consume a service on Bluemix
you have create a space, a space is one way to organize yours projects, and configure team
work according to area or environment, such as “Dev”, “Homologation”, “Production”, with
different teams with different roles. For now let’s create a space, for example “Dev”, and
click “Create”.

That’s it! You’re ready to go! Click on “I’m ready” and let’s start our first app.
That’s your first screen, it’s your bluemix dashboard. For now, click on “Catalog”.

2) Create a Watson Conversation service and your bot

Go to Watson group (left side), and click on Conversation.


As most of all service on Bluemix in this screen you have a description about the service,
business model and a link to detailed documentation. Change the last part of the name of
service to “-aboutme”. It’s not necessary, but it will help me us find our service easily.

Here you go!! Now you have a Watson Conversation for you. This is a service panel, where
there is the service credentials and a button to open a tool. So, let’s open our tool and teach
Watson about our bout. Click on “Launch Tool” button.
Now you need to create a workspace, which is like a knowledge domain, or the space for a
specific area which is intend to develop a Bot, for instance “Support area” or “Customer
Attendance Service”, etc. In this case as the proposal is develop a bot to answer about
ourselves. Click on “Create a Workspace. By the way, the service bring a bot exemplo, “Car
Dashboard”.

Name it “About me”, or as you prefer, and choose the language, in this case “English”. Click
on “Create”.
Inside your workspace, you need create yours intents. Intents is identify according to the
intention of the user target, for instance, if we were creating a “disk Pizza”, one intention
could be “Do a order” or “Ask a pizza”, and for a instance we have give at least 5 phrases to
Watson learned the standard, so a intention has a group of possibilities of user interact with
your bot, which will have a response for this group. Let’s click on “Create New”.

In the column “Intent name”, insert “whoami”, the “#” the system include automatically,
again this name is a classification for a group of possibilities that users normally use to
interact when has this intention, ok? As per mentioned previously, include at least 5
possibilities, could be more, but the recommendation is about 10. Include the examples
above, or as you prefer. Have in mind that is not necessary include all variations, as Watson
work with taxonomy and understand the standard. Click on the first line, type the first
example, and type enter to jump the next, do the same until your reach the last one. Then
click “done” button to conclude this intention.

Click on “Create new” to create the next intention as the following:

Don’t forget to click on “Done” when you finished. Go to the next one.

Click on “Create new” and create the next one as the following:
Click “done” when you finished.

Click on “Create new” to create an intention to respond about what you do.
Click on “Done” and let’s go to create the last one to respond about your hobby, so what do
you like to do in your free time.

Click “Done”and let’s go to entities. Click on “Entities” as showed in the screen above.

Now you are going to create entities. An entity represents a class of object or a data type that
is relevant to a user's purpose. By recognizing the entities that are mentioned in the user's
input, the Conversation service can choose the specific actions to take to fulfill an intent.
Click on “Create new” and follow the example below.
In this example you are creating a entity to be specific for responses about what you like to
do in your free time, for instance: “Do you like play soccer? “ on this case you intention and
entities, but in case the user ask: “What do you like to do?”, it’s more generic, so your answer
must be more generic as well. Attention: For this lab keep Fuzzy Matching “off”.
Entity has a name and a group of possibilities, and for each possibility you can add
synonyms, once Watson read the correct word to captured entity.
Type “sport” on field Entity (@ is included automatically by the system), then include in the
list above the values above, as the listed above, and click “Done”.

That is it for entities. Now let’s create our dialog. Click on “Dialog” as showed above.
At this point you are prepared to complete your bot, creating a dialog flow, which will be
based on intentions and entities you created. Click on “Create” and follow the nest steps.

The system generate automatically 2 nodes, “Welcome” that is the first node executed by the
service in the first requisition, such as “Hello, How can I help you?”, and “Anything else”,
which is the last node verified condition, that means no one the flow dialog no one of the
node of this flow has attended the conditions. Let’s include a node to if the intention fo the
user is greetings, in this case you will create a specific response for that.
Tip: Click I the border of a node to have the options to add more nodes in the “+” signal.

Click in the “+” signal below “Welcome” node.


Include in the first field the name for this node (it’s not mandatory). In the field if, where
you can validate a condition based on Intention, or Entity, or context variable, or a
combination of them. In this case type “#”, wait the system shows the list of intentions, so
click on “greetings”, Go to Responses and add the following response.

Click in the “x” signal on upside right to close this node, and click in “+” below of greetings
node.
Name it as Goodbye, and include #goodbye in the condition, so go to the response and
include the response, as the following.

Once again click on “+” above Goodbye node.


Include the node to respond to the #whatdoyoudo intention, as showing above. And create
another one for #whoami as the screenshot below:

Create another node for #hobby intention as the following, but this time keep the response
empty, because you will use another technique to be specific, once you created entities for
this intention.
Click on the signal “+” in the tight side of node “Hobby”.

Name this node as Soccer, and add @sports:Soccer in the codition, and the response, which
is specific for soccer. Feel free to change the response according to you. Now we go include
other node below soccer (click on “+” signal below soccer and so on), to treat other entities
sports as the following:
For Bike:
For Tennis:

For football:
In case the user do not mentioned no one of the entities above, we need to have a generic
response for that, so you have to include a “anything_else” method, as the following:

Ok! You already have all the nodes you need, but you have to inform to Watson to entry in
the entities condition when the #hobby condition ne true. Go back to the #hobby node and
click on icon “Jump to” (third one in the botton of node), as showed below:
The system will show the following information in a green bar, that means it is waiting you
indicate for where it have to jump. Click on “Soccer” node, and the system will show 2
options as the following:

click on “Go to condition” button. The screen will looks like as the following:
That’s it! Now let’s test it and learn more and more. Click on “…” botton in the corner in the
right side above. Talk to it!

Congratulations!! Now we can plug this service in any channel as you want, such as
Facebook messenger, Telegram, slack, etc.

3) Plug your bot to a web page.

3.1 Go to GitHUb page, case you do not have a account create one.
https://www.guthub.com
3.2 Create a app on Bluemix and clone a github source code.

Back to Bluemix catalog and create “Continuous Delivery” service, as the following:

Click on “Continuous Delivery service”and go the next page.

Change the name as showed above and click on “Create” button.


Click on “Start here” over “Start from toolchain template”

Click on “Simple Cloud Foundry toochain” service. Open a new browser tab and open
https://www.github.com, and create an account if you do not have.
Fill out the fields and click on “Sign up for GitHub” and follow the steps to create your
account. As soon as you have created your account go to the URL:
https://www.github.com/sergiogama/chatbot (Consider this one instead of /ibm-dbg-chat)
Click on “Fork” up right in the screen as the following:

Now you have a copy of the web front end for your chatbot, as the following:
Copy URL and Back tp bluemix browser tab.

Change the name of “Touchain Name” and paste the URL copied previously on “Source
repository URL” field, and click on “Create” Button. (Use /chatbot instead of /ibm-dbg-chat)
Click on “Eclipse Orion Web IDE”. Open the folder tree in left side and open bot.js file, as the
following:

Now let’s change the code to insert your Watson Conversation credentials, in lines 26, 27
and 32, in the right side. Back to browser tab of your conversation, and click on menu icon in
up left side, as the following:
Click on “Deploy” option. In the next screen you have the information need as the following:

Copy the credentials and workspace_id and back to DevOps browser tab. Change the code
as the following:
Now, open manifest.yml file in the left side pane, and change the host name as the
following:
Tip: change to your name, but pay attention as this host name will be part of a public
domain. In the example below will be https://ibm-dbg-sergiogama.mybluemix.net

Deploy your chatbot, just click on “Run” icon as showed above. Wait 1 to 3 minutes, until
the bullet comes green again, as the following:
As developer click on the icon as showed above, cross the finger, and…

You might also like