LUIS Build Application - microsoft-campus-community/workshop-shopping-list-bot GitHub Wiki

Prerequisite: This page assumes that you have a LUIS (Language Understanding) resource up and running in Azure. If you do not have one yet, follow the steps to create one first.

Wiring LUIS up to our Azure Language Understanding Resource

Now, you are going to create your LUIS application so that you can use it to predict what action (add/remove/mark/unmark item to/from/in the shopping list, get all items in the shopping list and remove all items from shopping list) the user wants the bot to perform (intents). You are also going to train the LUIS model so that it can extract entities from a message. Entities are domain-specific. For the shopping list domain, you will define entities like the name of an item and the unit (i.e., 1 kg, 2 pounds) for an item. This will enable our bot to know what the chat participant wants (intents) and the input (entities) for the specific action on the shopping list.

  1. Go to Luis.ai in your browser.
  2. Click on 'Login / Sign up' and log in with the Microsoft account you used to create the Language Understanding resource in Azure. Screenshot of luis.ai landing page. Red circles around 'Login / Sign up' and 'Sign in' buttons
  3. You are greeted with a prompt. Select the Azure subscription you used to create the language understanding resource previously. Under the 'Authoring resource' dropdown, you should select the '<NAME_OF_YOUR_LUIS_APPLICATION>-Authoring' resource you created previously. Click on 'Done'. Screenshot of luis.ai prompt to select Azure Subscription and LUIS authoring resource
  4. Now, you have three options to create all the intents and entities for LUIS. Pick one path.
    1. FIRST PATH is the easiest path because you can simply import the completed LUIS application and move on.
    2. SECOND PATH will start by using prebuilt intents and entities included in LUIS. With the prebuilt intents and entities as a starting point, we then only need to add a couple more by hand.
    3. THIRD PATH will create all intents and entities by hand.

[FIRST PATH] import LUIS application

This is the quickest way to create the LUIS application to use with the shopping list bot. If you are short on time, this way is for you. Import the complete LUIS application and be done with the LUIS application.

  1. Select 'Import as JSON' from the dropdown menu right to '+ New app'. Screenshot of luis.ai application list. Red arrow pointing at 'Import as JSON' in the dropdown next to '+ New app'
  2. When the 'Import new app' prompt is open upload the exported [LUIS JSON from our repository] (../blob/master/luis-shopping-list-app/Shopping-List.json). Give it a name, for example, 'Shopping List'. Screenshot of luis.ai prompt to import LUIS app from JSON
  3. Now, you are ready to move on to the next part of the workshop.

NEXT: Train LUIS


[SECOND PATH] Prebuilt intents

This is the second of three ways to create the LUIS application for the shopping list bot. You will start with prebuilt intents LUIS provides. Afterward, you will need to add some more intents by hand.

  1. Create a new LUIS application by clicking the '+ New app' button. Screenshot of luis.ai 'Conversation App' page with a red circle around '+ New app' button.
  2. Create a new app
    • In the 'Create new app' prompt, enter a new name for your LUIS application, for example, 'Shopping List'.
    • For culture, this documentation uses 'English'. The culture tells LUIS what language it can expect for the messages we will send to it. You could use a different culture. However, this will be more work for you later because you will need to remember to translate some of the later instructions.
    • Add a small description to your app.
    • Lastly, select the prediction resource you created earlier from the dropdown.
    • When everything is filled out, click 'Done'. Screenshot of luis.ai prompt to create a new LUIS application
  3. After the LUIS application is created, it will open automatically. You can click through the getting started documentation or close it.

