Bot Framework v4 natural language processing with LUIS bot sample
This bot has been created using Microsoft Bot Framework, it shows how to use LUIS, a Natural Language Understanding service to implement language understanding in a bot. The bot will use LUIS to extract language intents from a user's message.
This samples requires prerequisites in order to run.
-
Clone the repository
git clone https://github.com/Microsoft/botbuilder-samples.git
-
In a console, navigate to
samples/javascript_nodejs/12.nlp-with-luiscd samples/javascript_nodejs/12.nlp-with-luis -
Install modules
npm install
-
Setup LUIS
Assuming prerequisites have been installed:
# log into Azure az login# set you Azure subscription az account set --subscription "<azure-subscription>"
# Create the LUIS service application msbot clone services --name "<your_bot_name>" --luisAuthoringKey <LUIS-authoring-key> --code-dir "." --location westus --sdkLanguage "Node" --folder deploymentScripts/msbotClone --verbose
-
Start the bot
npm start
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 version 4.2.0 or greater from here
- Launch Bot Framework Emulator
- File -> Open Bot Configuration
- Navigate to
samples/javascript_nodejs/12.nlp-with-luisfolder - Select
nlp-with-luis.botfile
Language Understanding service (LUIS) allows your application to understand what a person wants in their own words. LUIS uses machine learning to allow developers to build applications that can receive user input in natural language and extract meaning from it.
- Install the
ludownCLI tool here to help describe language understanding components for your bot. - Install the
luisCLI tool here to create and manage your LUIS applications.
After creating the bot and testing it locally, you can deploy it to Azure to make it accessible from anywhere. To deploy your bot to Azure:
# login to Azure
az loginAs you make changes to your locally running bot, you can deploy those changes to Azure Bot Service using a publish helper. See publish.cmd if you are on Windows or ./publish if you are on a non-Windows platform. The following is an example of publishing local changes to Azure:
# build the TypeScript bot before you publish
npm run build# run the publish helper (non-Windows) to update Azure Bot Service. Use publish.cmd if running on Windows
./publishTo learn more about deploying a bot to Azure, see Deploy your bot to Azure for a complete list of deployment instructions.
This sample uses a language model to train LUIS. The source for the language model can be found in the cognitiveModels\reminders.lu. The .lu (language understanding) file describes language understanding components for your bot. .lu files are text files and can be modified to change what language your bot will understand. The ludown CLI tool takes as input a .lu file and produces a .json file. This .json file is then used as input to the luis CLI tool to train your LUIS application's language understanding model.
If you modify reminders.lu you need to train and publish the LUIS model. You can do so using the ludown and luis CLI tools.
```bash
# install the ludown CLI tool
npm install -g ludown
```
```bash
# install the LUIS CLI tool
npm install -g luis-apis
```
To learn more about the ludown CLI tool, refer to the documentation found here.
To learn more about the luis CLI tool, refer to the documentation found here.
The following examples will train and publish a LUIS model:
msbot get "Reminders" | luis train version --wait --stdin
msbot get "Reminders" | luis publish version --stdin