Using Natural Language Understanding, Part 3: LUIS Language Understanding Service

Training Artificial Intelligence to perform real-life tasks has been painful. The latest AI services now offer more accessible user interfaces. These require little knowledge about machine learning. The Microsoft LUIS service (Language Understanding Intelligent Service) performs an amazing task: interpreting natural language sentences and extracting relevant parts. You only need to provide 5+ sample sentences per scenario.

In this article series, we’re creating a sample app that interprets assessments from vital signs checks in hospitals. It filters out relevant information like the measured temperature or pupillary response. Yet, it’s easy to extend the scenario to any other area.

Language Understanding

After creating the backend service and the client user interface in the first two parts, we now start setting up the actual language understanding service. I’m using the LUIS Language Understanding service from Microsoft, which is based on the Cognitive Services of Microsoft Azure.

To get started using LUIS, you need to:

  • Make sure you have a Microsoft Account (usually you should have one from your Windows 10 login).
    If not, sign up for a Microsoft through this link for OneDrive, which gives you an extra free 0.5 GB for your OneDrive storage.
  • Now, sign in at using your Microsoft Account.
    Warning: for some strange reason, Microsoft has created two different versions of LUIS. If you plan to publish your AI service to Europe, create the LUIS service at: – otherwise, use
    Apps can only be manually migrated between the two locations. Read more in the Manage your keys in LUIS section of the documentation.

Azure Account?

At the time of writing, you don’t need an Azure account to use LUIS. Simply use your Microsoft Account to sign in to LUIS as described above. You will get a free “Programmatic Key” (also known as “Starter Key”). It serves up to 10,000 endpoints per month.

If one of the following arguments apply to you, create an Azure account to configure a cognitive service:

  • Serve more than 10,000 endpoints per month
  • You need SLAs for the service
  • Deploy your service to a specific region

With an Azure account, you ultimately have more flexibility. You can create and manage a custom “Endpoint Key” instead of the default “Starter Key”. Follow these steps:

  • Sign up for free to Azure using your Microsoft Account.
  • Create a cognitive service for LUIS, selecting the free pricing tier F0 (which gives you 10K calls per month). Choose the location closest to you. Keep in mind that you can only use a server in Europe if you use LUIS from, as explained in the previous section.
    Give the cognitive service any name you like (e.g., “Dhc-Luis”) and create a new resource group (e.g., “dhc-apps”)

Creating the Language Understanding Cognitive Service in Azure

Create the LUIS Service

In, navigate to My Apps > New App. For the application name, enter “Patient Check” and use the locale you prefer. English currently offers most features. This page lists all supported features per language.

Creating a new app in LUIS

Understanding how LUIS works

Once your app is created, it’s time to look at the options you have in the portal:

  • Intents: think of these as distinct commands that your language understanding service differentiates. In our scenario, we’ll have three: for recognizing the patient’s age, the body temperature and the pupillary response.
  • Utterances: when you create an Intent, you need to specify sample sentences, called utterances. This gives the AI some examples on what the user would say to trigger the intent.
    Utterances for the same “temperature” intent could be: “Your body temperature is [entity]” or “I measured [entity]”
  • Entities: specific information to extract from the utterances. For the body temperature, that’s the actual measured temperature, e.g., “36 degrees”.
    LUIS comes with several pre-built entities for common data: e.g., date & time, dimension, numbers, email and many more. However, you can also create your own entities.

Setting up LUIS – Entities

It’s best to start at the lowest level – the entities. Navigate to the page and create 3 different entities:

  • age: prebuilt / Age
  • pupilLightReaction: simple (custom)
  • temperature: prebuilt / Temperature

Entities defined in LUIS for the Vital Signs checklist app

LUIS Intents

After you created the entities, proceed to the intents. This is the most important step. Here, we define the different “commands” that the service distinguishes.

Intents with Pre-Built Entities

First, add an intent and call it “Temperature”. In the upper text box, provide some sample utterances: complete example sentences of what you could say to trigger this scenario. Press enter after each example to add it to the list below. Some examples:

  • your temperature is 36 degrees
  • i measured 38 degrees celsius
  • the thermometer says you have 98.6 degrees fahrenheit

For the pre-built entities, the service automatically recognizes the entities in the sentence you entered. In our case, temperatures are marked with a light blue background color. If you hover the mouse over this part, you still see the original text you entered.

