Language Understanding (LUIS) Quickstart

Learn how to create, train, and query a LUIS app in minutes using the Azure portal and the REST API.

Prerequisites

1. Create a LUIS app

Use the Azure portal to provision a LUIS resource and create an app.

  1. Sign in to the Azure portal.
  2. Search for Language Understanding and click Create.
  3. Fill in the required fields and click Review + create.
  4. After deployment, navigate to the LUIS portal and click New App.

2. Add intents and utterances

Define intents that represent the actions your bot can perform.

{
  "intents": [
    { "name": "BookFlight" },
    { "name": "CancelReservation" }
  ],
  "utterances": [
    { "text": "I want to book a flight to London", "intent": "BookFlight" },
    { "text": "Cancel my reservation", "intent": "CancelReservation" }
  ]
}

3. Train and publish the model

Use the LUIS portal or REST API to train and publish.

curl -X POST "https://{region}.api.cognitive.microsoft.com/luis/api/v2.0/apps/{appId}/versions/{versionId}/train" \
  -H "Ocp-Apim-Subscription-Key: {subscriptionKey}"

4. Query the endpoint

Send a request with a user utterance to get the predicted intent.

const fetch = require('node-fetch');

const endpoint = 'https://{region}.api.cognitive.microsoft.com/luis/prediction/v3.0/apps/{appId}/slots/production/predict';
const query = new URLSearchParams({
  'subscription-key': '{subscriptionKey}',
  'verbose': true,
  'query': 'I need a flight to Paris'
});

fetch(`${endpoint}?${query}`)
  .then(res => res.json())
  .then(data => console.log(data));

Next steps