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 samples repository
git clone https://github.com/Microsoft/botbuilder-samples.git
- Navigate to the samples folder (
botbuilder-samples/samples/csharp_dotnetcore/51.cafe-bot
) and openCafeBot.csproj
in Visual Studio. - Press F5.
- Open
botbuilder-samples/samples/csharp_dotnetcore/51.cafe-bot
sample folder. - Bring up a terminal, navigate to
botbuilder-samples/samples/csharp_dotnetcore/51.cafe-bot
folder. - Type 'dotnet run'.
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
botbuilder-samples/samples/csharp_dotnetcore/51.cafe-bot
- Select CafeBot.bot
- Install Node.js
- In a terminal
- Install required tools
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 Powershell prompt,
cd BotBuilder-Samples\samples\csharp_dotnetcore\51.cafe-bot
- To login, run:
Connect-AzureRmAccount
- To select your Azure subscription, run:
Select-AzureRmSubscription -Subscription "<YOUR SUBSCRIPTION>"
az account set --subscription "<YOUR SUBSCRIPTION>"
- 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 --name <YOUR-BOT-NAME> --folder DeploymentScripts/msbotClone --location <Bot service location, ie "westus"> --luisAuthoringKey <YOUR LUIS AUTHORING KEY>
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 --out cafeDispatchModel.luis > ludown parse toluis --in Dialogs/BookTable/Resources/turn-N.lu -o cognitiveModels -n cafeBotBookTableTurnNModel --out cafeBotBookTableTurnN.luis > ludown parse toluis --in Dialogs/WhoAreYou/Resources/getUserProfile.lu -o cognitiveModels -n getUserProfile --out getUserProfile.luis
- 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 --out cafeFaqChitChat.qna -a ```
-
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> --region <LUIS-Authoring-Region> --msbot | msbot connect luis --stdin > luis import application --in CognitiveModels/cafeBotBookTableTurnN.luis --authoringKey <Your LUIS authoring key> --region <LUIS-Authoring-Region> --msbot | msbot connect luis --stdin > luis import application --in CgnitiveModels/getUserProfile.luis --authoringKey <Your LUIS authoring key> --region <LUIS-Authoring-Region> --msbot | msbot connect luis --stdin
Note: LUIS authoring region can be one of westus or westeurope or australiaeast
-
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
Note: See here for instructions on setting up a Cognitive Service API account and fetching your QnA Maker subscription Key.
- Training a LUIS model
> msbot get cafeDispatchModel | luis train version --wait --stdin > msbot get cafeBotBookTableTurnNModel | luis train version --wait --stdin > msbot get getUserProfile | luis train version --wait --stdin
- Publishing a LUIS model
> msbot get cafeDispatchModel | luis publish version --stdin > msbot get cafeBotBookTableTurnNModel | luis publish version --stdin > msbot get getUserProfile | luis publish version --stdin
- Train and publish KB
> msbot get cafeFaqChitChat | qnamaker publish kb --stdin
- Replace QnA Maker alterations
> msbot get cafeFaqChitChat | qnamaker replace alterations --in CognitiveModels/cafeFaqChitChat.qna_Alterations.json --stdin
- Rename current LUIS version
> msbot get cafeDispatchModel | luis rename version --newVersionId 0.1_old --stdin
- Import a LUIS application version
> msbot get cafeDispatchModel | luis import version --stdin --in CognitiveModels/cafeDispatchModel.luis
- Deleting old LUIS application version
> msbot get cafeDispatchModel | luis delete version --stdin --versionId 0.1_old
- Replace KB contents
> msbot get cafeFaqChitChat | qnamaker replace kb --in CognitiveModels/cafeFaqChitChat.qna --stdin