Getting 'couldn't send retry' error in web chat for questions which are not present in knowledge base

徘徊边缘 提交于 2019-12-02 15:12:16

问题


I created a bot with Azure in C#. This bot is working fine for question which are present in my knowledge base. But when I try different question, it gives error couldn't send retry below that question and reply to that question as Sorry, my bot code is having an issue. It should reply No match found instead of Sorry, my bot code is having an issue. One more issue is this bot sometimes gives random answer form KB for some questions which are not present in Kb instead of No answer found in KB.

In web chat channel, it shows following issue - There was an error sending this message to your bot: HTTP status code InternalServerError. Any help will be appreciated.


回答1:


First of all, regarding that tutorial:

This article uses Bot Framework v3 SDK. Please see this Bot Framework article, if you are interested in Bot Framework v4 SDK version of this information.

It's old and uses V3 of the Bot Framework SDK. I highly, highly recommend building any new bots in V4. Use the Add natural language understanding tutorial instead.


InternalServerError indicates that there's a problem with your bot code, somewhere.

Here's a few things you can try that are likely causing the issue:

Write code that deals with No Answer

The official QnAMaker Sample does that here:

// Query QnAMaker for Answer
var response = await qnaMaker.GetAnswersAsync(turnContext);
// If we have an answer, send it to the user
if (response != null && response.Length > 0)
{
    await turnContext.SendActivityAsync(MessageFactory.Text(response[0].Answer), cancellationToken);
}
// If we don't have an answer, tell that to the user
else
{
    await turnContext.SendActivityAsync(MessageFactory.Text("No QnA Maker answers were found."), cancellationToken);
}

Ensure your QnAMaker Service has a DefaultAnswer

This is likely only an issue if you set up your bot to get a default non-answer from your QnAMaker Service.

In Azure Portal > Resource Group > QnA App Service > Configuration (note: this is NOT your bot's app service; this one is specific to QnAMaker), ensure DefaultAnswer is set:

Debug

Assuming that your bot is actually breaking only when and because no QnA Answers were found, those two things should be the only thing you need to troubleshoot. Otherwise, here's how to debug a bot:

Visual Studio/C#:

  1. In Visual Studio, run your bot by pressing F5 or clicking:

  1. Open your bot in Emulator

  2. In Visual Studio, go to Debug > Windows > Exception Settings:

  1. In the Exception Settings window, full-check "Common Language Runtime Exceptions"

  1. In Emulator, do the thing that makes your bot break. The bot should automatically stop when there's an error. Here, I've forced one:

As you can see, it says System.IndexOutOfRangeException: 'Index was outside the bounds of the array.' This means that my array, response doesn't have a 0th element because no answers were returned.

Other issues will show other errors. You can usually pinpoint issues fairly easily by reading the error details and doing a web search for the error code if you need additional details.

VS Code

  1. In VS Code, run your bot by pressing F5 and selecting 'Node.js' (for Node/TypeScript bots) or .NET Core (for C# bots):

  1. Open your bot in Emulator

  2. In VS Code, open the Debug menu:

  1. Under "BREAKPOINTS", check "All Exceptions" (Note: It's important to run your bot before checking this box because there are normal exceptions that occur when the bot starts up):

  1. In Emulator, do the thing that makes your bot break. The bot should automatically stop when there's an error. Here, I've forced one:

As you can see, it says Exception has occurred: TypeError TypeError: Cannot read property 'answer' of undefined This means that qnaResults[0] is undefined, or doesn't exist, which indicates that no answers were returned.

Other issues will show other errors. You can usually pinpoint issues fairly easily by reading the error details and doing a web search for the error code if you need additional details.



来源:https://stackoverflow.com/questions/56630914/getting-couldnt-send-retry-error-in-web-chat-for-questions-which-are-not-pres

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!