在QnA azure bot中嵌入链接

时间:2018-02-10 05:51:57

标签: c# azure botframework

我使用QnaMaker创建了一个Qna服务,并使用QnA模板在azure中注册了一个bot。我将在我的自定义客户端应用程序中使用此bot。所以,我创建了一个Direct Line频道,在Direct Line API的帮助下,我能够将我的机器人嵌入到mvc客户端。

假设我在知识库中的答案之一中有视频链接或简单链接。  有什么方法我可以知道ChatResponse中有链接吗?

foreach (Activity message in activities)
{
    // We have Text
    if (message.Text != null)
    {
        // Set the text response
        // to the message text
        objChat.ChatResponse
            += " "
            + message.Text.Replace("\n\n", "<br />");
    }
    // We have an Attachment
    if (message.Attachments.Count > 0)
    {

    }
}

我尝试添加<attachment contentType="video/mp4" contentUrl="videourl" thumbnailUrl="thumbnailurl"/>

但是在检查邮件是否附件时,计数结果为零。

1 个答案:

答案 0 :(得分:2)

  

我在知识库中的答案之一中有视频链接或简单链接。有什么方法我可以知道ChatResponse中有链接吗?

您似乎想要检测QnA制造商服务返回的答案是否包含链接并自定义回复消息或处理您自己的处理程序中的附件,您可以覆盖默认答案处理程序{{ 1}}实现它。

DefaultMatchHandler

有关如何覆盖public override async Task DefaultMatchHandler(IDialogContext context, string originalQueryText, QnAMakerDialog.Models.QnAMakerResult result) { //you can detect if the answer(s) that QnA maker service return contain the link(s) by using a regex //customize reply messages or handle attachments await context.PostAsync("{your_message_with_attachments}"); context.Done(true); } QnAMakerDialog的详细信息,请参阅this article