LUIS provides prebuilt intents and entities that you can use if they fit your domain. It has some prebuilt intents for the ToDo domain, a great starting point for the shopping list bot.

  1. Click on the '+ Add prebuilt domain intent' button, which will show you all the available prebuilt intents. Screenshot of luis.ai Intents page with a red circle around '+ Add prebuilt domain intent' button
  2. Type 'Todo' in the search bar of the 'Add prebuilt domain models' prompt. Of the prebuilt intents select 'ToDo.AddToDo', 'ToDo.DeleteToDo', 'ToDo.MarkToDo' and 'ToDo.ShowToDo'. When you have the four checkboxes selected click 'Done'. Screenshot of luis.ai Add prebuilt domain models with 'Todo' entered in the search bar and 'ToDo.AddToDo', 'ToDo.DeleteToDo', 'ToDo.MarkToDo' and 'ToDo.ShowToDo' selected in the list of available prebuilt intents.
  3. You should now see the four prebuilt intents and the 'None' intent in the list.
  4. Rename the four prebuilt intents so they match with the naming the bot will use. Rename 'ToDo.AddToDo' to 'AddItem', 'ToDo.DeleteToDo' to 'Remove Item', 'ToDo.MarkToDo' to 'MarkItem' and 'ToDo.ShowToDo' to 'GetAll'.
    • Set the checkbox in front of one prebuilt intent.
    • Click the 'Rename' button. It is in the row with the search bar.
    • In the 'Rename Intent' Name field, enter the new name and click 'Done'.
    • Repeat step 4. until you have all four prebuilt intents renamed. Screenshot of luis.ai Intents page with checkbox in front of 'ToDo.AddToDo' selected and red circle around 'Rename' button.
  5. Now navigate to the entities page by clicking on 'Entities' in the left navigation list. Screenshot of luis.ai Intents page with a red arrow pointing to 'Entities' in left side navigation list
  6. Three prebuilt entities have been added with the prebuilt intents. If your entities list is empty, refreshing the website should help. You are going to rename 'ToDo.TaskContent' to 'ItemName' and 'ToDo.TaskContent.Any' to 'ItemName.Any'. This is done through the same steps as renaming intents. After renaming, your entities page should look like the following. Screenshot of luis.ai Entities page with 'ItemName', 'ItemName.Any' and 'ordinal' entities.
  7. Now, you have a great starting point of intents and entities, which you can extend by adding your own intents and entities specific to the shopping list bot functionality. For this, you will need to follow some steps of the third path.
    • Number entity while the prebuilt ordinal entity is already there, you still need to add the prebuilt number entity.
    • Create UnitName entity so LUIS can recognize common units when it comes to food.
    • Create RemoveAll intent, which is not included in the prebuilt ToDo domain. This is a functionality the bot provides.
    • Create UnmarkItem intent The prebuilt ToDo domain includes a mark item intent you already added. The bot also provides the reverse functionality unmarking an item. You need to create one last intent before you can move on to the next part of this workshop.
  8. If you have all 4 bullet points listed above from the third path completed, you can move on to the next part of the workshop.

NEXT: Train LUIS


[THIRD PATH] LUIS application from scratch

This is the third way to create the LUIS application. You will create all your intents and entities by hand.

  1. Create a new LUIS application by clicking the '+ New app' button. Screenshot of luis.ai 'Conversation App' page with a red circle around '+ New app' button.
  2. Create a new app
    • In the 'Create new app' prompt, enter a new name for your LUIS application, for example, 'Shopping List'.
    • For culture, you can use 'English'. The culture tells LUIS what language it can expect for the messages. You could use a different culture. However, this will be more work for you later because you will need to remember to translate some of the other instructions.
    • Add a small description to your app.
    • Lastly, select the prediction resource you created earlier from the dropdown.
    • When everything is filled out, click 'Done'. Screenshot of luis.ai prompt to create a new LUIS application
  3. After the LUIS application is created, it will open automatically. You can click through the getting started documentation or close it.

[THIRD PATH] First, we will define the entities we want LUIS to recognize

  1. Navigate to the 'Entities' Page by clicking on it in the left navigation list. Screenshot of luis.ai empty Intents page with a red arrow pointing to Entities in navigation bar

