Contoso cafe bot is a complete and fairly sophisticated sample that demonstrates various parts of the BotBuilder V4 SDK and BotBuilder CLI tools in action.
This sample relies on prior knowledge/ familiarity with the following tools and services
- LUIS
- QnA Maker
- Ludown CLI tool
- LUIS CLI tool
- QnA Maker CLI tool
- MSBOT CLI tool
- Chatdown CLI tool
- Bot Framework Emulator
Contoso cafe bot is a fairly sophisticated bot sample that uses the following concepts in the BotBuilder V4 SDK and BotBuilder CLI tools -
- Welcoming users
- Using cards to interact with users
- Using suggested actions to solicit user input
- Single and multi-turn conversations with users
- Interruptable, multi-turn conversations
- Support for help and cancel
- FAQ
- Chit-chat conversations
- Routing user input to appropriate dialog
- Handling no-match
- Prompting users for information
- Implementing a custom prompt
- Multi-turn conversations using dialogs
- Implementing custom dialog solution
- Managing user and conversation state
- Using LUIS for Natural Language Processing
- Using QnA Maker for FAQ, chit-chat, getting help and other single-turn conversations
- Using BotBuilder CLI tools to create, configure and manage all required services.
-
Clone the repository
git clone https://github.com/microsoft/botbuilder-samples.git
-
In a terminal,
cd samples/javascript_nodejs/51.cafe-bot
-
Install modules and start the bot
npm i & npm start
Microsoft Bot Framework Emulator is a desktop application that allows bot developers to test and debug their bots on localhost or running remotely through a tunnel.
- Install the Bot Framework Emulator from here
- Launch Bot Framework Emulator
- File -> Open Bot Configuration and navigate to samples/javascript_nodejs/51.cafe-bot/
- Select contoso-cafe-bot.bot
-
Install Node.js
-
In a terminal
-
Install required tools
Ensure you have Node.js version 8.5 or higher
npm i -g msbot chatdown ludown luis-cli qnamaker
- Follow instructions here to create an Azure account. If you already have an account, sign in. Click on all services -> search for 'subscriptions' -> copy the subscription ID you would like to use from the Home > Subscriptions page.
- Follow instructions here to create a LUIS.ai account. If you already have an account, sign in. Click on your name on top right corner of the screen -> settings and grab your authoring key.
- To create and configure required LUIS and QnA Maker services,
- In a terminal,
cd samples/javascript_nodejs/51.cafe-bot
- Run MSbot Clone and pass in your LUIS authoring key and Azure subscription ID. This command will create required services for your bot and update the .bot file.
msbot clone -n <YOUR-BOT-NAME> -f deploymentScripts/msbotClone -l <Bot service location> --luisAuthoringKey <Key from step-2 above> --subscriptionId <Key from step-1 above>
- In a terminal,
Optionally, you can use the LUIS, QnA Maker portals to manually import the models found under cognitiveModels folder of this sample.
- Parse .lu files into LUIS models
> ludown parse toluis --in dialogs/dispatcher/resources/cafeDispatchModel.lu -o cognitiveModels -n cafeDispatchModel.luis --verbose > ludown parse toluis --in dialogs/bookTable/resources/turn-N.lu -o cognitiveModels -n cafeBotBookTableTurnN.luis --verbose > ludown parse toluis --in dialogs/whoAreYou/resources/getUserProfile.lu -o cognitiveModels -n getUserProfile.luis --verbose
- Parse .lu files into QnA Maker KB and QnA Maker alterations file
> ludown parse toqna --in dialogs/dispatcher/resources/cafeFAQ_ChitChat.lu -o cognitiveModels -n cafeFaqChitChat.qna -a --verbose
- Import LUIS applications (Note: You don't need this if you have already run MSBOT clone)
> luis import application --in cognitiveModels/cafeDispatchModel.luis --authoringKey <Your LUIS authoring key> --endpointBasePath https://westus.api.cognitive.microsoft.com/luis/api/v2.0 --msbot | msbot connect luis --stdin > luis import application --in cognitiveModels/cafeBotBookTableTurnN.luis --authoringKey <Your LUIS authoring key> --endpointBasePath https://westus.api.cognitive.microsoft.com/luis/api/v2.0 --msbot | msbot connect luis --stdin > luis import application --in cognitiveModels/getUserProfile.luis --authoringKey <Your LUIS authoring key> --endpointBasePath https://westus.api.cognitive.microsoft.com/luis/api/v2.0 --msbot | msbot connect luis --stdin
- Import QnA Maker KBs (Note: You don't need this if you have already run MSBOT clone)
> qnamaker create kb --in cognitiveModels/cafeFaqChitChat.qna --subscriptionKey <Your QnA Maker subscription key> --msbot | msbot connect qna --stdin
- Rename current LUIS version
> msbot get cafeDispatchModel --secret <Key if your bot file is encrypted> | luis rename version --newVersionId 0.1_old --stdin
- Import a LUIS application version
> msbot get cafeDispatchModel --secret <Key if your bot file is encrypted> | luis import version --stdin --in cognitiveModels/cafeDispatchModel.luis
- Deleting old LUIS application version
> msbot get cafeDispatchModel --secret <Key if your bot file is encrypted> | luis delete version --stdin --versionId 0.1_old
- Training a LUIS model
> msbot get cafeDispatchModel --secret <Key if your bot file is encrypted> | luis train version --wait --stdin
- Publishing a LUIS model
> msbot get cafeDispatchModel --secret <Key if your bot file is encrypted> | luis publish version --stdin
- Replace KB contents
> msbot get cafeFaqChitChat --secret <Key if your bot file is encrypted> | qnamaker replace kb --in cognitiveModels/cafeFaqChitChat.qna --stdin
- Train and publish KB
> msbot get cafeFaqChitChat --secret <Key if your bot file is encrypted> | qnamaker publish kb --stdin
- Replace QnA Maker alterations
> msbot get cafeFaqChitChat --secret <Key if your bot file is encrypted> | qnamaker replace alterations --in cognitiveModels/cafeFaqChitChat.qna_Alterations.json --stdin