From 0b3825577e34543f6c4f03dc20441f56f921942f Mon Sep 17 00:00:00 2001 From: Ruben Hinojosa Chapel Date: Fri, 28 Feb 2020 19:29:08 +0100 Subject: [PATCH] Little improvements --- javascript_nodejs/README.md | 4 +- javascript_nodejs/package-lock.json | 41 +++++-------------- .../src/dialogs/chitchat/index.js | 4 +- javascript_nodejs/src/dialogs/main/index.js | 8 +++- javascript_nodejs/src/index.js | 4 +- typescript_nodejs/README.md | 4 +- typescript_nodejs/package-lock.json | 41 +++++-------------- .../src/dialogs/chitchat/index.ts | 4 +- typescript_nodejs/src/dialogs/main/index.ts | 8 +++- typescript_nodejs/src/index.ts | 4 +- 10 files changed, 44 insertions(+), 78 deletions(-) diff --git a/javascript_nodejs/README.md b/javascript_nodejs/README.md index 8bcfd08..017e5ac 100644 --- a/javascript_nodejs/README.md +++ b/javascript_nodejs/README.md @@ -41,10 +41,10 @@ "hostname": "https://your-qnamaker-app-name.azurewebsites.net/qnamaker" }, "cosmosDb": { - "serviceEndpoint": "https://your-cosmosdb-account-name.documents.azure.com:443/", + "cosmosDbEndpoint": "https://your-cosmosdb-account-name.documents.azure.com:443/", "authKey": "", "databaseId": "", - "collectionId": "" + "containerId": "" }, "publicResourcesUrl": "http://localhost:3978" } diff --git a/javascript_nodejs/package-lock.json b/javascript_nodejs/package-lock.json index 354d400..1a4175f 100644 --- a/javascript_nodejs/package-lock.json +++ b/javascript_nodejs/package-lock.json @@ -2112,8 +2112,7 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "aproba": { "version": "1.2.0", @@ -2134,14 +2133,12 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -2156,20 +2153,17 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "core-util-is": { "version": "1.0.2", @@ -2286,8 +2280,7 @@ "inherits": { "version": "2.0.4", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "ini": { "version": "1.3.5", @@ -2299,7 +2292,6 @@ "version": "1.0.0", "bundled": true, "dev": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -2314,7 +2306,6 @@ "version": "3.0.4", "bundled": true, "dev": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -2322,14 +2313,12 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "minipass": { "version": "2.9.0", "bundled": true, "dev": true, - "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -2348,7 +2337,6 @@ "version": "0.5.1", "bundled": true, "dev": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -2438,8 +2426,7 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "object-assign": { "version": "4.1.1", @@ -2451,7 +2438,6 @@ "version": "1.4.0", "bundled": true, "dev": true, - "optional": true, "requires": { "wrappy": "1" } @@ -2537,8 +2523,7 @@ "safe-buffer": { "version": "5.1.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "safer-buffer": { "version": "2.1.2", @@ -2574,7 +2559,6 @@ "version": "1.0.2", "bundled": true, "dev": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -2594,7 +2578,6 @@ "version": "3.0.1", "bundled": true, "dev": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -2638,14 +2621,12 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "yallist": { "version": "3.1.1", "bundled": true, - "dev": true, - "optional": true + "dev": true } } }, diff --git a/javascript_nodejs/src/dialogs/chitchat/index.js b/javascript_nodejs/src/dialogs/chitchat/index.js index 96c0b26..9e39240 100644 --- a/javascript_nodejs/src/dialogs/chitchat/index.js +++ b/javascript_nodejs/src/dialogs/chitchat/index.js @@ -67,10 +67,8 @@ class ChitchatDialog extends ComponentDialog { return true; } - // This is a special case that leads to a new dialog, - // so it's not handled as a normal interruption flow. await dc.beginDialog(CancelDialog.name); - return false; + return true; } /** diff --git a/javascript_nodejs/src/dialogs/main/index.js b/javascript_nodejs/src/dialogs/main/index.js index 70e0a69..16bd246 100644 --- a/javascript_nodejs/src/dialogs/main/index.js +++ b/javascript_nodejs/src/dialogs/main/index.js @@ -150,8 +150,12 @@ class MainDialog extends ComponentDialog { if (interrupted) { if (dc.activeDialog) { - // issue a re-prompt on the active dialog - await dc.repromptDialog(); + // issue a re-prompt on the active dialog if it's not Cancel dialog + if (dc.activeDialog.id !== CancelDialog.name) { + await dc.repromptDialog(); + } else { + turnResult = await dc.continueDialog(); + } } // Else: We don't have an active dialog so nothing to continue here. } else { // No interruption. Continue any active dialogs. diff --git a/javascript_nodejs/src/index.js b/javascript_nodejs/src/index.js index 115624d..289aeb7 100644 --- a/javascript_nodejs/src/index.js +++ b/javascript_nodejs/src/index.js @@ -12,7 +12,7 @@ const localizer = require('i18n'); // Import required bot services. See https://aka.ms/bot-services to learn more about the different parts of a bot. const { BotFrameworkAdapter, MemoryStorage, ConversationState, UserState } = require('botbuilder'); const { LuisRecognizer, QnAMaker } = require('botbuilder-ai'); -const { CosmosDbStorage } = require('botbuilder-azure'); +const { CosmosDbPartitionedStorage } = require("botbuilder-azure"); // Avoid uploading sensitive information like appsettings.json file to your source code repository. // .gitignore file contains appsettings.json as an ignored file. @@ -73,7 +73,7 @@ if (NODE_ENV === DEV_ENV) { // is restarted, anything stored in memory will be gone. storage = new MemoryStorage(); } else { - storage = new CosmosDbStorage(appsettings.cosmosDb); + storage = new CosmosDbPartitionedStorage(appsettings.cosmosDb); } conversationState = new ConversationState(storage); diff --git a/typescript_nodejs/README.md b/typescript_nodejs/README.md index 9a50f22..5a203d6 100644 --- a/typescript_nodejs/README.md +++ b/typescript_nodejs/README.md @@ -42,10 +42,10 @@ "hostname": "https://your-qnamaker-app-name.azurewebsites.net/qnamaker" }, "cosmosDb": { - "serviceEndpoint": "https://your-cosmosdb-account-name.documents.azure.com:443/", + "cosmosDbEndpoint": "https://your-cosmosdb-account-name.documents.azure.com:443/", "authKey": "", "databaseId": "", - "collectionId": "" + "containerId": "" }, "publicResourcesUrl": "http://localhost:3978" } diff --git a/typescript_nodejs/package-lock.json b/typescript_nodejs/package-lock.json index 27a743c..4bad4ed 100644 --- a/typescript_nodejs/package-lock.json +++ b/typescript_nodejs/package-lock.json @@ -2248,8 +2248,7 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "aproba": { "version": "1.2.0", @@ -2270,14 +2269,12 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -2292,20 +2289,17 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "core-util-is": { "version": "1.0.2", @@ -2422,8 +2416,7 @@ "inherits": { "version": "2.0.4", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "ini": { "version": "1.3.5", @@ -2435,7 +2428,6 @@ "version": "1.0.0", "bundled": true, "dev": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -2450,7 +2442,6 @@ "version": "3.0.4", "bundled": true, "dev": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -2458,14 +2449,12 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "minipass": { "version": "2.9.0", "bundled": true, "dev": true, - "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -2484,7 +2473,6 @@ "version": "0.5.1", "bundled": true, "dev": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -2574,8 +2562,7 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "object-assign": { "version": "4.1.1", @@ -2587,7 +2574,6 @@ "version": "1.4.0", "bundled": true, "dev": true, - "optional": true, "requires": { "wrappy": "1" } @@ -2673,8 +2659,7 @@ "safe-buffer": { "version": "5.1.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "safer-buffer": { "version": "2.1.2", @@ -2710,7 +2695,6 @@ "version": "1.0.2", "bundled": true, "dev": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -2730,7 +2714,6 @@ "version": "3.0.1", "bundled": true, "dev": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -2774,14 +2757,12 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "yallist": { "version": "3.1.1", "bundled": true, - "dev": true, - "optional": true + "dev": true } } }, diff --git a/typescript_nodejs/src/dialogs/chitchat/index.ts b/typescript_nodejs/src/dialogs/chitchat/index.ts index d8b2273..494cb44 100644 --- a/typescript_nodejs/src/dialogs/chitchat/index.ts +++ b/typescript_nodejs/src/dialogs/chitchat/index.ts @@ -80,10 +80,8 @@ export class ChitchatDialog extends ComponentDialog { return true; } - // This is a special case that leads to a new dialog, - // so it's not handled as a normal interruption flow. await dc.beginDialog(CancelDialog.name); - return false; + return true; } /** diff --git a/typescript_nodejs/src/dialogs/main/index.ts b/typescript_nodejs/src/dialogs/main/index.ts index 7572632..ee7cc4c 100644 --- a/typescript_nodejs/src/dialogs/main/index.ts +++ b/typescript_nodejs/src/dialogs/main/index.ts @@ -160,8 +160,12 @@ export class MainDialog extends ComponentDialog { if (interrupted) { if (dc.activeDialog) { - // issue a re-prompt on the active dialog - await dc.repromptDialog(); + // issue a re-prompt on the active dialog if it's not Cancel dialog + if (dc.activeDialog.id !== CancelDialog.name) { + await dc.repromptDialog(); + } else { + turnResult = await dc.continueDialog(); + } } // Else: We don't have an active dialog so nothing to continue here. } else { // No interruption. Continue any active dialogs. diff --git a/typescript_nodejs/src/index.ts b/typescript_nodejs/src/index.ts index b332781..e9f9cd7 100644 --- a/typescript_nodejs/src/index.ts +++ b/typescript_nodejs/src/index.ts @@ -13,7 +13,7 @@ import { LuisRecognizerDictionary, QnAMakerDictionary } from './dialogs/shared/t // Import required bot services. See https://aka.ms/bot-services to learn more about the different parts of a bot. import { BotFrameworkAdapter, Storage, MemoryStorage, ConversationState, UserState, TurnContext } from 'botbuilder'; import { LuisRecognizer, QnAMaker, QnAMakerOptions } from 'botbuilder-ai'; -import { CosmosDbStorage } from 'botbuilder-azure'; +import { CosmosDbPartitionedStorage } from 'botbuilder-azure'; // Avoid uploading sensitive information like appsettings.json file to your source code repository. // .gitignore file contains appsettings.json as an ignored file. @@ -75,7 +75,7 @@ if (NODE_ENV === DEV_ENV) { // is restarted, anything stored in memory will be gone. storage = new MemoryStorage(); } else { - storage = new CosmosDbStorage(appsettings.cosmosDb); + storage = new CosmosDbPartitionedStorage(appsettings.cosmosDb); } conversationState = new ConversationState(storage);