[THIRD PATH] Create ItemName entity

Create an entity called 'ItemName', representing the part of a text that should be added to the shopping list.

  1. On the 'Entities' page, click '+ Create'. Screenshot of luis.ai empty Entities page with a red circle around '+ Create' button
  2. In the 'Create an entity' prompt, give the new entity the name 'ItemName' and leave the type as Machine Learned. Machine Learned means that LUIS should learn what we mean by ItemName from examples using machine learning algorithms. Click the 'Create' button, and the new entity should show up if you go to the 'Entities' page again. Screenshot of luis.ai prompt to create a new LUIS entity with name 'ItemName' and type 'machine learned'

[SECOND & THIRD PATH] Add prebuilt ordinal and number entity

The bot should be able to recognize the quantity of an item for the shopping list. For this, LUIS needs to be able to recognize numbers. LUIS provides prebuilt entities for numbers. You also want the bot to know which item in the shopping list the user might reference by position (1st, second, ...). For this, we can use the prebuilt ordinal entity.

  1. On the 'Entities' page, click 'Add prebuilt entity'. Screenshtot of luis.ai Entities page with red circle around 'Add prebuilt entity' button
  2. In the 'Add prebuilt entities' prompt, scroll down until you find 'number' and 'ordinal'. Make sure both are selected. Click 'Done' to add them to your LUIS application. Screenshot of luis.ai prompt to add prebuilt entities with prebuilt entity number and ordinal selected

[SECOND & THIRD PATH] Create UnitName entity

When a chat participant adds an item to the shopping list, they should be able to specify a unit (e.g., kg, pounds, etc.) for the item. Hence, you need one more entity so LUIS can recognize these units.

  1. On the 'Entities' page, click '+ Create'. Screenshot of luis.ai Entities page with a red circle around '+ Create' button
  2. In the 'Create an entity' prompt, type in name 'UnitName' and as type select 'List'. List means that this entity will be a fixed set you will have to define next. Before you do that, click 'Create'. Screenshot of luis.ai prompt to create a new LUIS entity with name 'UnitName' and type 'list'
  3. After the UnitName entity is created, it should automatically open. Here you define the list of units and for each unit optional synonyms. LUIS will take care to recognize the units even if they are differently capitalized than defined. Here are the units that you should enter.
Normalized values Synonyms
gram grams, g
kilogram kilograms, kg
milligram milligram s, mg
ounce ounces
pound pounds
gallon gallons
liter liters, l
milliliter milliliter, ml

This is how the unit list looks like after typing in all the values. Screenshot of luis.ai UnitName entity page with units added to the list of units we use in the bot.

Now you are ready to define the intents you want LUIS to recognize

  1. Navigate to the 'Intents' page. There should be a 'None' intent. The 'None' intent tells LUIS example sentences that are not a command in our domain. After creating new intents for the positive cases where LUIS should recognize commands, you can add some everyday sentences. Screenshot of luis.ai 'Intents' page with default 'None' intent as only intent in the list.

[THIRD PATH] Creating AddItem Intent

