Quickstart: Use prebuilt Home automation app

Note

This document uses the preview LUIS portal.

In this quickstart, create a LUIS app that uses the prebuilt domain HomeAutomation for turning lights and appliances on and off. This prebuilt domain provides intents, entities, and example utterances for you. When you're finished, you'll have a LUIS endpoint running in the cloud.

Prerequisites

For this article, you need a free LUIS account, created on the LUIS portal at https://www.luis.ai.

Sign in to LUIS portal

A new user to LUIS needs to follow this procedure:

  1. Sign in to LUIS portal (preview), select your country and agree to the terms of use. If you see My Apps instead, a LUIS resource already exists and you should skip ahead to create an app.

  2. Select Create Azure resource then select Create an authoring resource to migrate your apps to.

    Choose a type of Language Understanding authoring resource

  3. Fill in the details for the resource.

    Create authoring resource

    When creating a new authoring resource, provide the following information:

    • Resource name - a custom name you choose, used as part of the URL for your authoring and prediction endpoint queries.
    • Tenant - the tenant your Azure subscription is associated with.
    • Subscription name - the subscription that will be billed for the resource.
    • Resource group - a custom resource group name you choose or create. Resource groups allow you to group Azure resources for access and management.
    • Location - the location choice is based on the resource group selection.
    • Pricing tier - the pricing tier determines the maximum transaction per second and month.
  4. A summary of the resource to be created is displayed. Select Next.

    Create authoring resource

  5. Confirm by selecting Continue.

    Create authoring resource

Select subscription and authoring resource

In the LUIS portal, to see a list of apps or to create an app, select the subscription and authoring resource. Apps are accessed by the LUIS authoring resource.

Select authoring subscription and authoring resource

Create a new app

You can create and manage your applications on My Apps.

  1. In the LUIS portal, on the My apps list, select + Create.

    In the LUIS portal, on the My apps list, select '+ Create.

  2. In the dialog box, name your application Home Automation then select Done. LUIS creates the app. The description is optional and isn't used for authoring or prediction. The prediction resource is also optional when creating a LUIS app. When you publish your app to production, you should assign a prediction resource so your app can handle many requests.

    In the dialog box, name your application Home Automation

    Note

    The culture cannot be changed once the application is created.

Add prebuilt domain

Select Prebuilt domains then search for HomeAutomation. Select Add domain on the HomeAutomation card.

Select 'Prebuilt domains' then search for 'HomeAutomation'. Select 'Add domain' on the HomeAutomation card.

When the domain is successfully added, the prebuilt domain box displays a Remove domain button.

Intents and entities

Select Intents to review the HomeAutomation domain intents. The prebuilt domain intents have sample utterances.

Screenshot of HomeAutomation intents list

Note

None is an intent provided by all LUIS apps. You use it to handle utterances that don't correspond to functionality your app provides.

Select the HomeAutomation.TurnOff intent. You can see that the intent contains a list of utterances that are labeled with entities.

Screenshot of HomeAutomation.TurnOff intent

Train the LUIS app

  1. In the top right side of the LUIS website, select the Train button.

    Train button

  2. Training is complete when you see the status confirming success.

    Tip

    Notifications is available in the top-right navigation and includes a history.

Test your app

Once you've trained your app, you can test it. Select Test. Type a test utterance like Turn off the lights into the interactive test pane, and press Enter.

Turn off the lights

Check that the top scoring intent corresponds to the intent you expected for each test utterance.

In this example, Turn off the lights is correctly identified as the top scoring intent of HomeAutomation.TurnOff.

Screenshot of Test panel with utterance highlighted

Select Inspect to review more information about the prediction.

Screenshot of Test panel with inspection information

Select Test again to collapse the test pane.

Publish the app to get the endpoint URL

In order to receive a LUIS prediction in a chat bot or other client application, you need to publish the app to the endpoint.

  1. Select Publish in the top right navigation.

    LUIS publish to endpoint button in top right menu

  2. Select the Production slot and the Publish button.

    LUIS publish to endpoint

  3. Publishing is complete when you see the status bar at the top of the page confirming success.

    LUIS publish to endpoint

  4. Select the Access your endpoint URLs link in the notification to go to the Azure Resources page. The endpoint URLs are listed as the Example Query.

Query the V3 API prediction endpoint

  1. In the LUIS portal, in the Manage section (top right menu), on the Keys and endpoints page (left menu), select the endpoint URL at the bottom of the page.

    This action opens browser tab with the endpoint URL in the address bar.

    The URL has your app ID, key, and slot name. The V3 prediction endpoint URL looks like:

    https://REGION.api.cognitive.microsoft.com/luis/prediction/v3.0/apps/APP-ID/slots/SLOT-NAME/predict?subscription-key=YOUR-KEY&<optional-name-value-pairs>&query=UTTERANCE-TEXT.

  1. In the browser address bar, for the query string, make sure the following name and value bars are in the URL. If they are not in the query string, add them:

    Name/value pair
    verbose=true
    show-all-intents=true
  2. In the browser address bar, go to the end of the URL and enter turn off the living room light for the query value, then press Enter.

    {
        "query": "turn off the living room light",
        "prediction": {
            "topIntent": "HomeAutomation.TurnOff",
            "intents": {
                "HomeAutomation.TurnOff": {
                    "score": 0.984315455
                },
                "HomeAutomation.QueryState": {
                    "score": 0.009912962
                },
                "HomeAutomation.TurnDown": {
                    "score": 0.00626645749
                },
                "HomeAutomation.TurnUp": {
                    "score": 0.00572059769
                },
                "HomeAutomation.SetDevice": {
                    "score": 0.00379381469
                },
                "HomeAutomation.TurnOn": {
                    "score": 0.00366983772
                },
                "None": {
                    "score": 0.000623856
                }
            },
            "entities": {
                "HomeAutomation.Location": [
                    "living room"
                ],
                "HomeAutomation.DeviceName": [
                    [
                        "living room light"
                    ]
                ],
                "HomeAutomation.DeviceType": [
                    [
                        "light"
                    ]
                ],
                "$instance": {
                    "HomeAutomation.Location": [
                        {
                            "type": "HomeAutomation.Location",
                            "text": "living room",
                            "startIndex": 13,
                            "length": 11,
                            "score": 0.907323956,
                            "modelTypeId": 1,
                            "modelType": "Entity Extractor",
                            "recognitionSources": [
                                "model"
                            ]
                        }
                    ],
                    "HomeAutomation.DeviceName": [
                        {
                            "type": "HomeAutomation.DeviceName",
                            "text": "living room light",
                            "startIndex": 13,
                            "length": 17,
                            "modelTypeId": 5,
                            "modelType": "List Entity Extractor",
                            "recognitionSources": [
                                "model"
                            ]
                        }
                    ],
                    "HomeAutomation.DeviceType": [
                        {
                            "type": "HomeAutomation.DeviceType",
                            "text": "light",
                            "startIndex": 25,
                            "length": 5,
                            "modelTypeId": 5,
                            "modelType": "List Entity Extractor",
                            "recognitionSources": [
                                "model"
                            ]
                        }
                    ]
                }
            }
        }
    }
    

    Learn more about the V3 prediction endpoint.

Clean up resources

When no longer needed, delete the LUIS app. To do so, select My apps from the top left menu. Select the ellipsis (...) to the right of the app name in the app list, select Delete. On the pop-up dialog Delete app?, select Ok.

Next steps

You can call the endpoint from code: