This repo contains sample code for building task-oriented conversational bots using Project Conversation Learner, and demonstrating how to use the @conversationlearner/sdk
npm module.
Project Conversation Learner enables you to build and teach task-oriented conversational interfaces that learn from example interactions, combining code, logical constraints and machine learning. Certain absolute parts of your application such as checking if the user is logged in or making an API request to check store inventory can still be coded; however, other changes in state and action selection can be learned from example dialogs given by the domain expert or developer.
This README explains how to get started; full documentation is availble here.
An invitation is required to access Project Conversation Learner.
Project Conversation Learner consists of an SDK you add to your bot, and a cloud service which the SDK accesses for machine learning. At present, access to the Project Conversation Leaner cloud service requires an invitation. If you haven't been invited already, request an invitation. If you have not received an invitation, you will be unable to access the cloud API.
-
An invitation to access the Project Conversation Learner cloud service -- request an invitation.
-
Node 8.5.0 or higher and npm 5.3.0 or higher. Install from https://nodejs.org/en/
-
LUIS authoring key:
-
Log into http://www.luis.ai
-
Click on your name in the upper right, then on "settings"
-
Authoring key is shown on the resulting page
(Your LUIS authoring key serves 2 roles. First, it will serve as your Conversation Learner authoring key. Second, Conversation Learner uses LUIS for entity extraction; the LUIS authoring key is used to create LUIS models on your behalf)
-
-
Google Chrome web browser. Install from https://www.google.com/chrome/index.html.
-
git. Install from https://git-scm.com/downloads.
-
VSCode. Install from https://code.visualstudio.com/. Note this is recommended, not required.
-
Install and build:
git clone https://github.com/Microsoft/ConversationLearner-Samples my-bot-01 cd my-bot-01 npm install npm run build
Note: during
npm install
, you can ignore this error if it occurs:gyp ERR! stack Error: Can't find Python executable
-
Configure:
Create a file called
.env
in the directorymy-bot-01
. The contents of the file should be:LUIS_AUTHORING_KEY=<your LUIS authoring key>
-
Start bot:
npm start
This runs the generic empty bot in
my-bot-01/src/app.ts
. -
Run Conversation Learner UI:
[open second command prompt window] cd my-bot-01 npm run ui
-
Open browser to http://localhost:5050
You're now using Conversation Learner and can create and teach a Conversation Learner model.
The instructions above started the generic empty bot. To run a tutorial or demo bot instead:
-
If you have the Conversation Learner web UI open, return to the list of apps at http://localhost:5050/home.
-
If another bot is running (like
npm start
ornpm run demo-pizza
), stop it. You do not need to stop the UI process, or close the web browser. -
Run a demo bot from the command line (step 2 above). Demos include:
npm run tutorial-general
npm run tutorial-entity-detection
npm run tutorial-session-callbacks
npm run tutorial-api-calls
npm run demo-password
npm run demo-pizza
npm run demo-storage
npm run demo-vrapp
-
If you're not already, switch to the Conversation Learner web UI in Chrome by loading http://localhost:5050/home.
-
Click on "Import tutorials" (only needs to be done once). This will take about a minute and will copy the Conversation Learner models for all the tutorials into your Conversation Learner account.
-
Click on the demo model in the Conversation Learner UI that corresponds to the demo you started.
Source files for the demos are in my-bot-01/src/demos
-
If you have the Converstaion Learner web UI open, return to the list of apps at http://localhost:5050/home.
-
If a bot is running (like
npm run demo-pizza
), stop it. You do not need to stop the UI process, or close the web browser. -
If desired, edit code in
blis-bot-01/src/app.ts
. -
Rebuild and re-start bot:
npm run build npm start
-
If you're not already, switch to the Converstaion Learner web UI in Chrome by loading http://localhost:5050/home.
-
Create a new Converstaion Learner application in the UI, and start teaching.
-
To make code changes in
blis-bot-01/src/app.ts
, repeat the steps above, starting from step 2.
In VSCode, there are run configurations for each demo, and for the "Empty bot" in my-bot-01/src/app.ts
. Open the my-bot-01
folder in VSCode.
There is a template .env.example
file shows what environment variables you may set to configure the samples.
You can adjust these ports to avoid conflicts between other services running on your machine by adding a .env
file to root of project:
cp .env.example .env
This uses the standard configuration, which lets you run your bot locally, and start using Conversation Learner. (Later on, to deploy your bot to the Bot Framework, some edits to this file will be needed.)
Publish your Conversation Learner bot similar to the same way you would publish any other bot. At a high level, you upload your code to a hosted website, set the appropriate configuration values, and then register the bot with various channels. The docs include detailed instructions on deploying to localhost, and deploying to Azure.
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_APP_ID | Application Id GUID, obtained from the Converstaion 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 |
Once the bot is deployed and running you can connect different channels to it such as Facebook, Teams, Skype etc using an Azure Bot Channel Registration. For documentation on that process see: https://docs.microsoft.com/en-us/bot-framework/bot-service-quickstart-registration
- Tag questions on Stack Overflow with "microsoft cognitive"
- Request a feature on our User Voice page
- Open an issue on our github repo
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.