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.
For this example, we’re going to keep things simple and define only two intents: one for saying hello, and one for saying goodbye.
Make sure you’re on the Intents tab. (You should already be there, if you just created the workspace.)
Click Create new.
Name the intent hello.
Type hello as a User example and press Enter.
Examples tell the Conversation 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.
Add four more examples and click Done to finish creating the #hello intent:
Create another intent named #goodbye with these five examples:
see you later
Step 4: Build a 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 #hello and #goodbye intents, each with a single node.
Adding a start node
In the Conversation tool, click the Dialog tab.
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.
Click the Welcome node to open it in the edit view.
Replace the default response with the text, Welcome to the Conversation tutorial!.
Shows the Welcome node open in edit view
Adding nodes to handle intentsNow let’s add nodes to handle our intents between the Welcome node and the Anything else node.
Click the More icon More options on the Welcome node, and then select Add node below.
Type #hello in the Enter a condition field of this node. Then select the #hello option.
Add the response, Good day to you.
Click Close to close the edit view.
Click the More icon on this node, and then select Add node below to create a peer node. In the peer node, specify #goodbye as the condition, and OK. See you later! as the response.
Testing intent recognitionYou built a simple dialog to recognize and respond to both hello and goodbye inputs. Let’s see how well it works.
Click the Ask Watson icon to open the “Try it out” pane. There’s that reassuring welcome message.
At the bottom of the pane, type Hello and press Enter. The output indicates that the #hello intent was recognized, and the appropriate response (Good day to you.) appears.
Try the following input:
Watson can recognize your intents even when your input doesn’t exactly match the examples you included. The dialog uses intents to identify the purpose of the user’s input regardless of the precise wording used, and then responds in the way you specify.