Skip to content

Latest commit

 

History

History
 
 

This sample shows how to create a bot that uses QnA Maker. This bot example uses restify and dotenv.

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 repository
    git clone https://github.com/microsoft/botbuilder-samples.git
  • In a terminal, navigate to samples/javascript_typescript/11.qnamaker
    cd samples/javascript_typescript/11.qnamaker
  • Install modules and start the bot
    npm i & npm start

Prerequisite

Install TypeScript

In order to run this sample, you must have TypeScript installed. To install TypeScript:

  • Navigate to the TypeScript portal.
  • Click the Download button.
  • Follow the installation instructions for your development environment.

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 Bot Framework Emulator
  • File -> Open Bot Configuration and navigate to samples/javascript_typescript/11.qnamaker folder
  • Select qnamaker.bot file

Prerequisites

  • 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 QnAMaker-Host, QnAMaker-KnowledgeBaseId and QnAMaker-EndpointKey. 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.

QnA Maker service

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 service 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.

Deploy this bot to Azure

You can use the MSBot Bot Builder CLI tool to clone and configure any services this sample depends on.

To install all Bot Builder tools -

Ensure you have Node.js version 8.5 or higher

npm i -g msbot chatdown ludown qnamaker luis-apis botdispatch luisgen

To clone this bot, run

msbot clone services -f deploymentScripts/msbotClone -n <BOT-NAME> -l <Azure-location> --subscriptionId <Azure-subscription-id>

Further reading