We will be creating an assistant to take coffee orders.
- Go to this link and create an account: https://console.bluemix.net/registration/
- Or, go to https://console.bluemix.net/ and login if you have an account already and login
- Once logged in, click on
Catalog
in the upper right corner of the screen - Search for
Assistant
- Under the
AI
Category, click onWatson Assistant
- A service name is generated for you, but you can chagne it if you like
- Scroll down and make sure
Lite
Plan is selected for the free plan - Click
Create
- Click on
Launch tool
- Once in the tooling, navigate to the
Skills
tab and clickCreate new
- Name it something like
Coffee-assistant
and select the desired language
- Click
Add intent
- Name the new intent
order-drink
- Add a description of what the intent will do. For this, let's use "User wants to order a drink."
- Hit
Enter
to create the intent - Start adding a few exaxmples of how a user would order a drink (at least 5 examples are recommended). Let's use the following:
- i would like to order a drink please
- I need some caffeine
- order espresso
- a cappuccino would be lovely
- a latte please
- Open the
Try it
panel by clicking the button in the upper right corner. This allows you to test how your assistant will respond - Wait for the assistant to finish training, then type
can I order a coffee
. It should classify the intent as#order-drink
. Even though you didn't train the intent on this exact sentence, Watson can still understand it. - Add a few more intents to make your assistant more robust. Try creating the following intents and adding a few examples to each:
- #see-menu (User wants to see what's on the menu)
- #greetings (User greets the assistant)
- #thanks (User thanks the assistant)
Here are the finished intents:
- Click on the
Entities
tab at the top of the page - Click
Add entity
and add the namedrink
- Turn
Fuzzy Matching
on if you want Watson to understand misspellings - Add a value
coffee
with the synonym ofcafe
. - Click
Add value
to create the first value for this entity type - Add some additional values that you allow your users to order and any synonyms, for example:
- espresso
- cappuccino
- latte
- tea
- Click
show recommendations
to see some common synonyms for these entity values - Exit the page, and click on
System entities
underneath theEntities
tab - Turn on
@sys-number
Here is how your finished entity @drink
should look:
- Click on the
Dialog
tab at the top of the page - Click
Create
- Click on the
Welcome
node if you would like to change the intro message - Click
Add node
in the upper left, and name itGreetings
- Add your
#greetings
intent in the field forIf assistant recognizes
. Use the drop down suggestions for easier navigation - Fill in a response that says something like "Hi! How can I help you today?"
- Create two more nodes for
#thanks
and#see-menu
and add responses - Make sure they are at the
root
level, equal to the other 3 nodes you already have - You can add response variatons so that the assistant will respond differently each time your users reach this node
- You can also add additional response bubbles by click
+Add response type
so that Watson will respond with two messages at the same time. - Note that if desired, you can create clickable buttons/drop down menu using the
Option
response type, you can use theImage
response type to display an image from a URL, and you can ask Watson to pause if you want want a delay before the message shows. - Create another node and name it
Order Drink
- To the right of the name, click on
Customize
- Turn on
Slots
and hitApply
- Add the intent
#order-drink
toIf assistant recognizes:
- Under
Check for
, add the entity@drink
, notice that Watson automatically creates a context variable for you - Under
If not present, ask
add a question like "What would you like to drink?" - Click
Add slot
, and add a condition and prompt for@sys-number
: "How many cups of $drink would you like?" (Note: the syntax$variable
is short hand for accessing Context variables. Context variables allow you to pass information between your application and Watson Assistant, as well as reuse information throughout the conversation.) - Add in the response, "Ok, I have $number $drink coming right up!"
- Try it out! Try asking questions related to the dialog you have just created. Witness the power of slots by giving different amounts of information each time. "I would like a drink", "I want coffee", and "I want two coffees"
Finished dialog tree with Order Drink
open:
- Click the blue arrow in the upper left to navigate back to the
Home
screen - Click the
Assistants
tab in the top left - Click
Create new
to create a new Assistant, give it a name likeCoffee Virtual Assistant
- Add your Coffee Dialog Skill to your Coffee Assistant
- You will see the
Preview Link
is already enabled as an Integration, you can also add Slack or Facebook if you are an admiin of a Slack team (or want to create a free one) or are a Facebook Page Admin (or want to create a free one) - You can test your new assistant at the
Preview Link
and share the link with your friends and coworkers for testing and to gather data.
Any messages received from outside of the Try it
panel will show up in the Improve
tab
- Re-enter your
Coffee assistant
Dialog Skill, and on the left, click the tab on the far left navigation bar in the shape of a graph, just below theBuild
tab that is highlighted - See how many total conversations your assistant has had, as well as some of the top statistics here
- Navigate to the
User conversations
tab to see all the messages the assistant has received lately - Before making any changes, you will want to save the state of your current workspace so that your users do not interact with something that may be in progress or untested
- Navigate back to the
Build
tab on the left had nav bar - Click
Save new version
in the upper right - Give it a
Description
likeFirst release of coffee ordering virtual assistant
- Navigate to the
Version History
tab to see your newly saved version, click the three dots to the right of your new version and chooseAssign to assistant...
to connect this new, static version to your live coffee assistant. Your Development version can remain unlinked - Navigate back to the
Improve
tab,User conversations
page, and new data based on what was input into yourPreview Link
or other integrations - Click the pencil to the right of an input to add new intent data, or the pencil further to the right to add new entities. Adding new data can make Watson more confident in something you already taught, or add new intents and entities all together
- If you added brand new intents or entities, go back to the Dialog tab and create new nodes to give them responses
- Once you've added new data, test it in the
Try it
panel. If everything works as you expect, save a second new version back on theBuild
tab, give it a description likeImproved confidence of first release
and link it to your coffee assistant. If things did not go as expected or you broke something you had built before, you can always go back to yourVersion History
and choose to copy your first version back to your development environment to continue from the original state
Did you finish the above and want to learn more? Try some of the following methods to bolster your Coffee Assistant.
If your user orders a drink and completes the flow, and they try to make another order, the values found from the first flow will still be there so they will not be able to order something else. To fix this, we need to clear the context after a successful order so the values are not stored for the next order.
- Create a node above the Slots node
Order Drink
calledOrder Drink - Clear Context
- Set the condition to
#order-drink
- In the response section, click on the three button menu on the right and click on
Open context editor
- Fill in both of the variables (
drink
andnumber
) and set the values tonull
- Click on the three dot menu on the right side of original Slots node
Order Drink
, and selectMove
. Then, click the new context clearing node and move toAs Child Node
(So, the parent node is the context clearing node, and the slots node is the child) - Go to the section called
And finally
at the bottom of the context clearing node. SelectJump to
and click the slots node, thenIf assistant recognizes condition
- Change the condition of the slots node from
#order-drink
totrue
(Use this condition if you want the node to always fire) - Try it out! Without clearing the try it out panel, order a drink. Once finished, try ordering another drink and it should prompt you for the two needed variables again. Here's what the finished context clearing node will look like:
Sometimes, you will want an intent to be handled no matter where the user is in their flow. Digressions allow you to respond to an intent even if a user is in the middle of a process flow, and then it allows them to return to their prior flow without losing their progress.
- Create a
#help
intent with examples like: "I need help" - Create a node below your
Order Drink
node - Add the condition of
#help
with a response like: "I can help you order a drink from my coffee shop. Just say order drink to get started!" - Go into the
Customize
portion of the node by clicking in the upper right - Click on the
Digressions
tab - Enable
Return after digression
(Digressions should be on by default, this setting allows you to handle the intent and then return back to the flow) - Now to test this out, we need to get in the middle of our order drink flow. But first, since it is a slot, we need to go into the
Digressions
tab in theOrder Drink
slots node - Turn on
Allow digressions away while slot filling
and click the button that only allows nodes with returns enabled. This will help you to control which nodes you want to allow to digress to - Try it out by saying "order drink", then when asked for what kind of drink you want, say "help". You should see a response from your help node with another follow up message for the next slot filling question