Bot Framework v4 QnA Maker bot sample
This bot has been created using Microsoft Bot Framework, it shows how to create a bot that uses the QnA Maker Cognitive AI service.
The QnA Maker Service enables you to build, train and publish a simple question and answer bot based on FAQ URLs, structured documents or editorial content in minutes. In this sample, we demonstrate how to use the QnA Maker service to answer questions based on a FAQ text file used as input.
This samples requires prerequisites in order to run.
-
Clone the repository
git clone https://github.com/microsoft/botbuilder-samples.git
-
In a terminal, navigate to
samples/javascript_nodejs/11.qnamaker
cd samples/javascript_nodejs/11.qnamaker
-
Install modules
npm install
-
Setup QnA Maker Knowledgebase
Assuming prerequisites have been installed:
# log into Azure az login
# set you Azure subscription az account set --subscription "<azure-subscription>"
# Create QnA Maker service application msbot clone services --name "<your_bot_name>" --code-dir "." --location westus --sdkLanguage "Node" --folder deploymentScripts/msbotClone --verbose
-
Start the bot
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 version 4.2.0 or greater from here
- Launch Bot Framework Emulator
- File -> Open Bot Configuration
- Navigate to
samples/javascript_nodejs/11.qnamaker
folder - Select
qnamaker.bot
file
QnA Maker enables you to power a question and answer service from your semi-structured content.
One of the basic requirements in writing your own bot is to seed it with questions and answers. In many cases, the questions and answers already exist in content like FAQ URLs/documents, product manuals, etc. With QnA Maker, users can query your application in a natural, conversational manner. QnA Maker uses machine learning to extract relevant question-answer pairs from your content. It also uses powerful matching and ranking algorithms to provide the best possible match between the user query and the questions.
After creating the bot and testing it locally, you can deploy it to Azure to make it accessible from anywhere. To deploy your bot to Azure:
# login to Azure
az login
As you make changes to your locally running bot, you can deploy those changes to Azure Bot Service using a publish helper. See publish.cmd
if you are on Windows or ./publish
if you are on a non-Windows platform. The following is an example of publishing local changes to Azure:
# build the TypeScript bot before you publish
npm run build
# run the publish helper (non-Windows) to update Azure Bot Service. Use publish.cmd if running on Windows
./publish
To learn more about deploying a bot to Azure, see Deploy your bot to Azure for a complete list of deployment instructions.