Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix nodejs dispatch #684

Merged
merged 2 commits into from
Oct 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 42 additions & 4 deletions samples/javascript_nodejs/14.nlp-with-dispatch/README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 "<NAME>" --luisAuthoringKey "<YOUR AUTHORING KEY>" --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 <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.
```
msbot clone services -f deploymentScripts/msbotClone -n <BOT-NAME> -l <Azure-location> --subscriptionId <Azure-subscription-id>
- Inspect Bot configuration file.
- The `msbot clone` command above generates a bot configuration file.
- The name of the bot configuration file is <NAME>.bot, where <NAME> 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 = '<NAME>_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 = '<NAME>_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 = '<NAME>_Weather';
```


**Alternately** you can configure the required services by following the steps below.

Expand Down Expand Up @@ -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
```
Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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?",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,10 @@
{
"pattern": "turn off {Device_PatternAny} in {Room_PatternAny}",
"intent": "HomeAutomation"
},
{
"pattern": "turn off [the] {Device_PatternAny}",
"intent": "HomeAutomation"
}
],
"patternAnyEntities": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down