Let your app understand human language with LUIS


We are on the way to the next era of human-computer interactions. In addition to traditional Graphic User Interfaces (GUI) new interfaces are coming. This interface is also known as Conversational User Interfaces (CUI) that allows people to deal with a computer in more natural way. The way that is called conversation. We use conversations for sharing information between each other. It’s very comfortable for us so why not moving this beautiful thing to your application.

A lot of big companies move in this direction and already have products that implement the idea of CUI. Microsoft has Cortana, Apple has Siri, Google has Google Now. These products look like personal user assistants and help us to interact with a computer in the same way we do it with each other.

CUI with GUI
Let me show you how Conversation User Interface can be more productive than traditional Graphical User Interface. As an example, I will set the alarm for 8 AM for a weekday in two ways. The first way is using traditional GUI and steps to accomplish our task look like this:
1) Open Clock application.
2) Open Alarm Tab.
3) Press ‘+’ button to add new alarm.
4) Enter the time ‘8:00 AM’
5) Press on ‘Repeat’ to set days and choose all weekdays.
6) Press ‘Save’.
Now let’s have a look how this goal can be accomplished with Conversational User Interface:
1) Open Siri
2) Dictate ‘Wake me up on weekdays at 8 AM’
As you can see in this simple task CUI takes 3 times fewer steps over GUI. Also it looks more natural and two times faster to implement.

The work of Conversational User Interface can be described in three parts.
1) Receiving the utterance. It can be voice dictation, entered text or others.
2) Analyzing the text to make computer understand what human said.
3) Based on an order provide a result.

In this article, we will speak about the implementation of the most interesting part of this process i.e. text analyzation.

In human-computer interaction, the key problem is to understand what a user wants from a computer. Thanks to Microsoft Project Oxford called LUIS there is a simple way to do it. Language Understanding Intelligent Service (LUIS) enables you to interpret utterances which you send to it that can help your app a lot to understand a user. There are two ways to use LUIS. You can use pre-built Cortana applications and your own ones. Cortana applications give you the ability to understand a lot of things that Cortana (personal assistant for Windows 10) can.

The endpoint of LUIS is a REST API that keeps you flexible to choose technology for your app. To make it’s clear for understanding let’s start from an example.

Our application needs to understand an utterance like “What is the weather in Lviv?”. The good news is that the utterance like this is a part of pre-built Cortana apps and you don’t need to develop something custom to work with that. You just need to setup your Cortana app endpoint.
To do that follow the next steps:
1) Sign in on LUIS portal
2) Choose Cortana app and the language you want to use

3) To test the query from the portal you can enter it and press Enter. Also, you can take URL and use it in your application. Let’s enter “What is the weather in Lviv?” and press Enter

4) The result is that JSON. LUIS understands that we ask about the weather for location Lviv. You can view the whole list of different intents that is a part of pre-built Cortana apps here

  "query": "What is the weather in Lviv?",
  "intents": [
      "intent": "builtin.intent.weather.check_weather"
  "entities": [
      "entity": "Lviv",
      "type": "builtin.weather.absolute_location"

To make LUIS understand more specific intents you can create your own app. Let’s create an app for managing temperature on an air conditioner.
1) Press “New App”, enter the application name and press “Add App”.
2) When the application is created, you will see an application page. Every LUIS app has it own page where you can add new intents, entities, etc., and train the app.
3) To add a new intent just press “+” near Intents and enter data as in the image below.
4) As you can see our intent contains number 21 that represents the temperature. To make our app recognize this we need to add new Entity. You can add pre-build entities as well as your own ones. Build-in entity is a number, temperature, dimensions, etc. In our case we will add a number.
5) To make the system recognize the number press on a yellow arrow. As you can see 21 is now a number. Press “Submit”.
6) Let’s also add an ability for our app to use a different temperature scale like Fahrenheit or Celsius to make a user ask system utterances like “set temperature to 21 Fahrenheit”. To make this we can add pre-built entity temperature or add our own. We will add our own one to demonstrate you how it works. First you need to press “+” near Entities, enter the new entity name and press “save” as in the image below.
7) Now we add a new utterance “set temperature to 21 Fahrenheit”. To let the system know that Fahrenheit is a temperature scale press on it and select “Temperature scale”. Then press Submit.
8) The same way we can add Celsius temperature scale.
9) To make the app available via HTTP press on “Publish” and then on “Publish web service”
10) Congratulations, our app is available via HTTP and we can ask it some questions like “set temperature to 100 Fahrenheit”. The result will be JSON with interpreted sentence.

  "query": "set temperature to 100 Fahrenheit",
  "intents": [
      "intent": "Change temperature",
      "score": 0.999931335
      "intent": "None",
      "score": 0.0436323658
  "entities": [
      "entity": "fahrenheit",
      "type": "Temperature scale",
      "startIndex": 23,
      "endIndex": 32,
      "score": 0.6297436
      "entity": "100",
      "type": "builtin.number",
      "startIndex": 19,
      "endIndex": 21,
      "score": 0.9628851

Though LUIS is still in beta, it is a powerful instrument that can help your app be more natural. You can create your own LUIS applications and also use pre-built Cortana apps. LUIS gives you a free 100,000 transactions per month so we hope you will find it interesting and useful for your app.

Posted by Andriy Koval

Andriy is a founder and CEO at Westcoup. Contact him anytime at andriy.koval@westcoup.com