Pre-built entities in intents, in use with LUIS

Once you have added all the sample utterances you can think of, do the same for an “Age” intent.

Intents with Custom / Simple Entities

These are entities we train ourselves – as such, it’s even more important to provide as many sample utterances as you can think of.

Create an intent with the name “PupillaryResponse”. I’d recommend that you don’t use special characters in the names, as these names get directly sent to your app later. It’s easy that special characters get messed up when your code runs on different operating systems and languages. So better stick to simple names using only standard characters.

This intent describes the measured response of the eye to light. One of the important factors is the speed of the pupillary light reflex – broadly speaking, how fast your pupils adapt to a bright penlight the nurse or doctor shines on your eyes.

As before, type in sample utterances like:

  • no response of your pupils
  • your pupillary response is prompt
  • your left eye has a slow response to light
  • the pupillary light reflex is sluggish

Next, you need to teach LUIS the specific words contained in the example sentences, which it should extract as entities. If it’s only one word (e.g., “prompt”), simply click on the word. If it’s composed of multiple words (e.g., “no response”), click on the first word and then on the last word of the entity to expand the selection. In the pop-up, select the entity to assign.

LUIS: training an entity in sample utterances of an intent

Repeat these steps for all words you want to label as entities in your utterances. I’d recommend that you provide more sample sentences in this scenario, compared to the ~5 sentences that contain pre-built entities.

Training your Language Understanding Service

Now, your service is ready to be trained. LUIS trains the AI to understand the natural language using the examples we provided. It generalizes the utterances we have labeled.

Training the LUIS app with the configuration we've created

Training usually takes a few seconds. After the process is finished, it’s time to test the app. Click on the blue “Test” button in the upper right corner. Next, enter some test sentences.

Our service should recognize intents correctly. Click on “Inspect” to see more details, including the entities extracted from the test sentence. If not, you need to adapt the examples – maybe provide more examples for some intents, or see if any utterances or entities are at the wrong place.

Testing and inspecting the results of a trained LUIS AI

Once you’re satisfied with the results, it’s time to publish your app to move it from the testing environment to the real world.

Publishing your LUIS Service

Finally, we’re ready to publish our LUIS app to the world. So far, you could only play with your app in the browser while logged in to LUIS. This step makes the LUIS service accessible to our Node.js backend, which can run anywhere in the world.

Click on the “Publish” tab in the top bar. As we’re still in the early steps of development, we don’t need to distinguish between staging and production slots yet. This is necessary once the app is in real-world use and you want to test your changes before letting your users access the new version. Therefore, it’s OK to stich with the Production slot.

Publish your LUIS app

In the “Resources and Keys” section at the bottom, ensure that you select the right server for deploying the app. You can stick with the free “Starter_Key”.

Optional: Connecting an Azure Account

If you have created an Azure Account (see the previous part of the article) and set up a Cognitive Service, you can link it with LUIS. In this case, click on “Add Key”. Next, you need to provide your tenant ID. For a new Microsoft Account, you most likely only have one. Otherwise, look up the correct key where you have created the Cognitive Service through the Active Directory in the Azure portal.

Then, select the associated subscription and key from the drop-down menus. For more information on how to select the publishing target, check out the LUIS documentation.

Note that you cannot publish an app created at to a server based in Europe – you would have needed to create it through as mentioned before.

Testing Your Language Understanding App

It’s simple to test your public AI service. In the “Resources and Keys” section of the “Publish app” page, click on the “Endpoint” link. This opens a new browser tab with the query URL pre-set. By default, you see an empty response.

The URL ends with ?q= . Simply append a textual query and press enter, for example “?q=Your temperature is 39 degrees celsius”. You will immediately see the JSON results in your browser window. In this case, the top scoring intent is correctly identified as “Temperature”, and the extracted entity is “39 degrees celsius”.

Testing your LUIS service in the browser

Keep in mind that you’re directly editing a URI here, so be careful with special characters. To quickly convert a string to a properly URL encoded variant, check out the w3schools tool.

Next Steps

The biggest parts are done: we’ve created the HTML5 front-end UI for the user, the back-end server using Node.js, as well as the AI service based on LUIS.

The only remaining task is connecting everything together. That’ll be the focus of the final part of the article series!

Article Series: Using Natural Language Understanding