Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Commit

Permalink
update readme, end session callback, type annotations, and fix typos (#…
Browse files Browse the repository at this point in the history
…247)

* docs: update README

* docs: update sample env

* chore: update sdk

* docs: fix comments

* style: remove unnecessary type annotation
  • Loading branch information
mattmazzola committed Jul 13, 2018
1 parent 7ee1739 commit f766ff4
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .env.example
Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions README.md
Expand Up @@ -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
Expand All @@ -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=<your LUIS authoring key>
```

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

Expand Down
38 changes: 26 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion src/demos/tutorialEntityDetectionCallback.ts
Expand Up @@ -76,7 +76,6 @@ var resolveCity = function(cityFromUser: string) {
* @returns {Promise<void>}
*/
cl.EntityDetectionCallback(async (text: string, memoryManager: ClientMemoryManager): Promise<void> => {

// Clear
memoryManager.ForgetEntity("CityUnknown");

Expand Down
6 changes: 2 additions & 4 deletions src/demos/tutorialHybrid.ts
Expand Up @@ -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<string []| null>} List of Entity values to preserve after session End
* @returns {Promise<string[] | undefined>} List of Entity values to preserve after session End
*/
cl.OnSessionEndCallback(async (context: BB.TurnContext, memoryManager: ClientMemoryManager, sessionEndState: SessionEndState, data: string | undefined): Promise<string[] | undefined> => {

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!")

Expand All @@ -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
Expand Down
29 changes: 14 additions & 15 deletions src/demos/tutorialSessionCallbacks.ts
Expand Up @@ -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'

Expand Down Expand Up @@ -59,27 +59,26 @@ let cl = new ConversationLearner(modelId);
* @param {ClientMemoryManager} memoryManager Allows for viewing and manipulating Bot's memory
* @returns {Promise<void>}
*/
cl.OnSessionStartCallback(async (context: BB.TurnContext, memoryManager: ClientMemoryManager): Promise<void> => {

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<string []| null>} List of Entity values to preserve after session End
*/
cl.OnSessionEndCallback(async (context: BB.TurnContext, memoryManager: ClientMemoryManager, sessionEndState: SessionEndState, data: string | undefined): Promise<string[] | undefined> => {

* 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<string[] | undefined>} 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)
Expand Down

0 comments on commit f766ff4

Please sign in to comment.