LUIS is a machine learning-based service to build natural language applications. Bots can use LUIS to help with language understanding.
Setting up LUIS can be performed in two ways:
- Provision LUIS with MsBot (Preferred method)
- Provision LUIS with the Azure Portal
MsBot is a command line tool that manages Bot Framework projects that use Azure. When setting up LUIS, we demonstrate the MsBot clone
command which takes a .recipe
(json) file and deploys the project to Azure. See MsBot for more details.
-
Install the Azure CLI (if not already installed) here
-
Install the Bot CLI Tools
npm install -g chatdown msbot ludown luis-apis qnamaker botdispatch luisgen
- To login, run:
az login
To find out more information about logging in, see the AZ CLI Login reference
- To select your Azure subscription, run:
az account set --subscription '<azure subscription>'
To find out more information about setting your subscription, see the Azure CLI Subscription Set reference.
-
Collect your Luis Authoring Key from the the LUIS portal by selecting your name in the top right corner of the home page and select
Settings
. Save your key for the next step. -
Run the following command from the project directory:
msbot clone services --noDecorate --name "<bot name>" --luisAuthoringKey "<authoring key>" --folder "<folder to .recipe file>" --location "<Publish location>"
Switch Name | Description | Example |
---|---|---|
name | Name of the bot. An Azure group will be created with this name with all the associated resources. Shorter names are preferred. | "mybot" |
luisAuthoringKey | The authoring key in the LUIS portal. See step 4 above. | xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
folder | The location of where the bot.recipe file is located (Case sensitive). | nodejs: deploymentScripts/msbotClone, ASP.Net: DeploymentScripts/MsbotClone |
location | A supported "Publishing and Querying region" as described here. | westus |
NOTE: By default your LUIS Applications will be deployed to your free starter endpoint. An Azure LUIS service will be deployed along with your bot but you must manually add and publish to it from the luis.ai portal and update your key in the .bot file.
- Note the generated secret generated by MsBot.
- The secret key is used later. The output will look something like the following:
The secret used to decrypt <bot name>.bot is:
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX=
NOTE: This secret is not recoverable and you should store this secret in a secure place according to best security practices.
Your project may be configured to rely on this secret and you should update it as appropriate.
- Inspect Bot configuration file.
- The
msbot clone
command above generates a bot configuration file. - The name of the bot configuration file is .bot, where is the name of your bot used in the
msbot clone
step (Step 5 above). - The configuration file can later used by the Microsoft Bot Framework Emulator.
- (ASP.Net only) Ensure the bot configuration is packaged with your deployment
- For Visual Studio, in your bot project, right click on the generated bot configuration file, click "Properties".
- Ensure "Copy to Output Directory" is set to "Copy always".
- For other editors, edit your bot's
.csproj
file and add the following:
<ItemGroup>
<None Update="*.bot">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
- (ASP.Net only) Update your
appsettings.json
with your .bot file path and .bot file secret.
- Update the
botFilePath
with the name of your generated bot configuration file. - Update the
botFileSecret
with the secret that the msbot tool generated from step 6 above.
{
"botFilePath": "<bot name>.bot",
"botFileSecret": "<bot secret>"
}
- Install the Bot CLI Tools
npm install -g chatdown msbot ludown luis-apis qnamaker botdispatch luisgen
- Convert model files to
.json
format (if necessary) In your project, check theCognitiveModels
directory. If there are only files with the.luis
extension, convert the files to.json
with the following command:
- Navigate to LUIS portal.
-
Click the
Sign in
button. -
Click on
My Apps
. -
Click on the
Import new app
button. -
Click on the
Choose File
and select LUIS-Reminders.json from thebotbuilder-samples\samples\csharp_dotnetcore\23.luis-with-appinsights\CognitiveModels
folder. -
Update BotConfiguration.bot file with your AppId, SubscriptionKey, Region and Version. You can find this information under "Publish" tab for your LUIS application at LUIS portal. For example, for https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/XXXXXXXXXXXXX?subscription-key=YYYYYYYYYYYY&verbose=true&timezoneOffset=0&q=
- AppId = XXXXXXXXXXXXX
- SubscriptionKey = YYYYYYYYYYYY
- Region = westus
The Version is listed on the page.
-
Update BotConfiguration.bot file with your Authoring Key.
You can find this under your user settings at luis.ai. Click on your name in the upper right hand corner of the portal, and click on the "Settings" menu option. NOTE: Once you publish your app on LUIS portal for the first time, it takes some time for the endpoint to become available, about 5 minutes of wait should be sufficient.
- (Optional) Install the LUDown here to help describe language understanding components for your bot.
- Follow instructions here to set up your Application Insights service.
- Note: The Application Insights will automatically update the appsettings.json file.
- Navigate to the samples folder (
botbuilder-samples\samples\csharp_dotnetcore\21.luis-with-appsinsights
) and openLuisBotAppInsights.csproj
in Visual Studio - Hit F5
- Open
botbuilder-samples\samples\csharp_dotnetcore\21.luis-with-appsinsights
sample folder - Bring up a terminal, navigate to
botbuilder-samples\samples\csharp_dotnetcore\21.luis-with-appsinsights
folder. - Type 'dotnet run'.
Microsoft Bot Framework Emulator is a desktop application that allows bot developers to test and debug their bots on localhost or running remotely through a tunnel.
- Install the Bot Framework Emulator from here.
- Launch the Bot Framework Emulator
- File -> Open bot and navigate to
botbuilder-samples\samples\csharp_dotnetcore\21.luis-with-appsinsights
folder. - Select BotConfiguration.bot file.
You can use the MSBot Bot Builder CLI tool to clone and configure any services this sample depends on.
To install all Bot Builder tools -
Ensure you have Node.js version 8.5 or higher
npm i -g msbot chatdown ludown qnamaker luis-apis botdispatch luisgen
To clone this bot, run
msbot clone services -f DeploymentScripts/MsbotClone -n <BOT-NAME> -l <Azure-location, ie westus> --subscriptionId <Azure-subscription-id>