This sample shows how to integrate QnA Maker in a simple bot with ASP.Net Core 2.
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 as input.
- Clone the samples repository
git clone https://github.com/Microsoft/botbuilder-samples.git
- [Optional] Update the
appsettings.json
file underbotbuilder-samples/samples/csharp_dotnetcore/11.qnamaker
with your botFileSecret. For Azure Bot Service bots, you can find the botFileSecret under application settings.
- Follow instructions here to create a QnA Maker service.
- Follow instructions here to import the smartLightFAQ.tsv to your newly created QnA Maker service.
- Update qnamaker.bot with your kbid (KnowledgeBase Id), hostname, and endpointKey in the "qna" services section. You can find this
information under "Settings" tab for your QnA Maker Knowledge Base at QnAMaker.ai
- If you changed the
name
property of theqna
service in your.bot
file, be sure to updateQnAMakerKey
inQnABot.cs
- If you changed the
- (Optional) Follow instructions here to set up the QnA Maker CLI to deploy the model.
- Navigate to the samples folder (
botbuilder-samples/samples/csharp_dotnetcore/11.qnamaker
) and open QnABot.csproj in Visual Studio . - Run the project (press
F5
key)
- Install the .NET Core CLI tools.
- Using the command line, navigate to
botbuilder-samples/samples/csharp_dotnetcore/11.qnamaker
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 the Bot Framework Emulator
- File -> Open bot and navigate to
botbuilder-samples/samples/csharp_dotnetcore/11.qnamaker
folder. - Select the
qnamaker.bot
file.
After creating the bot and testing it locally, you can deploy it to Azure to make it accessible from anywhere. To learn how, see Deploy your bot to Azure for a complete set of deployment instructions.
Note: If you already created a QnA Knowledgebase, running msbot clone services ...
will create an additional one. You can deal with this in two different ways:
-
Remove the entry with
"type": "qna"
fromDeploymentScripts/MsbotClone
. You'll then need to update your.bot
file with the QnA settings from your previous QnA Knowledgebse and run theaz publish ...
command produced at the end of running themsbot clone services ...
command. -
Delete the original QnA Knowledgebase and resources you created earlier. Ensure that you re-import any
.tsv
files, as needed.