botframeworkazure-bot-serviceazure-qna-maker

Bot framework SDK NodeJS and Custom Question Answering: Failed to generate answers: [object Object]


After an upgrade of one of my knowledgebases from QnaMaker to a language resource with custom question answering enable (FKA QnAMaker Managed), my chatbot does not function anymore and returns an error: DialogContextError: Failed to generate answers: [object Object]

My .env has:

QnAKnowledgebaseId=<name of my knowledgebase>
QnAEndpointKey=<the Ocp-Apim-Subscription-Key from the prediction url
QnAEndpointHostName=https://<languageresourcename>.cognitiveservices.azure.com/  (I also tried to add language/ to the url)

QnaMaker initialization:

const { QnAMaker } = require('botbuilder-ai');
        try {
            this.qnaMaker = new QnAMaker({
                knowledgeBaseId: process.env.QnAKnowledgebaseId,
                endpointKey: process.env.QnAEndpointKey,
                host: process.env.QnAEndpointHostName
            });
        } catch (err) {
            console.warn(`QnAMaker Exception: ${ err } Check your QnAMaker configuration in .env`);
        }

And called by:

        const qnaResults = await this.qnaMaker.getAnswers(step.context);

dependencies:

"dependencies": {
        "adaptivecards-templating": "^1.4.0",
        "applicationinsights": "^1.8.10",
        "azure-storage": "^2.10.5",
        "body-parser": "^1.19.0",
        "botbuilder": "^4.15.0",
        "botbuilder-ai": "^4.15.0",
        "botbuilder-azure-blobs": "4.14.1-preview",
        "botbuilder-dialogs": "^4.15.0",
        "botbuilder-lg": "^4.15.0",
        "botframework-config": "^4.11.2",
         ...
}

Using the key, knowledgebaseid and hostname from my old QnAMaker KB works just fine. Struggling to translate the new prediction url into an object for the QnAMaker.

Update The class GenerateAnswerUtils (called by QnaMaker) is expecting the following:

const url = `${endpoint.host}/knowledgebases/${endpoint.knowledgeBaseId}/generateanswer`;

This will not work with a QnaMaker KB migrated to Custom Questions which expects an url like this:

'https://<languageresourcename>.cognitiveservices.azure.com/language/:query-knowledgebases?projectName=<projectname>&api-version=2021-10-01&deploymentName=production'

Not sure if this should be a bugreport or feature request. I will file an issue anyway.


Solution

  • The BotFramework SDK does not support the new Custom Questions feature yet. This was causing the error. A feature request is already filed.