Building a chatbot for Restaurant using IBM Watson Assistant:

Planning your intents and entities
To plan the intents for your application, you need to consider what your customers might want to do, and what you want your application to be able to handle. Choosing the correct intent for a user's input is the first step in providing a useful response. The intents you identify for your application will determine the dialog flows you need to create; they also might determine which back-end systems your application needs to integrate with in order to complete customer requests (such as customer databases or payment-processing systems).

Gather as many actual customer questions, commands, or other inputs as possible. Using input from real users gives a better picture of the expected input than having experts create lists of possible utterances. Remember that customers might phrase the same kind of request in many different ways.

Example

#Enquiry
• What is the price of x item
• Can I get the menu

After gathering all possible questions asked by a customer we can proceed to build a chatbot

Note: 
We will be using same skill created in the previous blog and continue. Therefore before performing this restaurant bot you should complete previous blog i.e., basicchatbot

Step 1: Let’s create an intent for Enquiry. Click on Create intent.





Step 2: Give the intent name as Enquiry and click on Create intent






Step 3: Add the different user examples for Enquiry intent







Step 4: After adding various examples click on back arrow  





Entities represent information in the user input that is relevant to the user's purpose.

Now let’s add entities (Menu, offers, cost) for Enquiry intent

Step 5: Click on entities to create a new entity














Step 6: Click on Create entity






Step 7: Give the name to the entity as Enquiry and click on Create entity






Step 8: Give the value as offers and click on Add value






Step 9: Add one more value Menu and click on <- (back) button










Step 10: Go to Dialog





Step 11: From Greetings node click on Add node below






Step 12: Give the name of the node as Enquiry and condition as #Enquiry and click on customize to give a specific response





Step 13: Enable Multiple conditioned response and click On Apply





Step 14: In the internal textbox enter @ and select the @Enquiry entity





Step 15: Select :is from the option







Step 16: Select “offers” from the drop-down. So the first internal condition executes when the user question is about offers.









Step 17: Give a sample response about offers




Step 18: Click on Add response to add response from the “menu” option





Step 19: Click on settings icon to give image as response






Step 20: Select image as an option 




Step 21: Select the Title as Menu and give a sample URL of the Menu in Image source and click on save

Sample Url: http://pepetonsgrill.com/wp-content/uploads/2018/02/Pepetons-Grill-Restaurant-Menu-00002.jpg






Step 22: Click on X to close the edit window





Step 23: Test the dialog click on Try it icon to open Try it out pane







Step 24: Give input as what are the offers available 







Step 25: Observe the bot response






Step 26: Give the input text as Can I get the menu and observe the bot response 



Step 27: Now let us create intent for ordering. Go to intents click on Create intent and name the intent as Order and click on Create intent




Step 28: Add sample user examples for Order intent and click on left arrow to go back






Step 29: Go to Entities to add entities for order intent  

Step 30: Click on Create entity give the name to the entity as items and click on Create entity

Step 31: Give sample food items in the value of items entity and click on Add value. After adding sample items then click on left arrow




To detect the quantity of the order from the user we have System entity “@sys-number”, we can use this system entity for detecting number’s 

Step 32: Go to System entities



Step 33: Enable @sys-number entity and click on Dialog


Step 34: Add node below from Enquiry node so that new node will generate next to Enquiry node



Step 35: Give the name  as Order and condition as #Order and click on customize to give specific response




Step 36: Enable multiple conditioned response and click on Apply


Step 37: Click on settings to add internal connection

In the internal condition, we have to check whether the user has mentioned about item name and it’s quantity

Step 38:  Enter the first condition as “@items” and click on to add other condition i.e quantity



Step 39: In the second condition add Sys-number for quantity



Step 40: Give your confirmation response as (Your order for @item of quantity @sys-number is ordered successfully) and click on save



Step 41: Click on X to close the edit window



Step 42: Test the Dialog by click on Try it



Step 43: If you see old chat click on clear




Step 44: Chat with bot first saying Hi and ask for 1 plate of Paneer Butter Masala please order and check the response



Sometimes the Customer may forget to give the quantity and the item name so we have to prompt the user for the required information. So, here slots help to prompt the user when required information is lacking in the question.

Step 45: Clear and close the Try it out pane and open Order node and click on customize to enable slots



Step 46: Enable slots and click on Apply


Step 47: In slots, we will check whether the user has mentioned item name or not. So in Check for enter the entity name item as shown below. If it mentioned by the user it will be saved in items

Step 48: If the user didn’t mention about the item, prompt for the information what do you want to order as shown below



Step 49: Click on Add slot and repeat the same for quantity. Please mention the quantity



Step 50: Click on Add response 



Step 51: Click on settings icon to add internal information



Step 52: Choose @item and click  to add other condition



Step 53: Enter the condition as $number!=” “ and enter the response as Your order for @items of quantity $number is ordered successfully and click on save


Step 54: Again click on Add response and click on settings icon  to add the other condition 






Step 55:  In the edit window enter the conditions and response as shown below and click on save  





Step 56: Test the dialog. Click on Try it


Step 57: First give the input as can you order. since item name is not mentioned it prompts of the information




Step 58: Enter the sample item Paneer Butter Masala as shown below and now the bot asks for the quantity as it not mentioned 



Step 59: Click on Manage Context 



Step 60: Check the saved context variable and click X to close the tab


Step 61: Now give the quantity 1 plate and observe the confirmation response, So the confirmation is given only after user mentions the item name and quantity



Now Let’s explore user defined Context Variables. In the start of conversation lets ask for customer name and save in context variable and once the customer is done with the conversation, let’s delete the context variable 

Step 62: Open the edit window of Welcome node and in the response ask for the Customer name as shown below


Step 63: Go to Entities, go to System Entities and enable @sys-person entity  



Step 64: Go to dialog and add child node under Welcome node


Step 65: Give the name of the node as Customer Name and give the condition as @sys-person



Step 66: Click on 3 vertical dot symbol and click on Open context editor to save the person name in the context variable  




Step 67Give the variable name as name and value as @sys-person and give response as shown below.



Step 68: Test the dialog. Click the Try it icon to open the Try it out pane. 

Till now we have built basic Restaurant Bot. Likewise we can keep on add more intents and entities per requirement and build dialog nodes accordingly


Thanks
Yuktesh Chintamadaka


















Comments

Post a Comment