0
votes

I enabled multi turn option for my QnA Maker Knowledgebase. I could not have the multi turn options displayed in test in webchat option. I am using qnAService Helper in my local bot framework.

I have the below error. [onTurnError]: StatusCodeError: 401 - {"error":{"code":"Unauthorized","message":"Authorization Failed"}}

I am using the below code from sample: class QnAServiceHelper {

static async queryQnAService(query, qnAcontext) {

    const endpoint = process.env.QnAEndpointHostName;
    const kbId = process.env.QnAKnowledgebaseId;
    const key = process.env.QnAEndpointKey;

    const url =  `${ endpoint }/qnamaker/knowledgebases/${ kbId }/generateAnswer`;


    const headers = {
        "Content-Type": "application/json",
        "Authorization": "EndpointKey " + key
    };

I understood that the url call is returing the error. Can anyone give pointers how to resolve this authorization issue? I tried to bypass the authorization but it still didn't help.

Here is the sample I used: https://github.com/microsoft/BotBuilder-Samples/tree/master/experimental/qnamaker-prompting

1
Do you get a value if you console.log({endpoint, kbId, key})? It looks like you are not using the right Id and/or password.Mick
Hi Mick, Yes I get the respective value that I configured in the .env file.Moses

1 Answers

0
votes

This question actually doesn't have anything to do with the multi-turn aspect.

The 401 error is likely because your .env file isn't quite right. It should look like this:

MicrosoftAppId=<GUID>
MicrosoftAppPassword=<PASSWORD>
QnAEndpointHostName=https://<YOURHOST>.azurewebsites.net
QnAEndpointKey=<GUID>
QnAKnowledgebaseId=<GUID>

You get the QnAMaker values from the QnAMaker GUI under Settings, here:

enter image description here

I made the comments in the image, but it's crucial that:

  • QnAEndpointHostName is formatted https://<yourHost>.azurewebsites.net, includes the https://, and does not include /qnamaker
  • QnAEndpointKey does not include EndpointKey and is only the GUID

If this doesn't fix your issue, let me know and I'll edit the answer.