Language Understanding Intelligent Service (LUIS) is a cloud-based API service to build natural language into apps and bots. Adding LUIS to your bots enables them to understand the users' intents conversationally and contextually so that your bots can decide what to respond to the users. Bot Framework Composer provides tools to train and manage language understanding components and it's easier for developers to add LUIS when they develop bots with Composer. In this article, we will walk you through the steps to use LUIS when you develop your bots with Composer. To further explore how to use LUIS in Bot Composer, you may refer to the ToDoBotWithLuisSample.
- Basic knowledge of language understanding (concept article here)
- Basic knowledge of events and triggers (concept article here)
- LUIS account (apply here)
- LUIS authoring key (how to get here)
To determine user's intent, in Composer you define the Handle an Intent
trigger, and then specify the actions to take when an Intent is recognized (and optionally entities). For more details please read the events and triggers article.
Composer currently supports two types of recognizers: LUIS recognizer (default) and Regular expression recognizer. You can only choose one type of recognizer for each dialog. Besides the recognizer, each dialog may contain a set of language understanding data authored in .lu format.
In this section, we will cover the steps to use LUIS as recognizer in your bot. These steps include the following: set a recognizer type for each dialog, author language understanding tranining data, publish your language understanding (LU) data, and test them in emulator.
In Composer, each dialog can have one type of recognizer and might contain a set of language understanding training data. To add LUIS to your bot, you need to select LUIS as the recognizer type for the specific dialog you want to define. You need to do the following two things:
- On the left side navigation pane, select the dialog you want to set LUIS recognizer.
- On the property editor on the right side, select LUIS as recognizer type.
Compose your language understanding training data in the LU editor. The training data should follow the .lu file format and is ususally composed of two parts: intents and example utterances. You can author as many intents as you want to include in the specific dialog. The following screenshot shows Greeting and CheckWeather intents with the matching utterances.
After you compose the language understanding training data in specific dialog, you need to define a Handle an Intent
trigger to handle the pre-defined intents. The Handle an Intent
trigger is a type of event handler specialized to work with the recognizers. Each Handle an Intent
trigger handles one intent. To define a Handle an Intent
trigger you need to do the following two steps: create a Handle an Intent
trigger and add actions to the Handle an Intent
trigger.
To create a Handle an Intent
trigger please do the following steps:
- select the dialog you want to create the
Handle an Intent
trigger on the left side navigation pane and - click New Trigger.
In the pop-up window, you do the following steps:
- select
Handle an Intent
as the trigger type from the drop-down menu - select the intent you want to handle with this trigger from the drop-down menu
- click Submit.
You need to define a Handle an Intent
trigger for each intent. After the definition, you will see the name of the intent shown in the trigger node as follows:
After you define your trigger and configure it to specific intent, you can add actions to be executed after the trigger is fired. For example, you can send a response message.
To send a response message, please do the following three steps:
- click the " + " sign below the trigger node and
- select Send a response.
- define the response message in the language generation editor in the .lg file format.
The screenshot below shows how to author a response message "This is a Greeting intent!" in the language generation editor.
You can add your desired action to each Handle an Intent
trigger.
When you finish defining all the triggers and language understanding training data, you can publish your language understanding content from Composer to LUIS. To publish the LU content, please do the following steps:
- click Start Bot on the upper right corner of your Composer
- fill in your LUIS authoring key and
- click Publish.
Any time you hit start bot (or restart bot), Composer will evaluate if your LU content has changed. If so Composer will automatically make required updates to your LUIS applications, train and publish them. If you go to your LUIS app website, you will find the newly published LU model.
To test your bot which you just added LUIS to, click the Test in Emulator button on the upper right corner of Composer. When you emulator is running, send in messages indicating different intents to see if they match the pre-defined intents.