Download as pdf or txt
Download as pdf or txt
You are on page 1of 106

Lab –1: Building sample chatbot in Watson Assistant tool

Before you begin


You'll need a service instance to start.
Step -1 : Login to IBM Cloud and go to Catalog
Lab –1: Building chatbot in Watson Assistant tool
Step - 2 : Go to Watson Services and open Watson Assistant(formerly Conversation)
Lab –1: Building chatbot in Watson Assistant tool
Step -3 : Give a service name to your Conversation Service and click on Create
Lab –1: Building chatbot in Watson Assistant tool
Step - 4 : Click on Launch tool to launch the dashboard of IBM
Conversation Service
Lab –1: Building chatbot in Watson Assistant tool
Step - 5 : Click on workspaces to load list of Workspaces
Lab –1: Building chatbot in Watson Assistant tool
Step - 6 : Click on Create to create a new workspace
Lab –1: Building chatbot in Watson Assistant tool
Step -7 : Give a name to your workspace and click on create
Lab –1: Building chatbot in Watson Assistant tool
Youʼll land on the Intents tab of your new workspace.
Step - 8 : Click on Add intent to create a new intent and add user input examples.
Lab –1: Building chatbot in Watson Assistant tool
Step - 9 : Give a name to intent and click on Create intent
Lab –1: Building chatbot in Watson Assistant tool
Step -10 : Add a user example and click on Add example
Lab –1: Building chatbot in Watson Assistant tool

Step -11 : You can add multiple examples to your intent


Lab –1: Building chatbot in Watson Assistant tool
Step -12 : If you are done adding examples click
Lab –1: Building chatbot in Watson Assistant tool
Step -13 : Click on Dialog to create a dialog flow
Lab –1: Building chatbot in Watson Assistant tool

Step -14 : Click on create to create the Dialog flow


Lab –1: Building chatbot in Watson Assistant tool
Welcome and Anything else nodes are the inbuilt nodes which has their own functionality.
Welcome node is executed during the start of the conversation, and Anything Else node is
executed when user question is irrelevant
Lab –1: Building chatbot in Watson Assistant tool
Step -15 : Click on Add node to add a new custom node.
Note: The new node should be added between Welcome and Anything_else node
Lab –1: Building chatbot in Watson Assistant tool

Step -16 : Give a name to the node and Type #Greetings in the condition field of this
node. Then select the #Greetings option
Lab –1: Building chatbot in Watson Assistant tool

Step -17 : Add sample responses and Click to close the edit view.
Lab –1: Building chatbot in Watson Assistant tool

Step – 18 : Test the dialog. Click the icon to open the "Try it out" pane. The
welcome message in the welcome node is displayed.
Lab –1: Building chatbot in Watson Assistant tool

Step -19 : Enter a sample input to test your chatbot


Lab –1: Building chatbot in Watson Assistant tool
Step -20 : Here is the response by the Bot
Lab –1.1: Building a chatbot for a Restaurant

We are done building a basic Chatbot. Now in next lab(Lab 1.1) we will proceed building a
chatbot for a restaurant
Planning your intents and entities
To plan the intents for your application, you need to consider what your customers might want to do, and what you
want your application to be able to handle. Choosing the correct intent for a user's input is the first step in providing a
useful response. The intents you identify for your application will determine the dialog flows you need to create; they
also might determine which back-end systems your application needs to integrate with in order to complete customer
requests (such as customer databases or payment-processing systems).
Gather as many actual customer questions, commands, or other inputs as possible. Using input from real users
gives a better picture of the expected input than having experts create lists of possible utterances. Remember that
customers might phrase the same kind of request in many different ways.

Example
#Enquiry
• What is the price of x item
• Can I get the menu
Lab –1.1: Building a chatbot for a Restaurant
After gathering all possible questions asked by a customer we can proceed building a
chatbot
Step – 1 : Let’s create an intent for Enquiry. So, go to Intents and click on “Add
Intent”.
Lab –1.1: Building a chatbot for a Restaurant
Step – 2 : Give the intent name as Enquiry and click on create intent
Lab –1.1: Building a chatbot for a Restaurant

Step – 3 : Add the different user examples for Enquiry intent


Lab –1.1: Building a chatbot for a Restaurant

Step– 4: After adding various examples click


Lab –1.1: Building a chatbot for a Restaurant
Now let’s add entities (Menu, offers, cost) for Enquiry intent
Step– 5:Click on Entities to create new entities
Lab –1.1: Building a chatbot for a Restaurant
Step– 6 :Click on Add entity
Lab –1.1: Building a chatbot for a Restaurant

Step – 7: Give the name for your entity and click on Create entity
Lab –1.1: Building a chatbot for a Restaurant

Step – 8: Give the value name as offers and click on Add value. Do the same
thing for menu
Lab –1.1: Building a chatbot for a Restaurant

Step – 9 : After adding two values (menu, offers) click


Lab –1.1: Building a chatbot for a Restaurant

