This article is part of the Watson Assistant learning path.
|100||Introduction to Watson Assistant||Article|
|101||Create your first Assistant-powered chatbot||Tutorial|
|200||Assemble a pizza-ordering chatbot dialog||Code pattern|
|201||Create a banking chatbot||Code pattern|
|202||Create a web-based chatbot with voice input and output||Code pattern|
|300||Create a Google Action with Watson Assistant||Code pattern|
|301||Create an Alexa skill with serverless and a conversation||Code pattern|
|400||Create a next-generation call center with Voice Agent||Code pattern|
With IBM Watson Assistant, you can build conversational interfaces into any application, device, or channel. Most virtual assistants try to mimic human interactions, but Watson Assistant is more. Watson Assistant knows when to search for an answer from a knowledge base, when to ask for clarity, and when to direct you to a human. The following video gives a high-level overview of the Watson Assistant service.
This article is the first part of a learning path that helps you gain a better understanding about how Watson Assistant works, and how you can integrate it with other applications to build your own virtual assistant.
Why use Watson Assistant?
Virtual assistants, or chatbots, go far beyond the gimmicky approach that they are often associated with. You can use bots to set appointments, call a car, and so on. It’s not a replacement for search. Amazon Echo and Google Home are excellent examples of virtual assistants. There is no interface, so having a well-structured dialog to talk through is essential.
A couple of instances of where Watson Assistant excels are customer self-service and employee self-service. Watson Assistant:
- Integrates directly with end-channels such as Slack or Facebook Messenger so that you can handle requests wherever it is most convenient for your users
- Knows when to provide a direct answer to a common question or reference more generalized search results for something more complex
- Stores data within user interactions that can be used to guide and personalize the experience over time
- Hands off the issue to a human agent when it’s something the virtual assistant can’t handle
The following figure shows Watson Assistant architecture that’s common for all implementations. In this architecture:
Users interact with the assistant through one or more of these integration points:
A virtual assistant that you publish directly to an existing social media messaging platform, such as Slack or Facebook Messenger.
A custom application that you develop, such as a mobile app or a robot with a voice interface.
The assistant receives user input and routes it to the dialog skill.
The dialog skill interprets the user input further, then directs the flow of the conversation. The dialog gathers any information it needs to respond or perform a transaction on the user’s behalf.
Any questions that cannot be answered by the dialog skill are sent to the search skill, which finds relevant answers by searching the company knowledge bases that you configure for the purpose.
A typical approach used when deploying Watson Assistant
This section covers the terms that you need to know as you follow the learning path to use Watson Assistant in your applications.
|Skills||A container for the artificial intelligence that enables an assistant to help your customers.|
|Assistant||Directs requests down the optimal path for solving a customer problem. Add skills so that your assistant can provide a direct answer to a common question or reference more generalized search results for something more complex.|
|Dialog||Defines what your assistant says in response to customers, based on what it believes the customer wants. The dialog flow is represented graphically in the tool as a tree.|
|Intents||A goal that you anticipate your users will have when they interact with your assistant. For example, you might define an intent that is named
|Entities||A term or object that provides context for an intent. For example, an entity might be a city name that helps your dialog to distinguish which store the user wants to know store hours for.|
|Content Catalog||An easy way to add common intents to your Watson Assistant dialog.|
Handling multiple intents in Watson Assistant
By default, Watson Assistant handles one intent at a time. For example, if you have an intent
#Transactions that handles transaction queries and a user says “I want to check my transactions,” then the assistant jumps to the node that responds to this condition. What about multiple intents in the same query? It gets more complicated when a user asks multiple questions at the same time. For example, if a user says “I want to check my transactions and my current balance,” there are two different intents. One is responsible for transactions, and the other is responsible for checking the balance. You’ll learn how you can tweak the assistant to give it the ability to handle multiple intents, making it smarter.
How intents work
Intents in Watson Assistant are triggered using a confidence score. Whenever a user asks a question, it’s sent to every intent model that you have created, and each intent model returns a confidence score. The assistant satisfies the condition using the intent that has the highest confidence score.
Let’s say you have three intent models:
#Greetings. If a user asks a question regarding their balance, then the highest confidence score is the
#Balance intent, and the assistant triggers the node that uses the
#Balance intent. Using the previous example “I want to check my transactions and my current balance,” the assistant detects the two intents, but it can only trigger one node using the intent that has the highest confidence score. With the concept of a confidence score, it’s possible for the assistant to handle multiple intents at the same time.
Implementing a multiple intent dialog
Using the confidence score, Watson Assitant can detect the intents, and if the user has a query with multiple intents, you can store these intents and then iterate through them. Following are the three main steps.
Define a confidence score threshold value: Define a constant variable to capture the intents.
Capture the intents that have a score above the threshold value. For example, if your constant variable is 0.5, you focus on all captured intents that have a score above 0.5 and store them.
Iterate through the intents: Customize and adjust the dialog to make it loop through the captured intents one by one, and trigger their corresponding node to answer the user’s multiple intent question.
Defining the confidence score threshold value
The confidence score helps you to optimize which intents to focus whenever Watson Assistant detects them. If no intents are detected, the assistant shows “Irrelevant,” which indicates that no intent has a confidence score above 0.2. You need to make sure to put a fair confidence threshold value, not too low and not too high. (If the value is too high, then it’s hard to detect the intents.) A value that ranges between 0.4-0.6 should be enough. As you see in the following image, there is a context variable
confidence threshold in the first node Greetings, and its value is set to 0.4.
Capturing and storing the intents
Capturing the intents means that you want to extract all of the intents from the user’s input that have a confidence score above the defined threshold value. You can create a node that is responsible for extracting and saving the intents by using the
filter function to get these intents with the expression
<? intents.filter('intent', 'intent.confidence >= $confidence_threshold') ?>. The following image shows how the context variable
$intents (where the the detected intents are stored) is checked to see if it is null. If it is, then get and save all of the intents that are above the defined confidence score value in the
$intents variable (the
$intents variable is like an array containing the extracted intents).
Two child nodes to the Extract intents node are creaated. The first one checks whether the list
$intents is empty. Here, you can simply reset
$intents to null. The second node is triggered whenever the list
$intents has intents and makes a jump to the Iterate Intent node, so you can start the iteration.
Iterating through the intents
The extracted intents are stored in the
$intents variable. Now, you must loop through the list that contains the intents so that you can trigger their node correspondingly one by one.
The iteration happens in the Iterate Intents node. In the Iterate Intents node, add a condition that checks whether the intent list is not empty because you’ll return to this node after each iteration. Then, get the first item from the list
$intents using the expression
<? $intents.get(0).intent ?>, and store it in a new context variable so that you can use it later (in the following image, the intent is stored in
After the intent is stored, you must remove this item from the
$intents list, which takes place in the node called Decrement array. Remove the intent from the list using the expression
<? $intents.remove(0) ?>. Removing the intent is necessary so you don’t get stuck in an infinite loop whenever you return to the Iterate Intents node. As you can see in the following image, after you remove the intent from the list you jump to Evaluate Intents, which is just an entry point to the main dialog (where you’ll be using the
$current_intent to trigger its corresponding node). In other words, the Evaluate Intents node does nothing. It’s just a separation between the process of extracting the intents and the main dialog.
If the list is empty, then the assistant jumps to the Out of Intents node (You can add this node at the bottom of your dialog). This node just resets the list
$intent to null.
There is one last step to modify, which is using the
$current_intent to trigger the dialog nodes. Usually in Watson Assistant, if you want to use intents in the nodes you use #INTENT-NAME. However, here we modified the way it works because we are working with a list that contains multiple intents. We extract the first item of the list
$intents and store it in a context variable. In this case, we need to use this context variable, so instead of putting #INTENT-NAME in the node, we put $CONTEXT-VARIABLE, which is
$current_intent. We add
$current_intent on every node that we want to trigger in the dialog.
$current_intent has the value “updateID”, instead of putting
#updateID for the Update ID node, we put
$current_intent=="updateID" so that the node Update ID gets triggered. In addition, every dialog node that we want to trigger must have conditioned responses. In case the list
$intents has more than one intent, we show the response to the user and add a return to the Iterate Intents node to repeat the process, and therefore, trigger the node for the other captured intents. If the list is empty (the intent that we currently have is the last intent in the list), then there is no need to add a jump, so we just show the response.
For example, if a user asks about his ID update and transactions, the assistant first triggers the Update ID node and shows the response, but it won’t stop there. The list has another intent extracted, which is transactions. Therefore, the list
$intents is not empty, so the assistant automatically repeats the process by jumping back to the node where we iterate through the list, and eventually shows the response for the transaction intent.
The modification created here works just like a
while loop. You extract the intents from the user’s query and store them in a context variable, which is a list containing these items. You get the first item from the list, store it in another context variable, and remove it from the list. Then, check which node uses the intent that it has stored in the context variable and trigger it. After it’s done, check if the list still has items. In case it has more items (that is, captured intents), then return to the iterating node, and repeat the process to eventually trigger every node with its corresponding captured intent.
Where is Watson Assistant available?
Watson Assistant is available in both the public and private cloud.
There are several SDKs available that support the various AI services. They are not limited to the following list.
This article is the first part of a learning path that guides you through the deployment of the Watson Assistant service and using included tools for creating intents, entities, and integrations with other applications. To get a high-level look at Watson Assistant including features and pricing, see the Watson Assistant product page. To continue with the learning path, take a look at the next step in the process, Create your first Assistant-powered chatbot.