【问题标题】:QnAmaker change default answer when QnAmaker does not have any response当 QnAmaker 没有任何响应时,QnAmaker 更改默认答案
【发布时间】:2018-05-09 12:36:19
【问题描述】:

当 QnAmaker 没有任何响应以显示提示对话框时如何更改默认答案。

例如:

用户1:你好
机器人:你好!!
用户 1:你卖汽车吗?
机器人:没有找到合适的匹配!

不是没有找到合适的匹配,机器人应该提出一个可用服务列表。

此外,只要未找到匹配项,机器人应再次提出可用服务列表。

如何实现?

【问题讨论】:

  • 如果您能提供minimal reproducible example,那就太好了。
  • 视情况而定,有几种方法可以做到这一点。这有点取决于您如何设置框架。例如,您是为 QnAmaker bot 使用简单的 azure 服务,还是使用自定义 API 来支持 botframework 等。
  • 你好@Digitalsa1nt,我正在使用简单的天蓝色服务。请在下面找到代码提取。/ ***** 代码提取 ****/public class BasicQnAMakerDialog : QnAMakerDialog { public BasicQnAMakerDialog() : base(new QnAMakerService(new QnAMakerAttribute(Utils.GetAppSetting("QnASubscriptionKey"), Utils.GetAppSetting ("QnAKnowledgebaseId"),"",0.30,8))) {} }
  • 啊,我明白了,如果您在 azure 中使用预构建的,看起来可能是这样,那么您将需要在 azure 中围绕框架编辑一些代码。我会看看我能不能很快找到一个好的例子。

标签: c# botframework azure-language-understanding qnamaker


【解决方案1】:

QnAMakerAttribute 有一个 defaultMessage 参数,允许您自定义“不匹配”响应文本:https://github.com/Microsoft/BotBuilder-CognitiveServices/blob/7866f5a1bc970bdd0be341b9ba24c74067edf57c/CSharp/Library/QnAMaker/QnAMaker/QnAMakerService/QnAMakerAttribute.cs

public class BasicQnAMakerDialog : QnAMakerDialog 
{ 
  public BasicQnAMakerDialog() : base(
         new QnAMakerService(
                new QnAMakerAttribute(
                      Utils.GetAppSetting("QnASubscriptionKey"),
                      Utils.GetAppSetting("QnAKnowledgebaseId"),
                      "**List of services: one, two three**",
                      0.30,
                      8))) {} 
}

还有一个等待合并的拉取请求,它将允许覆盖发送默认消息:https://github.com/Microsoft/BotBuilder-CognitiveServices/pull/87 在此之前,您唯一的选择似乎是在您自己的代码库中复制 QnAMakerDialogQnAMakerDialog source

【讨论】:

  • 您好 Eric,感谢您的回复并提供有关拉取请求的信息。但是,有提示对话框会更好,因为它会提供更好的用户体验。
【解决方案2】:

由于在使用 QnA 制造商和 botframework 的同时有几种不同的方法,因此对于您目前遇到的问题有很多不同的建议,但微软目前没有那么多适当的指导方针。 (至少不是我发现的)

我遇到了针对 QnA 制造商 git 存储库列出的这个问题:found here. 有一些不同的建议,所以我将在下面从最少到最多列出它们。

选项 1:[假设您正在创建一个连接到 QnA maker 的基本对话框类]

public BasicQnAMakerDialog() : base(new QnAMakerService(new QnAMakerAttribute(ConfigurationManager.AppSettings["QnASubscriptionKey"], ConfigurationManager.AppSettings["QnAKnowledgebaseId"], "No good match in FAQ")))

选项 2:[只需查看默认返回的特定字符串并“覆盖”它]

protected override async Task RespondFromQnAMakerResultAsync(IDialogContext context, IMessageActivity message, QnAMakerResults result)
{
    var answer = result.Answers.First().Answer;
    Activity reply = ((Activity)context.Activity).CreateReply();
    if (reply.Text.equals("Not Match Found!))
         reply.Text = "No good match in FAQ";
    await context.PostAsync(reply);
}   

当 QnAMaker 仍处于预览状态时,曾经出现过选项 1 无法按预期工作的情况。选项 2 在我看来不是那么整洁,但它是一个不错的解决方法。

正如 Eric 在他的回答中所说,在他们的 git 存储库中有一个活动的拉取请求等待针对此问题的合并。所以最终这将是一件更容易处理的事情。在那之前,希望以上两个选项会有所帮助。

【讨论】:

  • 您好 DigitalsaInt,已尝试选项 2,但当未找到响应时,bot 似乎未捕获默认消息。仅在匹配时有效。我正在使用 facebook 频道
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-10-05
  • 2018-11-01
相关资源
最近更新 更多