Search code examples
c#botframeworkazure-qna-maker

QNAMaker GetAnswer API with Custom question answering


I have a chatbot setup with QNAMaker and a custom c# bot to query knowledge base. Bot builder 4.2 package is being used. Below is the typical QNAMaker KB details and this works.

enter image description here

Below is the details in c# bot chatbot.bot file. Details have been added from the above

    {
      "type": "qna",
      "KbId": "13xxx-xxx-xxx-xx",
      "endpointKey": "89xxx-xxxx-xxx",
      "hostname": "https://xxx.azurewebsites.net/qnamaker",
      "id": "117",
      "name": "QnAMaker-en",
      "subscriptionKey": ""
    },

Get answer is called in the bot as shown below. More details here

var response = await _service.GetAnswersAsync(stepContext.Context).ConfigureAwait(false);

The above works, with response always has answer from QNAMaker KB.

Recently i plan to use Custom Question Answering. I have created a Knowledge base with Text analytics. After i published this Knowledge base i see the different key to access. Below is the details

enter image description here

I no longer see the Endpoint key instead i get a Ocp-Apim-Subscription-Key. How do make use of this new KB in existing bot. What change is needed in chatbot.bot file? When i try to use Ocp-Apim-Subscription-Key as Endpoint key in chatbot.bot file the GetAnswer response is always null.

{
      "type": "qna",
      "KbId": "78xxx-xxx-xxx",
      "endpointKey": "8exxxxx",
      "hostname": "https://xxxxxx.cognitiveservices.azure.com/qnamaker/v5.0-preview.2",
      "id": "117",
      "name": "QnAMaker-en",
      "subscriptionKey": "8exxxxx"
    },


Solution

  • The BotFramework SDK does not support the new Custom Questions feature yet. This. A feature request is already filed in github: https://github.com/microsoft/botframework-sdk/issues/6413