Skip to content

Latest commit

 

History

History
 
 

This sample shows how to integrate QnA Maker in a simple bot with ASP.Net Core 2.

Concepts introduced in this sample

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.

To try this sample

  • Clone the samples repository
git clone https://github.com/Microsoft/botbuilder-samples.git
  • [Optional] Update the appsettings.json file under botbuilder-samples/samples/csharp_dotnetcore/11.qnamaker with your botFileSecret. For Azure Bot Service bots, you can find the botFileSecret under application settings.

Prerequisites

  • Follow instructions here to create a QnA Maker service.
  • Follow instructions here to import the sample.qna to your newly created QnA Maker service.
  • Update BotConfiguration.bot with your kbid (KnowledgeBase Id) and endpointKey in the "qna" services section. You can find this information under "Settings" tab for your QnA Maker Knowledge Base at QnAMaker.ai
  • (Optional) Follow instructions here to set up the QnA Maker CLI to deploy the model.

Visual Studio

  • Navigate to the samples folder (botbuilder-samples/samples/csharp_dotnetcore/11.qnamaker) and open QnABot.csproj in Visual Studio .
  • Hit F5

Visual Studio Code

  • Open botbuilder-samples/samples/csharp_dotnetcore/11.qnamaker sample folder.
  • Bring up a terminal, navigate to botbuilder-samples/samples/csharp_dotnetcore/11.qnamaker folder.
  • Type 'dotnet run'.

Update packages

  • In Visual Studio right click on the solution and select "Restore NuGet Packages". Note: this sample requires Microsoft.Bot.Builder, Microsoft.Bot.Builder.AI.QnA and Microsoft.Bot.Builder.Integration.AspNet.Core.

Testing the bot using Bot Framework Emulator

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.

Connect to bot using Bot Framework Emulator V4

  • Launch the Bot Framework Emulator
  • File -> Open bot and navigate to botbuilder-samples/samples/csharp_dotnetcore/11.qnamaker folder.
  • Select the BotConfiguration.bot file.

Further reading