Up until this point, we have been using a simple regex recognizer to detect user intent. Bot Framework Composer has deep integration with LUIS.
In this tutorial, you learn how to:
[!div class="checklist"]
- Add LUIS into your bot with Composer for Language Understanding
- Completion of the tutorial Incorporating cards and buttons into your bot.
- A working knowledge of the concepts taught in the Language Understanding article.
- LUIS and how to get LUIS authoring key.
-
Click on
WeatherBot
in the left dialog navigation panel, go to the properties panel for this dialog and locate the Recognizer Type option and set it toLUIS
-
To work with LUIS recognizer, you can provide content in the .lu file format that is highly similar to Language Generation format.
With this, intents are denoted using the markdown section notation - e.g.
# intentName
and utterances are provided as a list.Replace the recognizer content with this -
> See https://aka.ms/lu-file-format to learn about supported LU concepts. > Weather intent and its utterances # Weather - get weather - weather - how is the weather > Help intent and its utterances # Help - help - i need help - please help - can you please help > Cancel intent and its utterances # Cancel - cancel - please cancel that - stop that
-
Once you have done this, you need to re-configure the various Intent triggers within that dialog.
-
Click on
weather
trigger in the left navigation. SelectWeather
from the intent drop-down menu in the properties panel on the right side of the Composer.Update the title of the trigger to
Weather
instead of Intent -
Click on
cancel
trigger in the left navigation and chooseCancel
from the intent drop downUpdate the title of the trigger to
Cancel
instead of Intent -
Given we are using LUIS which is a machine learning based intent classifier, we want to avoid low confidence results. To do this,
Set the Condition property to this
#Cancel.Score >= 0.8
This says do not fire the cancel trigger if the confidence score returned by LUIS is lower than or equal to 0.8
-
Click on
help
trigger in the left navigation and chooseHelp
from the intent drop downUpdate the title of the trigger to
Help
instead of IntentSet the
Condition
property to this#Help.Score >= 0.5
This says do not fire the cancel trigger if the confidence score returned by LUIS is lower than or equal to 0.5
-
Click on Restart Bot
Composer has now detected that you have LU information specified and it needs to create/ update corresponding LUIS applications.
For
Authoring key
, click onenvironment
in the top right corner of your screen (this is right above where this documenation content is displayed) and copyLUIS authoring key 1
into the composer window -
Click
Publish
. This should take a minute or two to complete. Composer will render progress at the top right corner of the screen. -
Click on Test in Emulator and talk to the bot.
With LUIS, you no longer have to type in exact regex patterns to trigger specific scenarios for your bot. Try things like:
- "How is the weather"
- "Weather please"
- "Can you help me"
- "Cancel please"
You can use LUIS to recognize entities from what the user says.
As an example, the user could say "How is the weather in 98052?" and instead of prompting the user again for a zipcode, we could just go straight to pulling up weather information if the user had already provided that as part of their initial query.
Let's get this wired up.
-
Step one is to add a regex entity extractor to the LUIS app. To do this, click on
WeatherBot
and on the right side, add the following entity definition at the end of the LU content -> regex zipcode entity. Any time LUIS sees a five digit number, it will flag it as 'zipcode' entity. $ zipcode : /[0-9]{5}/
-
Next, let's configure your
prompt for zipcode
to use the entity if LUIS finds it. To do this, opengetWeather
dialog from the left navigation menu, selectBeginDialog
trigger and scroll to and find the prompt. -
Let's insert an action before the prompt by clicking on +, musing over Manage Properties and selecting Set a property
-
Since the prompt itself is trying to set the zipcode in the
user.zipcode
, let's set that property to the@zipcode
entity.Set Property to
user.zipcode
Set Value to
@zipcode
-
Click on Restart Bot, wait for the LUIS application to be updated (since you added a new entity) and then click on Test in Emulator
Now when you say "how is the weather in 98052" you should see your bot directly provide weather for that location instead of prompting you for zipcode.