diff --git a/.env.example b/.env.example index c24c3be..5b2ad34 100644 --- a/.env.example +++ b/.env.example @@ -12,7 +12,7 @@ LUIS_SUBSCRIPTION_KEY= # application will be used by your bot. This setting is ignored when using the included # UI (where you manually choose which application to edit.) To obtain the ID of an # application, open the application in the UI, click on "Settings", and look for -# the field "App ID". +# the field "CONVERSATION_LEARNER_MODEL_ID". CONVERSATION_LEARNER_MODEL_ID= # Optionally Configure UI port to avoid conflicts with other locally running services diff --git a/README.md b/README.md index e008aec..b8965ae 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ Project Conversation Learner consists of an SDK you add to your bot, and a cloud 1. Install and build: - ```bash + ```bash git clone https://github.com/Microsoft/ConversationLearner-Samples my-bot-01 cd my-bot-01 npm install @@ -54,6 +54,7 @@ Project Conversation Learner consists of an SDK you add to your bot, and a cloud Create a file called `.env` in the directory `my-bot-01`. The contents of the file should be: ``` + NODE_ENV=development LUIS_AUTHORING_KEY= ``` @@ -116,7 +117,7 @@ Source files for the demos are in `my-bot-01/src/demos` 4. Rebuild and re-start bot: - ```bash + ```bash npm run build npm start ``` @@ -152,8 +153,8 @@ Ensure that these variables are set when deploying your bot: Environment variable | Setting --- | --- CONVERSATION_LEARNER_SERVICE_URI | https://westus.api.cognitive.microsoft.com/conversationlearner/v1.0/ -CONVERSATION_LEARNER_MODEL_ID | Application Id GUID, obtained from the Conversation Learner UI under the "settings" for the app -LUIS_AUTHORING_KEY | LUIS authoring key for this app. Obtained from https://www.luis.ai +CONVERSATION_LEARNER_MODEL_ID | Model Id GUID, obtained from the Conversation Learner UI under the "settings" for the app +LUIS_AUTHORING_KEY | LUIS authoring key for this app. Obtained from https://www.luis.ai MICROSOFT_APP_ID | Microsoft Application Id MICROSOFT_APP_PASSWORD | Microsoft Application Password diff --git a/package-lock.json b/package-lock.json index cae48bf..a5e7ad1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -30,9 +30,9 @@ "integrity": "sha512-cIlHwmkoraF48vRHkyHa9JB4QiLQwSDk1EFzoMFBnQSM7ueY6ZFFRuYSYjlKLKxO4TXfLDaaumHT9Te5T0iveA==" }, "@conversationlearner/sdk": { - "version": "0.274.10", - "resolved": "https://registry.npmjs.org/@conversationlearner/sdk/-/sdk-0.274.10.tgz", - "integrity": "sha512-jrwdo9beITwwc0rkP9DGMVn/c5VjK9zHogWP7CT/E9GBaaujsNhqlgmVAeym9rJMbeZO+RPfX4g2ATmDDAbVRw==", + "version": "0.274.12", + "resolved": "https://registry.npmjs.org/@conversationlearner/sdk/-/sdk-0.274.12.tgz", + "integrity": "sha512-797zohbJDK6LXTo/hnfojRj22PmXVMBFRN+v0L7l1fTAO0uUV3nrjfSN9UuSg4gqomS7T2kGtvk4JacWJtvCNg==", "requires": { "@conversationlearner/models": "0.170.1", "@conversationlearner/ui": "0.295.13", @@ -503,7 +503,7 @@ }, "async": { "version": "1.5.2", - "resolved": "http://registry.npmjs.org/async/-/async-1.5.2.tgz", + "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=" }, "async-each": { @@ -2026,7 +2026,7 @@ }, "express": { "version": "4.16.3", - "resolved": "http://registry.npmjs.org/express/-/express-4.16.3.tgz", + "resolved": "https://registry.npmjs.org/express/-/express-4.16.3.tgz", "integrity": "sha1-avilAjUNsyRuzEvs9rWjTSL37VM=", "requires": { "accepts": "~1.3.5", @@ -2371,12 +2371,14 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -2391,17 +2393,20 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -2518,7 +2523,8 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -2530,6 +2536,7 @@ "version": "1.0.0", "bundled": true, "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -2544,6 +2551,7 @@ "version": "3.0.4", "bundled": true, "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -2551,12 +2559,14 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.2.4", "bundled": true, "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -2575,6 +2585,7 @@ "version": "0.5.1", "bundled": true, "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -2662,7 +2673,8 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -2674,6 +2686,7 @@ "version": "1.4.0", "bundled": true, "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -2795,6 +2808,7 @@ "version": "1.0.2", "bundled": true, "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", diff --git a/package.json b/package.json index e784921..8ab4c38 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "author": "Microsoft Conversation Learner Team", "license": "MIT", "dependencies": { - "@conversationlearner/sdk": "0.274.10", + "@conversationlearner/sdk": "0.274.12", "botbuilder": "4.0.0-preview1.2", "convict": "^4.0.2", "dotenv": "^4.0.0", diff --git a/src/demos/tutorialEntityDetectionCallback.ts b/src/demos/tutorialEntityDetectionCallback.ts index 44a9c88..d86749d 100644 --- a/src/demos/tutorialEntityDetectionCallback.ts +++ b/src/demos/tutorialEntityDetectionCallback.ts @@ -76,7 +76,6 @@ var resolveCity = function(cityFromUser: string) { * @returns {Promise} */ cl.EntityDetectionCallback(async (text: string, memoryManager: ClientMemoryManager): Promise => { - // Clear memoryManager.ForgetEntity("CityUnknown"); diff --git a/src/demos/tutorialHybrid.ts b/src/demos/tutorialHybrid.ts index f968ac4..298e43a 100644 --- a/src/demos/tutorialHybrid.ts +++ b/src/demos/tutorialHybrid.ts @@ -78,10 +78,9 @@ let state: any = null * @param {BB.TurnContext} context Allows retrieval of Bot State * @param {ClientMemoryManager} memoryManager Allows for viewing and manipulating Bot's memory * @param {string | undefined} data Value set in End_Session Action in UI -* @returns {Promise} List of Entity values to preserve after session End +* @returns {Promise} List of Entity values to preserve after session End */ -cl.OnSessionEndCallback(async (context: BB.TurnContext, memoryManager: ClientMemoryManager, sessionEndState: SessionEndState, data: string | undefined): Promise => { - +cl.OnSessionEndCallback(async (context: BB.TurnContext, memoryManager: ClientMemoryManager, sessionEndState: SessionEndState, data: string | undefined) => { let state = convoState.get(context) if (!state) throw("Bot State no Initialized!") @@ -103,7 +102,6 @@ cl.OnSessionEndCallback(async (context: BB.TurnContext, memoryManager: ClientMem // 3) Return list of Entities to save for the next time ConversationLearner is started // (see tutorialSessionCallback for an example) } - return }) // All transfer of state between the global Bot’s state and Conversation Learner diff --git a/src/demos/tutorialSessionCallbacks.ts b/src/demos/tutorialSessionCallbacks.ts index f1a9263..319296e 100644 --- a/src/demos/tutorialSessionCallbacks.ts +++ b/src/demos/tutorialSessionCallbacks.ts @@ -6,7 +6,7 @@ import * as path from 'path' import * as express from 'express' import * as BB from 'botbuilder' import { BotFrameworkAdapter } from 'botbuilder' -import { ConversationLearner, ClientMemoryManager, SessionEndState, FileStorage } from '@conversationlearner/sdk' +import { ConversationLearner, ClientMemoryManager, FileStorage } from '@conversationlearner/sdk' import config from '../config' import startDol from '../dol' @@ -59,27 +59,26 @@ let cl = new ConversationLearner(modelId); * @param {ClientMemoryManager} memoryManager Allows for viewing and manipulating Bot's memory * @returns {Promise} */ -cl.OnSessionStartCallback(async (context: BB.TurnContext, memoryManager: ClientMemoryManager): Promise => { - +cl.OnSessionStartCallback(async (context: BB.TurnContext, memoryManager: ClientMemoryManager) => { // Set BotName when session starts memoryManager.RememberEntity("BotName", "Botty") }) /** -* Called when Session ends. -* If not implemented all entity values will be cleared -* If implemented, developer can copy entites from Prev to preserve them for the next session -* as well as store them in the Bot State -* @param {BB.TurnContext} context Allows retrieval of Bot State -* @param {ClientMemoryManager} memoryManager Allows for viewing and manipulating Bot's memory -* @param {string | undefined} data Value set in End_Session Action in UI -* @returns {Promise} List of Entity values to preserve after session End -*/ -cl.OnSessionEndCallback(async (context: BB.TurnContext, memoryManager: ClientMemoryManager, sessionEndState: SessionEndState, data: string | undefined): Promise => { - + * Called when Session ends. + * If not implemented all entity values will be cleared. + * If implemented, developer return a list of entities to preserve for the next session + * as well as store them in the Bot State + * @param {BB.TurnContext} context Allows retrieval of Bot State + * @param {ClientMemoryManager} memoryManager Allows for viewing and manipulating Bot's memory + * @param {SessionEndState} sessionEndState Indicates whether END_SESSION was called on the running Session + * @param {string | undefined} data Value set in End_Session Action in UI + * @returns {Promise} List of Entity values to preserve after session End + */ +cl.OnSessionEndCallback(async (context, memoryManager, sessionEndState, data) => { // 1) Do something with returned "data" defined in EndSession action // It could, for example, specify things such as: Was the task - // was successfully completed? Is there a need to escale to a human? + // was successfully completed? Is there a need to escalate to a human? // 2) Extract values from ConversationLearner memoryManager and store in BotState // using context object (see tutorialHybrid for an example)