diff --git a/samples/javascript_nodejs/14.nlp-with-dispatch/README.MD b/samples/javascript_nodejs/14.nlp-with-dispatch/README.MD index 3af8959ac0..43ffa3bc60 100644 --- a/samples/javascript_nodejs/14.nlp-with-dispatch/README.MD +++ b/samples/javascript_nodejs/14.nlp-with-dispatch/README.MD @@ -34,6 +34,7 @@ Use the Dispatch model in cases when: ```bash npm start ``` + # Configure services This sample relies on [LUIS](https://luis.ai), [QnA Maker](https://qnamaker.ai) and [Dispatch](https://github.com/microsoft/botbuilder-tools//tree/master/packages/Dispatch) services. @@ -51,11 +52,45 @@ Ensure you have [Node.js](https://nodejs.org/) version 8.5 or higher npm i -g msbot chatdown ludown qnamaker luis-apis botdispatch luisgen ``` -To clone this bot, run +To clone this bot, perform the following: +- Collect your Luis Authoring Key from the the [LUIS portal](https://www.luis.ai) by selecting your name in the top right corner. Save this key for the next step. + +- Run the following command from the project directory: +```bash +msbot clone services --name "" --luisAuthoringKey "" --folder "DeploymentScripts/MsbotClone" --location "ie, 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 in for the emulator and configuration. +```bash +The secret used to decrypt .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. ``` -msbot clone services -f deploymentScripts/msbotClone -n -l --subscriptionId +- 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. +- The configuration file can be loaded by the [Microsoft Bot Framework Emulator](https://aka.ms/botframeworkemulator). + +- Update `bot.js` +Update the following line to add a prefix with the name of your bot (plus underscore '_'). +```dotnet +const DISPATCH_CONFIG = '_nlp-with-dispatchDispatch'; ``` -Note: You can also manually import the LUIS and QnA Maker applications via the [LUIS.ai](https://luis.ai) and [QnAMaker.ai](https://qnamaker.ai) portals. See instructions [here](https://docs.microsoft.com/en-us/azure/cognitive-services/luis/what-is-luis) to import the LUIS models and [here](https://docs.microsoft.com/en-us/azure/cognitive-services/qnamaker/quickstarts/create-publish-knowledge-base) to import the QnA Maker knowledge base. All models this sample relies on is [here](./cognitiveModels). + + - Update `homeAutomation.js` +Update the following line to add a prefix with the name of your bot (plus underscore '_'). + ```dotnet + const LUIS_CONFIGURATION = '_Home Automation'; + ``` + - Update `weather.js` + Update the following line to add a prefix with the name of your bot (plus underscore '_'). + ```dotnet + const WEATHER_LUIS_CONFIGURATION = '_Weather'; + ``` + **Alternately** you can configure the required services by following the steps below. @@ -87,7 +122,7 @@ You need to train and publish the LUIS models that were created for this sample ```bash > msbot get "Home Automation" | luis train version --wait --stdin -> msbot get "Weather" | luis train version --stdin --wait +> msbot get "Weather" | luis train version --wait --stdin > msbot get "Home Automation" | luis publish version --stdin > msbot get "Weather" | luis publish version --stdin ``` @@ -122,6 +157,9 @@ To create a new dispatch model for these services and update the .bot file confi ```bash > dispatch create -b nlp-with-dispatch.bot | msbot connect dispatch --stdin ``` + +Then go into your bot file and for the `"dispatch"`-type service with the name `"nlp-with-dispatchDispatch"`, add a `"subscriptionKey"` with your preferred LUIS Key. You can use the `"subscriptionKey"` that's found under the `"luis"`-type services. + ## Securing keys in your .bot file Since your .bot file contains service IDs, subscription and authoring keys, its best to encrypt them. To encrypt the .bot file, you can run diff --git a/samples/javascript_nodejs/14.nlp-with-dispatch/cognitiveModels/dispatch.qna b/samples/javascript_nodejs/14.nlp-with-dispatch/cognitiveModels/dispatch.qna index 9e124d5a7f..2a4f9f4f8a 100644 --- a/samples/javascript_nodejs/14.nlp-with-dispatch/cognitiveModels/dispatch.qna +++ b/samples/javascript_nodejs/14.nlp-with-dispatch/cognitiveModels/dispatch.qna @@ -15,7 +15,7 @@ }, { "id": 0, - "answer": "I am the LUIS-QnAMaker Dispatch bot! This sample demonstrates using several LUIS applications and QnA Maker knowledge base using dispatch.\r\n", + "answer": "I am the LUIS-QnAMaker Dispatch bot! This sample demonstrates using multiple LUIS applications and QnA Maker knowledge bases using dispatch.\r\n", "source": "custom editorial", "questions": [ "What are you?", diff --git a/samples/javascript_nodejs/14.nlp-with-dispatch/cognitiveModels/homeAutomation.luis b/samples/javascript_nodejs/14.nlp-with-dispatch/cognitiveModels/homeAutomation.luis index eb9a634529..1ccd3634fe 100644 --- a/samples/javascript_nodejs/14.nlp-with-dispatch/cognitiveModels/homeAutomation.luis +++ b/samples/javascript_nodejs/14.nlp-with-dispatch/cognitiveModels/homeAutomation.luis @@ -575,6 +575,10 @@ { "pattern": "turn off {Device_PatternAny} in {Room_PatternAny}", "intent": "HomeAutomation" + }, + { + "pattern": "turn off [the] {Device_PatternAny}", + "intent": "HomeAutomation" } ], "patternAnyEntities": [ diff --git a/samples/javascript_nodejs/14.nlp-with-dispatch/resources/homeautomation.lu b/samples/javascript_nodejs/14.nlp-with-dispatch/resources/homeautomation.lu index 4b1fcfc796..8c3ef4ad4c 100644 --- a/samples/javascript_nodejs/14.nlp-with-dispatch/resources/homeautomation.lu +++ b/samples/javascript_nodejs/14.nlp-with-dispatch/resources/homeautomation.lu @@ -47,7 +47,6 @@ - {Device_PatternAny} off [please] - turn off {Device_PatternAny} in {Room_PatternAny} - turn off [the] {Device_PatternAny} -- turn on {Device_PatternAny} in {Room_PatternAny} ## None