Bot Framework v4 NLP with LUIS bot sample
This sample shows how to create a bot that uses Language Understanding (LUIS).
Language Understanding (LUIS) is a cloud-based API service that applies custom machine-learning intelligence to a user's conversational, natural language text to predict overall meaning, and pull out relevant, detailed information.
In this sample, we demonstrate how to call LUIS to extract the intents from a user's message.
-
[Node.js][4] version 8.5 or higher
# determine node version node --version -
LUIS service application
-
Navigate to LUIS portal.
-
Click the
Sign inbutton. -
Click on
My Apps. -
Click on the
Import new appbutton. -
Click on the
Choose Fileand select reminders.json from theBotBuilder-Samples/javascript_nodejs/12.nlp-with-luis/cognitiveModelsfolder. -
Provide a name for the LUIS app
-
Click on the
Trainbutton. To train your language model. -
Click on the
Publishbutton. To publish your trained language model. -
Update nlp-with-luis.bot file with your AppId, SubscriptionKey, Region and Version. You can find this information under "Keys and Endpoint" tab for your LUIS application at LUIS portal. For example, for https://westus.settingsapi.cognitive.microsoft.com/luis/v2.0/apps/{LuisAppID}?subscription-key={LuisSubscriptionKey}&verbose=true&timezoneOffset=0&q=
The Version is listed on the page. Note: Enter either the "authoringKey" OR "subscriptionKey", not both. See an example .bot service configuration for using LUIS here.
-
Update index.js and set the
LUIS_CONFIGURATIONvalue to match thenamefield in your service declaration. -
Update nlp-with-luis.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 may take some time to go live.
-
Your .bot file should now include an item in the services array that looks like this:
{ "type":"luis", "name":"<some name>", "appId":"<an app id>", "version":"<a version number>", "authoringKey":"<your authoring key>", "subscriptionKey":"<your subscription key>", "region":"<region>", "id":"<some number>" }
-
- Clone the repository
git clone https://github.com/Microsoft/botbuilder-samples.git
- In a console, navigate to s
amples/javascript_nodejs/12.nlp-with-luiscd samples/javascript_nodejs/12.nlp-with-luis - Install modules
npm install
- 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 from here
- Launch Bot Framework Emulator
- File -> Open Bot Configuration and 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.
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 luisgenTo clone this bot, run
msbot clone services -f deploymentScripts/msbotClone -n <BOT-NAME> -l <Azure-location> --subscriptionId <Azure-subscription-id> --appId <YOUR APP ID> --appSecret <YOUR APP SECRET PASSWORD>
NOTE: You can obtain your appId and appSecret at the Microsoft's Application Registration Portal