Skip to content
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

services platforms author
cognitive-services, luis, language-understanding
cahann, lmazuel, kamip

Cognitive Services: LUIS Runtime Sample

A example demonstrating how:

  • to consume the LUIS Authoring SDK to build an app or manage it
  • to consume the LUIS Runtime SDK to predict user utterances.


The minimum prerequisites to run this sample are:

The first step is to get your Programmatic Key. Go to the home page,, and log in. After creating your LUIS account, a starter key, also known as a programmatic key, is created automatically for LUIS account. To find the programmatic key, click on the account name in the upper-right navigation bar to open Account Settings, which displays the Programmatic Key.

Get the programmatic key

Set the LUIS_SUBSCRIPTION_KEY environment variable to this programmatic key to continue.

Cognitive Services: LUIS Authoring Sample

We provide two samples:

  • The booking sample who is a complete example on how to create an app, create intents, utterances, training and publishing the app
  • The management example shows management operations: import or export an app/version, listing the different versions of an app, cloning a version, etc.

Cognitive Services: LUIS Runtime Sample

LUIS Application

The first step to using LUIS is to create or import an application. Go to the home page,, and log in. After creating your LUIS account you'll be able to Import an Existing Application where can you can select a local copy of the LuisApp.json file an import it.

Import an Existing Application

If you want to test this sample, you have to import the pre-build LuisApp.json file to your LUIS account.

Once you imported the application you'll need to "train" the model (Training) before you can "Publish" the model in an HTTP endpoint. For more information, take a look at Publishing a Model.

Finally, edit the luisRuntime.js file and update the attribute placeholders with the values corresponding to your Application and Azure Region where the application was deployed.

Where to find the Application ID and Subscription Key

You'll need these two values to configure the LuisDialog through the LuisModel attribute:

  1. Application ID

    You can find the App ID in the LUIS application's settings.

    App Settings

  2. Subscription Key and Azure Region

    Click on the Publish App link from the top of the LUIS application dashboard. Once your app is published, copy the Region and Key String from Starter_Key from the Endpoints table on the Publish App page.

    Programmatic API Key

Code Highlights

One of the key problems in human-computer interactions is the ability of the computer to understand what a person wants, and to find the pieces of information that are relevant to their intent. In the LUIS application, you will bundle together the intents and entities that are important to your task. Read more about Planning an Application in the LUIS Docs.

Once your model is set, you can invoke the LUIS Runtime API to analyze user input and obtain its intent and possible entities.

From NPM, use the azure-cognitiveservices-luis-authoring and azure-cognitiveservices-luis-runtime packages.

const CognitiveServicesCredentials = require('ms-rest-azure').CognitiveServicesCredentials;
const LUISRuntimeClient = require("azure-cognitiveservices-luis-runtime");

// Create client with SubscriptionKey and Azure region
const credentials = new CognitiveServicesCredentials(subscriptionKey);
const client = new LUISRuntimeClient(credentials, "")

// Predict
const result = await client.prediction.resolve("[LUIS_APPLICATION_ID]", "Text to Predict or User input")

The LuisResult object contains the possible detected intents and entities that could be extracted from the input.


You will see the following when running the application:

Executing query: find flights in economy to Madrid
Detected intent: FindFlight (score: 95.57%)
Detected entities:
	-> Entity 'economy' (type: Class, score: 85.95%)
	-> Entity 'madrid' (type: Destination, score: 89.44%)
	-> Entity 'economy to madrid' (type: Flight, score: 81.03%)
Complete result object as dictionary
{"query":"find flights in economy to Madrid","topScoringIntent":{"intent":"FindFlight","score":0.9557334},"entities":[{"entity":"economy","type":"Class","startIndex":16,"endIndex":22,"score":0.8595318},{"entity":"madrid","type":"Destination","startIndex":27,"endIndex":32,"score":0.8943938},{"entity":"economy to madrid","type":"Flight","startIndex":16,"endIndex":32,"score":0.8102929}],"compositeEntities":[{"parentType":"Flight","value":"economy to madrid","children":[{"type":"Class","value":"economy"},{"type":"Destination","value":"madrid"}]}]}

More Information

To get more information about how to get started in Bot Builder for .NET and Conversations please review the following resources:

You can’t perform that action at this time.