You are on page 1of 18

IBM Watson Assistant

IBM Watson
Assistant Lab
Exercise Guide
Overview
The purpose of this lab is to introduce you to the Watson Assistant and to show to you the overall
requesting process to the service and the resulting response.

Tutorial
These instructions are referenced from https://console.bluemix.net/docs/services/conversation/getting-
started.html#gettingstarted, taken 5 May 2018.

Before You Begin

You'll need a service instance to start.


If you created a Watson Assistant service instance, you're all set with these prerequisites. Go to Step 1.
1. Sign up for a free IBM Cloud account or log in.
2. Go to the Watson Assistant page in the IBM Cloud Catalog.
3. fill the Service Name field of the Conversation page and click Create.

Step 1: Open the Tool

After you create a Watson Assistant service instance, you'll land on the Manage page of the service
dashboard.
On the Manage page, click Launch tool.
Step 2: Create a Workspace

Your first step in the Watson Assistant tool is to create a workspace.


A workspace is a container for the artifacts that define the conversation flow.
1. In the Watson Assistant tool, click Skills then Create New.
2. Give your workspace the name La Piccola Pizza and put Watson Assistant Service for La Piccola
Pizza as the description If the dialog you plan to build will use a language other than English, then
choose the appropriate language from the list. Click Create.

3. Youʼll land on the Intents tab of your new workspace.

Step 3: Create Intents

An intent represents the purpose of a user's input. You can think of intents as the actions your users might
want to perform with your application.
We're going to define four intents for a pizza store called La Piccola Pizza:
1. Order pizza
2. Payment
3. Greeting
4. Cancel order
Make sure you're on the Intents tab. (You should already be there, if you just created the workspace.)
1. Click Add intent.
2. Name the intent order, and then click Create intent.
3. Type ‘Can I order pizza?’ into the Add user example field, and then press Enter.

Examples tell the Watson Assistant service what kinds of user input you want to match to the intent. The
more examples you provide, the more accurate the service can be at recognizing user intents.

4. Add three more examples:


 How to order pizza
 I want to order pizza
 I’m hungry
5. Click the Close icon to finish creating #order intent
6. Create another intent called #payment with these examples:
 Can I pay with visa?
 Do you accept cash?
 I want to pay my bill
 How do I pay my bill?
 I want to pay my order
7. Create another intent called #cancel with these examples:
 Can I cancel my order?
 I want to cancel my order
 Let me know how to cancel my order
 Please try to cancel my order
 What should I do to cancel my order?
8. Create another intent called #greeting with these examples:
 Hello
 Hi
9. You've created four intents, #order, #payment, #cancel and #greeting. You also provided example
user input to train Watson to recognize these intents in your users' input.
Step 4: Create Entities

An entity represent 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 Watson Assistant service can choose the specific actions
to take to fulfill an intent.
Intent represents the purpose of a user's input. You can think of intents as the actions your users might
want to perform with your application.
We're going to define six entities for La Piccola Pizza:
1. Contact person
2. Crust type
3. Order type
4. Payment method
5. Pizza type
6. Size

Make sure you're on the Entities tab.


1. Click Add entity.
2. Name the intent contact_person, and then click Create entity.
3. Type ‘email’ into the Entity Value name field, and then click Patterns. Fill
([\w.]*)@([\w].*)\.([\w]*) on the Patterns field
([\w.]*)@([\w].*)\.([\w]*) define the pattern for the value of email that consist of three words
separated by @ and . (dot). Then click Add value.
4. Click the Close icon to finish creating @contact_person entity.
5. Create another entity called @payment_method with these entity value .
6. Type ‘card’ into the Entity Value name field, and then click Synonyms. Add the following as its
synonyms:
 Visa
 Mastercard
 Debit
7. Add another entity with value name called ‘cash’ then put ‘cod’ as the synonym.
8. Create another entity called @crust_type with these value name:
 Black double cheesy
 Black original
 Black sausage
 Black stuffed
 Double cheesy
 Original
 Sausage
 Stuffed
9. Create another entity called @order_type with these value name:
 Delivery
 Takeaway; synonym: take away
10. Create another entity called @pizza_type with these value name:
 Black pepper beef
 Cheeseburger
 Hawaiian chicken
 Meat lovers
 Super supreme beef
 Tuna melt
11. Create another entity called @size with these value name:
 Personal; synonym: small
 Large
 Regular
Now you’ve created your own entities. We will also use the System Entities provided by Watson.

1. Click System Entities


2. Turn on the following System entities
 @sys-currency
 @sys-date
 @sys-location
 @sys-number
 @sys-person
 @sys-time
Step 5: Create Dialog

A dialog defines the flow of your conversation in the form of a logic tree. Each node of the tree has a
condition that triggers it, based on user input.
We'll create a simple dialog that handles our intents, each with a single node.
1. In the Watson Assistant tool, click the Dialog tab.
2. Click Create. You'll see two nodes:
 Welcome: Contains a greeting that is displayed to your users when they first engage with the
bot.
 Anything else: Contains phrases that are used to reply to users when their input is not
recognized.
3. Click the Welcome node to open it in the edit view. We will use slot to gather information of
user’s name and allow multiple response.
4. Click Customize, click the Slots and Multiple responses toggle to turn it on, then click Apply.
5. Click Add slot and define the following slot to get user’s name and save it as $person

6. We’ll modify the response based on the time.


 Good morning 05:00 AM to 12:00 PM.
 Good afternoon 12:00 PM to 05:00 PM.
 Good evening 5:00 PM to 05:00 AM

Add the response, as follow:

7. Click to close the edit view.


You created a dialog node that is triggered by the welcome condition, which is a special condition that
indicates that the user has started a new conversation. Your node specifies that when a new conversation
starts, the system should respond with the welcome message.
Testing the start node

You can test your dialog at any time to verify the dialog. Let's test it now.

Click the icon to open the "Try it out" panel. You should see your welcome message.

Adding nodes to handle intents

Now let's add nodes to handle our intents between the Welcome node and the Anything else node.
1. Click the More icon ( ) on the Welcome node, and then select Add node below.
2. Name it as Order Pizza then type #order in the If bot recognizes field. We’ll need to collect
seven data for ordering pizza:
 Pizza type
 Size
 Crust type
 Quantity
 Order Type
 Location; optional, if the order is for delivery
 Email
3. Open Order Pizza node, then choose Customize. Click the Slots and Multiple responses toggle to
turn it on, then click Apply.
4. Click Add slot and define the following slots to get the data
Check for Save it as If not present, ask
@pizza_type $pizza_type We have Cheeseburger, Black Pepper Beef, Hawaiian
Chicken, Meat Lovers, and Tuna Melt. Which one do you
prefer?
@size $size What size do you prefer? There are personal, regular and
large size.
@crust_type $crust_type Would you like to have Black Double Cheesy, Black
Original, Black Sausage, Double Cheesy, Original, or
Sausage type of crust?
@sys-number $quantity How many pizzas do you want to order?
@order_type $order_type Would you like to take away or delivery?
@sys-location $location Please input your address
@contact_person $email Please input your valid email address

5. @sys-location is only required for delivery service. Click setting icon on slot @sys-location

6. Click the More icon ( ) then choose Enable Condition. Then fill out the form as follow then save
it. It’ll set the slot location as required if user choose to order for delivery.

We’ve finished setting the slots for required data. We’ll create the conditional response once
we’ve collected all required data.
7. Click Add response then fill with the following data
If bot recognizes Respond with
$order_type == "delivery" || Great! I'll make an order for you. $quantity $size $pizzaType pizza with
$order_type == "Delivery" $crustType on behalf of $person. It will be delivered in 30minutes.
$order_type == "takeaway" Great! I'll make an order for you. $quantity $size $pizzaType pizza with
|| $order_type == "take $crustType on behalf of $person. It will be ready at
away" || $order_type == <?now().plusMinutes(15)?>
"Take away" || $order_type
== "Take Away"

We’ve finished with node Order Pizza. You can try the result
8. Let’s create another node, called Pay Order then type #payment in the Enter a condition
9. Turn on the multiple response, then add three responds.
 If user define payment by cash
 If user define payment by card
 If user does not define the payment method

If bot recognizes Respond with


@payment_method:cash Please provide the exact amount of cash.
@payment_method:card Alright, we will bring the EDC machine
We accept payment by credit card and Cash. Would you consider pay
with cash or credit card?
10. Create jump to function to continue the response from order to payment.
Open Order Pizza node, choose Jump to.. option.

Now you will be able to choose destination node, select Pay Order node then choose Respond.

Our Order Pizza node will look like this


And the dialog will look like this

11. Create new node called Cancel then type #cancel as the condition. For this node, we will
implement simple text response. Therefore, just put Okay. I will cancel your order. as the
response.

That's it. You created a simple conversation with four intents and a dialog to recognize them.
END OF TUTORIAL
NOTES
NOTES
© Copyright IBM Corporation 2014.

The information contained in these materials is provided for


informational purposes only, and is provided AS IS without warranty
of any kind, express or implied. IBM shall not be responsible for any
damages arising out of the use of, or otherwise related to, these
materials. Nothing contained in these materials is intended to, nor
shall have the effect of, creating any warranties or representations
from IBM or its suppliers or licensors, or altering the terms and
conditions of the applicable license agreement governing the use of
IBM software. References in these materials to IBM products,
programs, or services do not imply that they will be available in all
countries in which IBM operates. This information is based on
current IBM product plans and strategy, which are subject to change
by IBM without notice. Product release dates and/or capabilities
referenced in these materials may change at any time at IBM’s sole
discretion based on market opportunities or other factors, and are not
intended to be a commitment to future product or feature availability
in any way.

IBM, the IBM logo and ibm.com are trademarks of International


Business Machines Corp., registered in many jurisdictions
worldwide. Other product and service names might be trademarks of
IBM or other companies. A current list of IBM trademarks is
available on the Web at “Copyright and trademark information” at
www.ibm.com/legal/copytrade.shtml.

You might also like