2
votes

(Please note that this FAQ bot is created without any coding with the help of Microsoft QnA Maker and then connecting it to Bot Framework).

I created a FAQ bot on Microsoft Bot Framework with the help of its "no-coding-required" QnA Maker and then registered it on Bot Framework. Now I need to insert Message Endpoint for bot to function. But I am not subscribing to Azure Bot Service or any other hosting service to host the bot as of now. I want to run it on my local Windows machine.

I downloaded Bot Framework Emulator and ran node.js http-server command to its folder, tunneled it with ngrok and put the resultant URL followed by /api/messages (like https://xxxxxxxx.ngrok.io/api/messages) for the message endpoint as well as in Botframework Emulator. But it didn't work. Ngrok gives an error as Bot is remote and tunneling is to my local machine, where software too is needed. But I haven't got the bot software code with me as QnA Maker apparently don't provide it for downloading. So what are the options before me to create a working endpoint for my bot?

Hope my query is clear, if not, please ask me to clarify further. TIA!

1

1 Answers

2
votes

How do you want to use your QnA layer?

The QnA Maker page is automatically hosting (for free now but the are looking at the usage) the QnA functionality so you can integrate it in many ways:

  • using a bot
  • but also in a classic Asp.Net app
  • or in many other project types

How?

To use your knowledge base, once you have set it up (and trained), the first step is to publishin https://qnamaker.ai/). You will got this kind of information: enter image description here

Integration in a bot

You can use the QnA template: https://docs.microsoft.com/en-us/bot-framework/azure/azure-bot-service-template-question-and-answer

It will use a dedicated dialog type called QnAMakerDialog available through NuGet / npm:

For C#, the QnAMaker Dialog is distributed via the Microsoft.Bot.Builder.CognitiveServices NuGet package.

For Node.js, the QnAMaker Dialog is distributed via the botbuilder-cognitiveservices npm module.

Here is how you use your parameters from the publish phase: the QnASubscriptionKey and QnAKnowledgebaseId are used in the following sample code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Threading;
using Microsoft.Bot.Connector;
using Microsoft.Bot.Builder.Dialogs;
using Microsoft.Bot.Builder.CognitiveServices.QnAMaker;

[Serializable]
public class BasicQnAMakerDialog : QnAMakerDialog
{        
    //Parameters to QnAMakerService are:
    //Required: subscriptionKey, knowledgebaseId, 
    //Optional: defaultMessage, scoreThreshold[Range 0.0 – 1.0]
    public BasicQnAMakerDialog() : base(new QnAMakerService(new QnAMakerAttribute(Utils.GetAppSetting("QnASubscriptionKey"), Utils.GetAppSetting("QnAKnowledgebaseId"), "No good match in FAQ.", 0.5)))
    {}
}

Directly in another projet

As QnA Maker is publishing your QnA knowledge base as a web API, you can directly use it from code with web calls. Here is the link to the API reference: https://qnamaker.ai/Documentation/ApiReference

If you have a look to the methods provided on the API list you will use Generate answer

API