Discussing more advanced techniques about Dialog
Welcome to the Fifth lesson on how to Build Chatbots with IBM Watson assistant, we saw in the last lesson how to create a Dialog that makes our chatbot interactive with the user.
If you didn’t watch the previous tutorial you can see it in the link below.
In this lesson, we’ll go deeper into dialog with more advanced techniques.
Giving the answer about Hours of operation
We characterized purposes for individuals asking about hours of operation and addresses of our Hotels Services and even made a substance to have the option to give address explicit answers.
Be that as it may, much like the Chatting intents, intents alone don’t offer reactions to clients. We’ll need to create nodes to handle these two business-specific intents.
Let’s see how to do that in action:
First, we gonna create the parent node, now we need to create a node for hours of operation for our Hotels Services.
With the welcome node selected click on the Add node button.
This will create an empty node below the first node as shown in the image below.
Go ahead and name it Operation_Hours, you can choose any name you want like hours_of_operation or wherever you want I’m gonna stick with that name and add “#hours_info” intent to the condition.
In the response, enter this code:
Our hours of operations can be founded <a href=”http://bit.ly/34ewr3X”>Here</a>.
As you can see the HTML code is allowed in responses, making the chatbot more interactive and useful textual answers.
Click on Try it out panel and test that it works by asking: What are your hours of operation in new york?
As you see everything is working well until now.
After all, the user might ask about a specific location, even we detected it with the @location entity as well as the system entity.
After that continued to overlook it or ignore it, opting instead for a generic answer, We can show improvement over that.
We’ll utilize our current node to capture the operation hours inquiries or questions, and then jump to the child nodes to decide how to get the request on the basis of the specific location information that was or wasn’t provided.
Now we gonna Create the Hotels_Location child node, just follow these steps:
Delete the response from our Operation_Hours node by clicking on the trash bin icon. We have to do that because we don’t want this parent node which is Operation_Hours to provide the answer to the user. We’ll make the child nodes decide the appropriate response.
With the Operation_Hours node selected, click on Add child node.
This creates the first child node. We’ll make use of it for the case of the user providing the chatbot a city for which we have Hotels services.
So go ahead and name it Hotels_Locations, or where ever name you want, I will stick with that name.
Set the condition to @location because we want to execute this node only if the user is asking about hours of operation for
Adding a child node allows you to add to an existing conversation path.
The child node is executed only if the parent node’s condition is true or if it’s jumped to from elsewhere. The intent will be hours info, The input will have the @location entity. Knowing this allows us to provide very specific responses.
We need an approach to offer an alternate reaction for every city, so we have to enable Multiple conditioned responses.
Click on the Customize link within our child node as shown in the image above, then scroll down and Switch Multiple conditioned responses and click Apply.
You can see that we have the ability to add a condition to each response.
Go ahead and create a series of responses one for each city.
In the IF ASSISTANT RECOGNIZES section you’ll want to enter the specific city as shown here:
- @location:(New York)
Add one for each box and you can click the Add response button to add a response, it worth noting that I add parenthesis in New York, that doesn’t matter you can add it or not it’s up to you.
And in the RESPOND WITH section add these examples:
- Our New York Hotels are open all week from 6 am until 11:59 pm.
- Our Pennsylvania Hotels are open all week from 6 am until 11:59 pm.
- Our Florida Hotels are open all week from 6 am until 11:59 pm.
- Our Texas Hotels are open all week from 6 am until 11:59 pm.
Choose any examples you want because these examples are just for demonstration purposes.
The end result should be similar to what you see in the image below.
Since we have a child node taking care of handling hours of operation for our particular Hotels locations, we can focus on working on the case in which a client gives a city that we don’t have a Hotel in that city.
With the Hotels_Locations node selected, click the Add node button to add a node below it as shown in the image above.
Call this node No_Location or where ever you want, and add @sys-location as the condition.
In the text response, enter:
Unfortunately, we haven’t a Hotel in @sys-location. Our Hotels are in New York, Pennsylvania, Texas, and Florida.
Feel free to come up with a generic response or you can use this, it’s up to you.
Notice that @sys-location will also recognize our own locations, however, this node will never be executed for our own locations, since it comes after the Hotels_Locations node.
Remember, The execution of the dialog always goes top to bottom and stops at the first node for which the condition is true.
In conclusion, when organizing your dialog, always place nodes with specific conditions at the top and ones with more generic conditions at the bottom.
Now we need to have a child node to take care of the case in which the user didn’t specify a location.
With the No_Location node selected, click the Add node button to add a node below it.
Call this node Location_Not_Specified and set the condition to be true as shown.
When does the client or the user ask a question: What are your hours of operation? The hours_info intent gets detected, so we gonna give the user our Hours of Operation.
Hotels_Locations child node every time evaluated first because it is on the top of the three nodes.
We fail its condition because the user didn’t mention a certain location, so the next child node will be executed, We also fail that condition because no @sys-location is detected either, So we finally consider this third child node will be executed.
We need a generic answer for when no location is specified, feel free to come up with a generic answer.
But for me, I will stick with that message I have provided you earlier:
Our hours of operations can be founded <a href=”http://bit.ly/34ewr3X”>Here</a>.
Now Before doing anything, we need to make sure that the parent node.
In this case, Operation_Hours hands off control to the child nodes.
Select the parent node which is Operation_Hours node, and scroll down you see the “And finally” section is set to Wait for user input, This is not what we want.
The user has already provided us with the question and we haven’t responded yet just change this section of Operation_Hours to Skip user input.
This will hand off the execution to the two-child nodes we have just created befor.
Click on the Try it button and try some inputs like:
- what are your hours of operations in Florida?
- What are hours of operations in new york?
You should see everything is working well.
Giving answer about locations
Our clever chatbot is getting more useful by each step, but now we need to handle Hotel location address requests.
We’ll have a parent node and three children to distinguish each scenario.
We need to create a new parent and child nodes to take care of address requests and we will need to change one condition #location_info instead of #hours_info and change the responses from Operations_Hours to the actual addresses.
however, the structure is the same, so we can simply duplicate Operation_Hours and change this copy to what we need.
Let’s see that in action:
Click on the three vertical dot icon to the right of the Operation_Hours node and select Duplicate to make a copy of Operation_Hours and its children and even it will duplicate it with the same info inside of it.
Select the Operation_Hours — copy1 node that was generated.
Change its name to Our_Location_Information and set the condition to #location_info.
Watson will only execute the node when the user asks us about an address not hours of operation.
Next, we have to change the responses in two child nodes within the Our_Location_Information node tree.
Be aware and don’t change the No_Location response because the one we have applies to both requests for hours of operation and for address requests from the user which was this message “Unfortunately, we haven’t a Hotel in @sys-location. Our Hotels are in New York, Pennsylvania, Texas, and Florida.”
Feel free to come up with any answers, but here is the type of response you should assign to each city in Hotels_Location node:
- Our New York Hotel is located on Madison Avenue.
- Our Pennsylvania Hotel is Located at Grant Street.
- Our Florida Hotel is Located at Duval Street.
- Our Texas Hotel is Located at Austin’s Dirty Sixth Street.
And for Location_Not_Specified node just type:
Our List of Locations can be founded <a href=”http://bit.ly/34ewr3X”>Here</a>
Open the Try it out panel, press Clear to start a new conversation and asking something like:
What are hours of operations in new york?
what are your hours of operations in Florida?
do you have a Hotel in Florida?
What’s the address of your New York Hotels?
In the next lesson, we will see how to deploy the chatbot on WordPress.