Step – 10: Go to dialog


Lab –1.1: Building a chatbot for a Restaurant

Step – 11 : Click on Add node to add condition for Enquiry


Lab –1.1: Building a chatbot for a Restaurant

Step – 12 : Give the name of the node as “Enquiry” and give the condition as
#Enquiry
Lab –1.1: Building a chatbot for a Restaurant

Step – 13 : Click on Customize to give the specific responses


Lab –1.1: Building a chatbot for a Restaurant

Step – 14 :Enable multiple responses and click on Apply


Lab –1.1: Building a chatbot for a Restaurant

Step – 15 :In the internal condition Enter @Enquiry and select the option
Lab –1.1: Building a chatbot for a Restaurant

Step – 16 : Select “:is” from the option’s


Lab –1.1: Building a chatbot for a Restaurant

Step – 17 :Select “offers” from the dropdown. So the first internal condition
executes when the user question is about offers.
Lab –1.1: Building a chatbot for a Restaurant

Step – 18:Give a sample response about offers


Lab –1.1: Building a chatbot for a Restaurant

Step – 19: Click on Add response to add response for “menu” condition
Lab –1.1: Building a chatbot for a Restaurant

Step – 20 : Give the condition for “menu”


Lab –1.1: Building a chatbot for a Restaurant

Step – 21 :Click on to give a image response


Lab –1.1: Building a chatbot for a Restaurant

Step – 22: Select Image from the options


Lab –1.1: Building a chatbot for a Restaurant
Step – 23 :Enter the “Title” as “Menu”, and give a sample Image URL of menu in Image
source. Sample Url: http://pepetonsgrill.com/wp-content/uploads/2018/02/Pepetons-Grill-
Restaurant-Menu-00002.jpg
Lab –1.1: Building a chatbot for a Restaurant

Step – 24 : Click on Save


Lab –1.1: Building a chatbot for a Restaurant

Step – 25 :Click to close the edit window


Lab –1: Building chatbot in Watson Assistant tool

Step -26 : Test the dialog. Click the icon to open the "Try it out" pane.
Lab –1.1: Building a chatbot for a Restaurant

Step – 27: Give the input as “What are the offers available”
Lab –1.1: Building a chatbot for a Restaurant

Step – 28 : Observe the response by the bot


Lab –1.1: Building a chatbot for a Restaurant

Step – 29: Give the input as “Can I get the menu” and observe the output
Lab –1.1: Building a chatbot for a Restaurant

Step – 30 :Now let’s create Intent for ordering. So go to Intents


Lab –1.1: Building a chatbot for a Restaurant
Step – 31 :Now let’s create Intent for ordering. So go to Intents
Lab –1.1: Building a chatbot for a Restaurant
Step – 32 :Give the name of the intent as Order
Lab –1.1: Building a chatbot for a Restaurant
Step – 33 :Add the sample user examples for #Order intent
Lab –1.1: Building a chatbot for a Restaurant
Step – 34 :Click after adding user examples.
Lab –1.1: Building a chatbot for a Restaurant

Step – 35 :Go to Entities to add entities for ordering intent


Lab –1.1: Building a chatbot for a Restaurant
Let’s create entities for items in the restaurant
Step – 36 :Click on Add Entity
Lab –1.1: Building a chatbot for a Restaurant

Step – 37 :Give the name to the entity as “items” and click on Create entity
Lab –1.1: Building a chatbot for a Restaurant

Step – 38 :Give sample food items in the items entity


Lab –1.1: Building a chatbot for a Restaurant

Step – 39 :You can also add synonyms for entities as shown below
Lab –1.1: Building a chatbot for a Restaurant

Step – 40 :After giving the sample food items click


Lab –1.1: Building a chatbot for a Restaurant
To detect the quantity of the order from the user we have System entity “@sys-number” , we
can use this system entity for detecting number’s
Step – 41 : Go to System entities and enable “@sys-number” entity
Lab –1.1: Building a chatbot for a Restaurant

Step – 42 : Go to Dialog
Lab –1.1: Building a chatbot for a Restaurant

Step – 43: Click on Add node


Lab –1.1: Building a chatbot for a Restaurant

Step – 44 : Give the name of the node as “Order” and give the condition as “#Order”
Lab –1.1: Building a chatbot for a Restaurant

Step – 45 :Click on “Customize” to give specific responses


Lab –1.1: Building a chatbot for a Restaurant

Step – 46 :Enable multiple responses and click on Apply


Lab –1.1: Building a chatbot for a Restaurant

Step – 47:Click on to add the internal condition


