The following article demonstrates how to use LUIS to add conversational intelligence to your apps. The focus will be about creating and consuming Language Understanding Models. We'll add Language Understanding capabilities to the news bot from the previous article. After this article, the bot will be able to interpret English language and map sentences to specific functions in the code.


Microsoft’s Language Understanding Intelligent Service (LUIS) offers a fast and effective way of adding language understanding to applications.

With LUIS, you can use pre-existing, world-class, pre-built models from Bing and Cortana whenever they suit your purposes – and when you need specialized models, LUIS guides you through the process of quickly building them.

Before proceeding, it is important that you understand the basic concepts of LUIS.

a. Intents: Consider intent as an intention or action. What action should a sentence trigger? Search for a news? Look for help? Proceed with sign up? Those can be examples of Intents. Intents match user requests with the actions that should be taken by your app.

b. Utterances: Utterances are sentences representing examples of user queries or commands that your application is expected to receive and interpret. LUIS learns from these utterances and your app is able to generalize and understand similar contexts.

For each intent, add example utterances that trigger this intent and include as many utterance variations as you expect users to say.

c. Entities: An entity represents a class including a collection of similar objects (places, things, people, events or concepts). Entities describe information relevant to the intent, and sometimes they are essential for your app to perform its task.

Imagine a news bot that search for a news. How will the bot know which work in the sentence he should use to search for news? This item that he should search about is called the Entity. Example, from the sentence search for news about Mauritius. Mauritius will be the entity.

Now that you understand the basic concepts of LUIS, let’s go and create your LUIS application.

Creating a LUIS App

To create a LUIS application, go to, register and click on create a new App.

Once you click on new app, you will get screen below to add the basic application details.

Once you click create, you are redirected to the bot dashboard where you can see statistics about the bot.

In this example, we’ll create a bot that allows us to search for news, register for news and get help.

Later in this article, we’ll build and enhance the bot to understand the sentiment of the news, therefore our bot will be able to detect whether a news has a positive or negative sentiment.


Therefore, the bot will have 4 intents, namely, SearchNews, AskHelp, Register and None.

All LUIS application has a None intent created by default which represents any text that it cannot interpret.

Next, click on intent on the dashboard and select Add Intent to add the 4 intents.

Define the Utterances and Entities

For each of the Intents, we now need to add the Utterance and Entities. Click on each of the Intents and start adding the Utterance.

In the example below, we add the utterance “What are the news in Mauritius”.

Now, the question is, how will the bot identify what is the word he needs to search for? This is what Entities are for!

Then, from the Utterance, we select the word news which represents the entity. We need to do the same for a few utterance which will be used to train the model.

In the example below, the word Mauritius is the entity. The bot will know that it needs to search for news about Mauritius.

We need to add a few more examples of the entities such that LUIS has enough materials to learn. Let's add other examples as below.

Now, we also need to be able to identity the good and the bad news. How will the bot know which words to identify good and bad news. For this purpose, we also need to train our bot by adding utterances referencing good and bad news.

The next step is to add the utterance and entity for other Intents such as register for news or to ask for help.

Train the model

The next step is the train the model. To do so, from the left menu, click on Train & Test and click on Train Application.

At this stage, LUIS will learn from all the information that you have entered and should now be able to identify Intents and Entities for new sentences.

Test the Application

Once the model is trained, you can now type in sample sentences and see if it find the intent and entities correctly.

As expected, when we input new sentences, the LUIS correctly identified the intent and entities.

Once done, click on publish and be able to call the LUIS app from the Bot.

Setting up the LuisDialog

Now that the LUIS service is setup, we now need to add t in the bot project to be able to recognize each intents of the user.

What will happen now is that whenever the user input a text, this will be sent to the LUIS model to identify each Intent and their Entities.

To proceed, create a new class RootDialog which implements the LusDialog Object and is specialized to handle intents and entities from LUIS

public class RootDialog : LuisDialog<object>

You also need to add the keys of your LUIS App Id and Subscription key as above. Both can be retrieved in the Publish tab of the LUIS model.

Now, it’s time to map the LUIS intents to the code in out bot. To do so, we need to add specific functions in the class RootDialog and decorate each function having the name of the intent in the LUIS model.

Proceed with the same steps for all the other intents, also, always create the “none” intent for cases the LUIS model could not map the utterance to any intent.

public async Task None(IDialogContext context, LuisResult result)
public async Task Help(IDialogContext context, LuisResult result)
public async Task Subscribe(IDialogContext context, LuisResult result)

Let’s see how the bots behave. As you run the program and ask the bots questions related to the intents, you will see that the bot will now reach the code as per the intent and the entities.


In this article, the use of LUIS to add language capability to the bot has been demonstrated. As discussed, with Microsoft Cognitive Services, it's very easy to add "intelligence" to Apps. In the next article, we'll discuss how we can leverage on the Bing News API, make the bot fetch news from the internet just by asking it using plain English.

See Also

1. Also in the series - Microsoft Bot Framework Basics: Building Intelligent Bots (Part 1) 
2. Kickstart To Microsoft Cognitive Service In Azure Portal
3. Understanding Microsoft Cognitive Services
4. Universal Windows Platform Apps: Microsoft Cognitive Services (Project Oxford)


a. Understanding Natural Language - LUIS