LUIS should recognize if a text is a command to add a new item to a list and extract all the new item information from the text.

  1. Click '+ Create' on the LUIS 'Intents' page to create a new intent. Screenshot of luis.ai 'Intents' page with default 'None' intent as only intent in the list and red circle around '+ Create' button
  2. As the name type in 'AddItem' and click 'Done' Screenshot of luis.ai 'Create new Intent' prompt with text field name contains 'AddItem' and red circle around 'Done' button
  3. Once created, the page for the 'AddItem' intent will open, and you can train LUIS by typing in sentences you want it to associate with adding an item.
  4. In the textbox below 'Example User Input', type in a sentence like 'add two kilograms of flour' and hit enter. Screenshot of luis.ai 'AddItem' intent page with 'add two kilograms of flour' typed in as an example user input.
  5. Once it is submitted, you can see it in the list of example sentences. You also see that LUIS can already recognize some entities like 'two' as a number and 'kilograms' as UnitName because they are underlined. However, LUIS does not yet know about the ItemName, which in this case should be flour. Click on 'flour' in the example sentence so that it gets selected. By dragging the brackets, you could extend the selection. For this example, sentence you only want it to extract 'flour' as the ItemName, so the selection should be good. The flyout presented below the selected 'flour' word shows all the custom entities you can mark this word as for LUIS to learn that words like it belong to this entity class. Click on 'ItemName' because this is the entity 'flour' should be classified as. Screenshot of luis.ai 'AddItem' intent page with 'flour' in example sentence marked and flyout presenting all the entities we can select.
  6. Now, 'flour' is marked as 'ItemName' entity. You should train LUIS with more examples so it can get better. Below the image is a list of examples for you to get started. Of course, you can get creative and enter sentences about how you would add something to a list. Please share your sentences by creating an issue in this repository. Screenshot of luis.ai 'AddItem' intent page with word 'flour' in example sentence marked as an entity of type 'ItemName'
Example sentence ItemName number UnitName
create a task to get green beans from the grocery store green beans
please add two cans of chopped tomatoes chopped tomatoes two
put ice cream on the grocery list ice cream
put caramel cheese popcorn on my grocery shopping list caramel cheese popcorn
remind me to buy milk milk
remind me to get 2 pounds of apples apples 2 pounds
please add heavy cream to the list heavy cream
to grocery list add 12 eggs eggs 12
remind me to get a liter cooking oil cooking oil liter

[THIRD PATH] Creating GetAll Intent

LUIS should recognize if a text is a command to get all items in the list.

  1. Click '+ Create' on the LUIS 'Intents' page to create a new intent. Screenshot of luis.ai 'Intents' page with the default 'None' intent and 'AddItem' intent and red circle around '+ Create' button
  2. As the name type in 'GetAll' and click 'Done' Screenshot of luis.ai 'Create new Intent' prompt with text field name contains 'GetAll' and red circle around 'Done' button
  3. Once created, the page for the 'GetAll' intent will open, and you can train LUIS by typing in example sentences you want it to associate with getting all items from the shopping list.
  4. In the textbox below 'Example User Input', type in a sentence like 'what do i have to buy on the shopping list' and hit enter. Screenshot of luis.ai 'GetAll' intent page with 'what do i have to buy on the shopping list' typed in as an example user input.
  5. Once it is submitted, you can see it in the list of example sentences. For this intent, you do not need to mark any entities because there are no entities to extract. LUIS should just know which kind of sentences mean that all items in the list should be shown.
  6. You should train LUIS with more examples so it can get better. Below is a list of examples for you to get started. Of course, you can get creative and enter sentences about how you would like to ask a shopping list to tell you all its items. Please share with which sentences you produce by creating an issue in this repository.
Example sentence
get all items
show me my shopping list
get everything on my shopping list
what do i need to buy in the shopping list
what is on my shopping list
would you bring up my shopping list
please show me my shopping list items
can you show my shopping list
all shopping list

[THIRD PATH] Creating MarkItem Intent