Lab –1.1: Building a chatbot for a Restaurant
In the internal condition we have to check weather user has mentioned about item name and
it’s quantity
Step – 48 : Enter the first condition as “@items” and click on to add other condition i.e quantity
Lab –1.1: Building a chatbot for a Restaurant
Step – 49 :In the second condition select “@sys-number” i.e for Quantity
Lab –1.1: Building a chatbot for a Restaurant
Step – 50 : Give your confirmation response as shown below (Your order for @items of quantity
@sys-number is ordered successfully) and click on save
Lab –1.1: Building a chatbot for a Restaurant
Step – 51 : Click to close the edit window
Lab –1.1: Building a chatbot for a Restaurant
Step -52 : Test the dialog. Click the icon to open the "Try it out" pane.
Lab –1.1: Building a chatbot for a Restaurant
Step – 53 : Enter your input and observe the response as shown below
Lab –1.1: Building a chatbot for a Restaurant
Sometimes the Customer may forget to give the quantity and the item name so we
have to prompt the user for the required information. So, here slots help to prompt the
user when required information is lacking in the question.
Step – 54 : Open edit window of order node
Lab –1.1: Building a chatbot for a Restaurant
Step – 55 : Click on Customize to enable slots
Lab –1.1: Building a chatbot for a Restaurant
Step – 56 : Enable slots and click on Apply
Lab –1.1: Building a chatbot for a Restaurant
Step – 57 : In slots we will check weather user have mentioned item name or not. So in “Check
for” enter the entity name “@items” as shown below. If it mentioned by user it will be saved in
items
Lab –1.1: Building a chatbot for a Restaurant
Step – 58 :If user didn’t mentioned about item, prompt for the information as shown below
Lab –1.1: Building a chatbot for a Restaurant
Step – 59 : Click on Add Slot and do the same thing for quantity
Lab –1.1: Building a chatbot for a Restaurant
Step – 60 : Click on Add response
Lab –1.1: Building a chatbot for a Restaurant
Step – 61 :Click on to add the internal condition
Lab –1.1: Building a chatbot for a Restaurant
Step – 62 :Choose “@items” entity in condition and click to add other condition
Lab –1.1: Building a chatbot for a Restaurant
Step – 63:Enter the condition as shown below ($number!=“”)
Lab –1.1: Building a chatbot for a Restaurant
Step – 64 :Enter the response as shown below (Your order for @items of quantity $number is
ordered successfully) & click on Save
Lab –1.1: Building a chatbot for a Restaurant
Step – 65 :Enter the response as shown below (Your order for @items of quantity $number is
ordered successfully) & click on Save
Lab –1.1: Building a chatbot for a Restaurant
Step – 66:Again click on Add response and click on to add the other condition
Lab –1.1: Building a chatbot for a Restaurant
Step – 67: In the edit window enter the conditions and response as shown below and click on save
Lab –1.1: Building a chatbot for a Restaurant
Step -68 : Test the dialog. Click the icon to open the "Try it out" pane.
Lab –1.1: Building a chatbot for a Restaurant
Step – 69 : First give the input as ”can you order”, as item name is not mentioned it prompts of
the information
Lab –1.1: Building a chatbot for a Restaurant
Step – 70: Enter the sample item name as shown below and now the bot asks for the quantity as it
is not mentioned
Lab –1.1: Building a chatbot for a Restaurant
Step – 71: Click on Manage Context to check the saved context variable and click to close the
tab
Lab –1.1: Building a chatbot for a Restaurant
Step – 72:Now give the quantity and observe the confirmation response, So the confirmation is
given only after user mentions the item name and quantity
Lab –1.1: Building a chatbot for a Restaurant

Now Let’s explore user defined Context Variables. In start of conversation lets ask for customer name
and save in context variable and once the customer is done with the conversation, let’s delete the
context variable
Step – 73:Open edit window of Welcome Node
Lab –1.1: Building a chatbot for a Restaurant
Step – 74: In the response ask for the Customer name as shown below
Lab –1.1: Building a chatbot for a Restaurant
Step – 75 : Go to Entities, go to System Entities and enable “@sys-person” entity
Lab –1.1: Building a chatbot for a Restaurant
Step – 76 : Go to dialog and click on
Lab –1.1: Building a chatbot for a Restaurant
Step – 77 : Click on add child node to add a child node
Lab –1.1: Building a chatbot for a Restaurant
Step – 78: Give the name of the node as “Customer Name” and give the condition as “@sys-person”
Lab –1.1: Building a chatbot for a Restaurant
Step – 79: Click on and click on Open context editor to save the person name in the context
variable
Lab –1.1: Building a chatbot for a Restaurant
Step – 80 : Give the variable name as “name” and value as “@sys-person” as shown below.
Lab –1.1: Building a chatbot for a Restaurant
Step – 81 : Give the response in the welcome node as shown below
Lab –1.1: Building a chatbot for a Restaurant
Step -82 : Test the dialog. Click the icon to open the "Try it out" pane .
Lab –1.1: Building a chatbot for a Restaurant
Step – 83 :Click on clear, the bot asks for the customer name
Lab –1.1: Building a chatbot for a Restaurant
Step – 84 :Enter your name and observe the output as shown below and open manage context to
see the saved name in context varibles

You might also like