Pass utterances to a LUIS endpoint and get intent and entities back.
Before you begin
You need a Cognitive Services API key to make calls to the sample LUIS app we use in this walkthrough. To get an API key follow these steps:
- You first need to create a Cognitive Services API account in the Azure portal. If you don't have an Azure subscription, create a free account before you begin.
- Log in to the Azure portal at https://portal.azure.com.
- Follow the steps in Creating Subscription Keys using Azure to get a key.
- Go back to the LUIS website and log in using your Azure account.
Understand what LUIS returns
To understand what a LUIS app returns, you can paste the URL of a sample LUIS app into a browser window. The sample app you'll use is an IoT app that detects whether the user wants to turn on or turn off lights.
- The endpoint of the sample app is in this format:
https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/df67dcdb-c37d-46af-88e1-8b97951ca1c2?subscription-key=<YOUR_API_KEY>&verbose=false&q=turn%20on%20the%20bedroom%20light. Copy the URL and substitute your subscription key for the value of the
Paste the URL into a browser window and press Enter. The browser displays a JSON result that indicates that LUIS detects the
HomeAutomation.TurnOnintent and the
HomeAutomation.Roomentity with the value
Change the value of the
q=parameter in the URL to
turn off the living room light, and press enter. The result now indicates that the LUIS detected the
HomeAutomation.TurnOffintent and the
HomeAutomation.Roomentity with value
Copy the code that follows and save it into an HTML file:
"YOUR SUBSCRIPTION KEY"with your subscription key in this line of code:
xhrObj.setRequestHeader("Ocp-Apim-Subscription-Key","YOUR SUBSCRIPTION KEY");
Open the file you saved using a web browser. An alert window should pop up that says
Detected the following intent: TurnOn.