LUIS should recognize if a text is a command to mark an item in the list as completed and extract information about which item should be marked.

  1. Click '+ Create' on the LUIS 'Intents' page to create a new intent. Screenshot of luis.ai 'Intents' page with default 'None', 'AddItem' and 'GetAll' intents and red circle around '+ Create' button
  2. As the name type in 'MarkItem' and click 'Done' Screenshot of luis.ai 'Create new Intent' prompt with text field name contains 'MarkItem' and red circle around 'Done' button
  3. Once created, the page for the 'MarkItem' intent will open, and you can train LUIS by typing in sentences you want it to associate with marking an item as completed.
  4. In the textbox below 'Example User Input', type in a sentence like 'mark bananas as completed' and hit enter. Screenshot of luis.ai 'MarkItem' intent page with 'mark bananas as completed' typed in as an example user input.
  5. LUIS should extract which item to mark as completed. Click on 'bananas' in the example sentence so that it gets selected. By dragging the brackets, you could extend the selection. For this example, sentence you only want it to extract 'bananas' as the ItemName, so the one-word selection is good. The flyout presented below the selected 'bananas' word shows all the custom entities you can mark this word as for LUIS to learn that words like it belong to this entity class. Click on 'ItemName' because the entity 'bananas' should be classified in this sentence. Screenshot of luis.ai 'MarkItem' intent page with 'bananas' in example sentence marked and flyout presenting all the entities we can select.
  6. Now 'bananas' is marked as 'ItemName' entity. You should train LUIS with more examples so it can get better. Below the image is a list of examples for you to get started. Of course, you can get creative and enter sentences about how you would mark an item in a shopping list as completed. Please share with which sentences you produce by creating an issue in this repository. Screenshot of luis.ai 'MarkItem' intent page with word 'bananas' in example sentence marked as an entity of type 'ItemName'
Example sentence ItemName ordinal
task completed buy gum gum
cross apples off my shopping list apples
the 3rd task finished 3rd
mark the second task as completed second
buying orange juice is done orange juice
mark task buy a bottle of vinegar as finished vinegar
mark salad on the groceries list salad
completed buying red onions red onions
mark pancake mix on my to-do list pancake mix

[THIRD PATH] Creating RemoveItem Intent

LUIS should recognize if a text is a command to remove an item from the shopping list. You also need to train LUIS to find out which item should be removed.

  1. Click '+ Create' on the LUIS 'Intents' page to create a new intent. Screenshot of luis.ai 'Intents' page with default 'None', 'AddItem', 'GetAll' and 'MarkItem' intents and red circle around '+ Create' button
  2. As the name type in 'RemoveItem' and click 'Done' Screenshot of luis.ai 'Create new Intent' prompt with text field name contains 'RemoveItem' and red circle around 'Done' button
  3. Once created, the page for the 'RemoveItem' intent will open, and you can train LUIS by typing in sentences you want it to associate with removing an item.
  4. In the textbox below 'Example User Input', type in a sentence like 'shopping list delete pineapple' and hit enter. Screenshot of luis.ai 'RemoveItem' intent page with 'shopping list delete pineapple' typed in as an example user input.
  5. You also want LUIS to extract which item should be removed. Click on 'pineapple' in the example sentence so that it gets selected. By dragging the brackets, you could extend the selection. For this example, sentence you only want it to extract 'pineapple' as the ItemName. The flyout presented below the selected 'pineapple' word shows all the custom entities you can mark this word as for LUIS to learn that words like it belong to this entity class. Click on 'ItemName' because this is the entity you want 'pineapple' to be part of. Screenshot of luis.ai 'RemoveItem' intent page with 'pineapple' in example sentence marked and flyout presenting all the entities we can select.
  6. Now, 'pineapple' is marked as 'ItemName' entity. You should train LUIS with more examples so it can get better. Below the image is a list of examples for you to get started. Of course, you can get creative and enter sentences about how you remove an item from a shopping list. Please share with which sentences you produce by creating an issue in this repository. Screenshot of luis.ai 'RemoveItem' intent page with word 'pineapple' in example sentence marked as an entity of type 'ItemName'
Example sentence ItemName ordinal
take coffee off my groceries list coffee
remove peanuts peanuts
todo list delete trail mix trail mix
remove tomato sauce from grocery list tomato sauce
delete mushrooms mushrooms
delete the first item in my shopping list first
remove the 7th shopping list item 7th
remove third third
erase limes from shopping list limes

[SECOND & THIRD PATH] Creating RemoveAll Intent

LUIS should recognize if a text is a command to remove all items from the list.

  1. Click '+ Create' on the LUIS 'Intents' page to create a new intent. Screenshot of luis.ai 'Intents' page with default 'None', 'AddItem', 'GetAll', 'MarkItem' and 'RemoveItem' intents and red circle around '+ Create' button
  2. As the name type in 'RemoveAll' and click 'Done' Screenshot of luis.ai 'Create new Intent' prompt with text field name contains 'RemoveAll' and red circle around 'Done' button
  3. Once created, the page for the 'RemoveAll' intent will open, and you can train LUIS by typing in sentences you want it to associate with removing all items from the shopping list.
  4. In the textbox below 'Example User Input', type in a sentence like 'remove all items from my shopping list' and hit enter. Screenshot of luis.ai 'RemoveAll' intent page with 'remove all items from my shopping list' typed in as an example user input.
  5. Once it is submitted, you can see it in the list of example sentences. For this intent, you do not need to mark any entities because LUIS does not need to extract any input. LUIS should just know which kind of sentences means that to remove all items from the list.
  6. You should train LUIS with more examples so it can get better. Below is a list of examples for you to get started. Of course, you can get creative and enter sentences about how you would like to ask a shopping list to remove all its items. Please share with which sentences you produce by creating an issue in this repository.
Example sentence
remove everything
delete all items from my list
delete all
clear my shopping list
please remove all tasks
shopping list delete everything
remove every item in my todo list
delete my shopping list completely
delete my entire list

[SECOND & THIRD PATH] Creating UnmarkItem Intent

LUIS should recognize if a text is a command to mark an item in the list as NOT completed and extract information about which item should be unmarked.

  1. Click '+ Create' on the LUIS 'Intents' page to create a new intent. Screenshot of luis.ai 'Intents' page with default 'None', 'AddItem', 'GetAll', 'MarkItem', 'RemoveItem' and 'RemoveAll' intents and red circle around '+ Create' button
  2. As the name type in 'UnmarkItem' and click 'Done' Screenshot of luis.ai 'Create new Intent' prompt with text field name contains 'UnmarkItem' and red circle around 'Done' button
  3. Once created, the page for the 'UnmarkItem' intent will open, and you can train LUIS by typing in sentences you want it to associate with unmarking an item.
  4. In the textbox below 'Example User Input', type in a sentence like 'mark spinach as not completed' and hit enter. Screenshot of luis.ai 'UnmarkItem' intent page with 'mark spinach as not completed' typed in as an example user input.
  5. You also want LUIS to extract which item should be marked as NOT completed. Click on 'spinach' in the example sentence so that it gets selected. By dragging the brackets, you could extend the selection. For this example sentence, we only want it to extract 'spinach' as the ItemName, so you do not need to extend the selection. The flyout presented below the selected 'spinach' word shows all the custom entities you can mark this word as for LUIS to learn that words like it belong to this entity class. Click on 'ItemName' because this is the entity you want 'spinach' to be part of. Screenshot of luis.ai 'UnmarkItem' intent page with 'spinach' in example sentence marked and flyout presenting all the entities we can select.
  6. Now, 'spinach' is marked as 'ItemName' entity. You should train LUIS with more examples so it can get better. Below the image is a list of examples for you to get started. Of course, you can get creative and enter sentences how you would mark something on a list as not completed. Please share which sentences you produce by creating an issue in this repository. Screenshot of luis.ai 'UnmarkItem' intent page with word 'spinach' in example sentence marked as an entity of type 'ItemName'
Example sentence ItemName ordinal
set fifth task as not finished fifth
task not completed buy red cabbage red cabbage
the 2nd task is not done 2nd
uncheck cheese in my shopping list cheese
unmark kidney beans kidney beans
please set red lentils in my shopping list as not done red lentils
shopping list unmark romaine lettuce romaine lettuce
rice uncheck rice
untick cucumber on my list cucumber

NEXT: Train LUIS