In previous blog we learnt about Bot Service. To see the previous blog click here. As mentioned earlier I have divided the blog into 4 parts mentioned below.
- Learning Bot service
- Understanding what is LUIS
- Writing code in Bot Framework to do other stuff (like get weather)
- Integrate bot with Facebook messenger
Part II – Understanding what is “LUIS”
LUIS is Microsoft’s language understanding tool kind of similar to DialogFlow by Google (if you have used one). Well, DialogFlow pretends to give you much more than LUIS but there are several limitations. In DialogFlow you have to key in phrases that users might use and if user don’t key in those words then it won’t recognize it. LUIS is much more intelligent in that sense. You key in few examples of phrases that user might use and LUIS intelligently picks up on phrases that were not keyed in but means the same thing. Enough with the differences. Lets learn some basic terminology. Now, most of the terminology has been documented here; but I am going to put it in very simple terms as of what I understood. Also, this blog will be focused on keeping it simple and sweet.
- Intent means purpose of a user’s input. In other words, what is the purpose of the user or what is the user expecting the application to do. Example, weather.
- Utterance means phrases that user can use to show his intent. Example, what is the weather.
- Entities means categorization of relevant information in utterance or phrase. Example, what is the weather in New York; in this phrase New York is categorized as a Location entity.
Now, LUIS is not totally needed to build a bot in Azure. But if you want to build intelligence in your bot to recognize what users intent is then having knowledge of LUIS really helps.
When you create a new Web Bot App with Bot Template as LUIS then LUIS app is automatically created for you. To access LUIS app visit https://www.luis.ai.
Once you open the LUIS app you can click on the Intent tab which will show you list of all the Intents you have created. As you have created this LUIS app via Web Bot App you will see some default Intents already created. This is shown below.
Let’s create weather intent which will get the current temperature for us. click on “Create Intent” button and type in the intent name (whatever you like).
Now we know how to create Intent but if you type “How is weather in Charlotte” we want LUIS to detect that ‘Charlotte’ is a city. For this we will use Entity. Click on Entity on the left hand sidebar; then click on Create new Entity button. Enter name as “City” and keep the Entity Type as Simple.
Let’s go back to the Intent and see how we can use Entity in the utterance.
Use Entity in Intent’s utterances
Type the utterance as “How is the weather in Charlotte”. We now want LUIS to recognize Charlotte is City entity. Once the utterance is added; select Charlotte and you will get an option to select Entity. This is shown below.
Use of Phrase List
What if city name contains two words? Well, you have phrase list for that. You can train LUIS to understand such scenarios. Cool, right!! Let’s try it. Click on Phrase List on the left hand sidebar and click Create new Phrase List.
Now, let’s add utterance with one of the city from the phrase list.
Train and Test the model
Once all the utterance are entered you can train the model by clicking on Train button located on the top right corner of the application (shown below).
Once the model is trained its ready to test. We can enter the utterance similar to the one we have entered in the examples. During the test I have entered “what is the weather in Chicago”. It is similar but not exactly how we have entered any of the utterance. Now, lets inspect the response from LUIS.
As you can observe the utterance is not exactly the one we entered in the example list. Hence, when LUIS detected the proper intent it also gave a score of 0.82. It also detected the Entity as city with value Chicago.
Your LUIS is trained to identify “Weather” intent. Let’s look at how we can now identify the intent and do some work like “get weather details” in our example.
Leave a comment with your feedback, questions or improvements needed.