Skip to content

Microsoft LUIS

What is Microsoft LUIS?

Microsoft LUIS is a machine learning-based service to build natural language into apps, bots, and IoT devices. With LUIS you can create and train enterprise-ready, custom models that continuously improve. With LUIS, Microsoft offers a commercial tool for interpreting textual user input without the need for programming skills.

LUIS supports up to 500 intentions (actions identified in a sentence) and 100 entities (information that is extracted to fulfill the intended purpose). There are currently 12 different languages supported, including English, French, German, Italian, and Spanish.

As a good starting point, you can use the following article: https://docs.microsoft.com/en-us/azure/cognitive-services/luis/luis-quickstart-intents-only

Use LUIS library

The LUIS library can be used in a chatbot to interpret user input using the Microsoft LUIS service.

The user input is sent to LUIS to identify information. Subsequently, LUIS tries to interpret the user goals (intents) and to extract information from sentences (entities). The returned result can then be further processed by the chatbot. The language model is created and administered on the LUIS user interface.

The library is only used to access the LUIS service. You need a Cognitive Services API key to make calls to the LUIS service. Therefore, you need a Microsoft account which can be created at https://azure.microsoft.com/en-us/free/.

How it works

First you have to copy the library de.citunius.businessbot.api.ai.luis-1.x.x.jar into the lib directory of the chatbot. In order to use the LUIS service, the library requires the following parameters:

Parameter Value Description
Luis.AppId xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx Applications-ID (8x4x4x4x12 characters)
Luis.SubscriptionId xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx API Key (32 characters)
Luis.Region e.g., westeurope, westus, australiaeast, eastasia
Luis.Verbose true Verbose, either true or false
Luis.TimezoneOffset 0 Timezone offset

The parameters can be found on the Microsoft LUIS website under Publish app as shown in the screenshot below:

To send a request to LUIS, the client is instantiated and function queryLUIS(query) is called with the user input. As result, object LuisResult is returned with the results interpreted by LUIS.

1
2
3
4
5
6
7
8
9
LuisClient client = new LuisClient(luisAppId, luisSubscriptionId, luisRegion, luisVerbose, luisTimezoneOffset);
LuisResult result;
try {
    result = client.queryLUIS(query);
    System.out.println("Luis result > intent: ["+result.getIntents()[0].getIntent()+"]");
    return result.getIntents()[0].getIntent();
} catch (Exception e) {
    System.err.println("Exception: ", e);
}

For testing, you can also query LUIS directly in the browser using the following URL: https://westeurope.api.cognitive.microsoft.com/luis/v2.0/apps/###APP_ID###?subscription-key=###SUBSCRIPTION_KEY###&verbose=true&timezoneOffset=0&q=wer%20hat%20die%20telefonnummer%20123456?

As result, you will get the following JSON result in the web browser: