Language understanding

Language understanding (LU) is used by a bot to understand language naturally and contextually to determine what next to do in a conversation flow. In Bot Framework Composer, the process is achieved through setting up recognizers and providing training data in the dialog so that the intents and entities contained in the message can be captured. These values will then be passed on to triggers which define how the bot responds using the appropriate actions.

LU has the following characteristics when used in Bot Framework Composer:

  • LU is training data for LUIS recognizer.
  • LU is authored in the inline editor or in User Input using the .lu file format.
  • Composer currently supports LU technologies such as LUIS.

Core LU concepts in Composer

Intents

Intents are categories or classifications of user intentions. An intent represents an action the user wants to perform. It is a purpose or goal expressed in the user's input, such as booking a flight, paying a bill, or finding a news article. You define and name intents that correspond to these actions. A travel app may define an intent named "BookFlight."

Here's a simple .lu file that captures a simple Greeting intent with a list of example utterances that capture different ways users will express this intent. You can use - or + or * to denote lists. Numbered lists are not supported.

# Greeting
- Hi
- Hello
- How are you?

#<intent-name> describes a new intent definition section. Each line after the intent definition are example utterances that describe that intent. You can stitch together multiple intent definitions in a language understanding editor in Composer. Each section is identified by #<intent-name> notation. Blank lines are skipped when parsing the file.

Utterances

Utterances are inputs from users and may have a lot of variations. Since utterances are not always well-formed, we need to provide example utterances for specific intents to train bots to recognize intents from different utterances. By doing so, your bots will have some "intelligence" to understand human languages.

In Composer, utterances are always captured in a markdown list and followed by an intent. For example, the Greeting intent with some example utterances are shown in the Intents section above.

Note

You may have noticed that LU format is very similar to LG format but they are different. LU is for bots to understand user's inputs (primarily capture intent and optionally entities) and it is associated with recognizers, while LG is for bots to respond to users as output, and it is associated with a language generator.

Entities

Entities are a collection of objects, each consisting of data extracted from an utterance such as places, time, and people. Entities and intents are both important data extracted from utterances. An utterance may include zero or more entities, while an utterance usually represents one intent. In Composer, all entities are defined and managed inline. Entities in the .lu file format are denoted using {<entityName>=<labelled value>} notation. For example:

# BookFlight
- book a flight to {toCity=seattle}
- book a flight from {fromCity=new york} to {toCity=seattle}

The example above shows the definition of a BookFlight intent with two example utterances and two entity definitions: toCity and fromCity. When triggered, if LUIS is able to identify a destination city, the city name will be made available as @toCity within the triggered actions or a departure city with @fromCity as available entity values. The entity values can be used directly in expressions and LG templates, or stored into a property in memory for later use. For additional information on entities see the article advanced intents and entities.

Example

The table below shows an example of an intent with its corresponding utterances and entities. All three utterances share the same intent BookFlight each with a different entity. There are different types of entities, you can find more information in .lu file format.

Intent Utterances Entity
BookFlight "Book me a flight to London" "London"
"Fly me to London on the 31st" "London", "31st"
"I need a plane ticket next Sunday to London" "next Sunday", "London"

Below is a similar definition of a BookFlight intent with entity specification {city=name} and a set of example utterances. We use this example to show how they are manifested in Composer. Extracted entities are passed along to any triggered actions or child dialogs using the syntax @city.

# BookFlight
- book a flight to {city=austin}
- travel to {city=new york}
- I want to go to {city=los angeles}

After publishing, LUIS will be able to identify a city as entity and the city name will be made available as @city within the triggered actions. The entity value can be used directly in expressions and LG templates, or stored into a property in memory for later use. Read here for advanced intents and entities definition.

Author .lu files in Composer

You author .lu files as training data for the LUIS recognizer. You need to know:

To create .lu files in Composer, follow these steps:

Set up a Recognizer Type

Select a dialog in the navigation pane and then select Default recognizer from the Recognizer Type drop-down list in the Properties pane on the right side of the Composer screen.

Select recognizer

Create a trigger

In the same dialog you selected the Default recognizer recognizer, select Add in the tool bar and then Add new trigger.

In the pop-up trigger menu, select Intent recognized from the What is the type of this trigger? list. Fill in the What is the name of this trigger (luis) field with an intent name and add example utterances in the Trigger phrases field.

For example, you can create an Intent recognized trigger in the MyBot dialog with an intent named (weather) and a few examples utterances.

weather intent

After you select Submit you will see an Intent recognized trigger named weather in the navigation pane and the trigger node in the authoring canvas. You can edit the .lu file inline on the right side of the Composer screen.

lu inline editor

Select User Input from the Composer menu to view all the LU templates created. Select a dialog from the navigation pane then toggle Edit Mode to edit the LU templates.

User input

Add action(s) to the Intent recognized trigger

Select + under the Intent recognized trigger and add any action(s) you want your bot to execute when the weather trigger is fired.

Send a response

Publish LU to LUIS

The last step is to publish your .lu files to LUIS.

Select Start Bot on the upper right corner of the Composer. Fill in your LUIS Primary key and select OK.

Note

If you do not have a LUIS account, you can get one on the LUIS. If you have a LUIS account but do not know how to find your LUIS primary key please see the Azure resources for LUIS section of the Authoring and runtime keys article.

Publish LU

Any time you select Start Bot (or Restart Bot), Composer will evaluate if your LU content has changed. If so Composer will automatically make the required updates to your LUIS applications then train and publish them. If you go to your LUIS app website, you will find the newly published LU model.

References

Next