C# 在QnA azure机器人中嵌入链接

C# 在QnA azure机器人中嵌入链接,c#,azure,botframework,C#,Azure,Botframework,我使用Qna模板创建了一个Qna服务,并在azure中注册了一个机器人。我将在自定义客户端应用程序中使用此bot。因此,我创建了一个直连频道,在直连API的帮助下,我能够将我的机器人嵌入mvc客户端 假设,我在知识库中的一个答案中有一个视频链接或简单链接。 有没有办法让我知道ChatResponse中有链接 foreach (Activity message in activities) { // We have Text if (message.Text != null)

我使用Qna模板创建了一个Qna服务,并在azure中注册了一个机器人。我将在自定义客户端应用程序中使用此bot。因此,我创建了一个直连频道,在直连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)
    {

    }
}
foreach(活动中的活动消息)
{
//我们有文本
if(message.Text!=null)
{
//设置文本响应
//到消息文本
objChat.chat响应
+= " "
+message.Text.Replace(“\n\n”和“
”); } //我们有附件 如果(message.Attachments.Count>0) { } }
我试图添加

但在检查消息是否有附件时,计数为零

我在知识库的答案中有一个视频链接或简单链接。有没有办法让我知道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)
    {

    }
}
似乎您希望检测QnA maker服务返回的答案是否包含链接,并在您自己的处理程序中自定义回复消息或处理附件,您可以覆盖默认答案处理程序
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
DefaultMatchHandler
的详细信息,请参阅

我在知识库的答案中有一个视频链接或简单链接。有没有办法让我知道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)
    {

    }
}
似乎您希望检测QnA maker服务返回的答案是否包含链接,并在您自己的处理程序中自定义回复消息或处理附件,您可以覆盖默认答案处理程序
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
DefaultMatchHandler
的详细信息,请参阅。

对于QnAMaker,您的代码提取有点奇怪。你能补充更多细节吗?但在所有情况下,QnAMaker的答案都只是字符串,因此如果你想在里面设置链接,你可以使用markdown(用于在某些通道上直接渲染),或者在向用户发送回复之前在代码中放置你将要处理的特定标志/标记。你的代码提取对于QnAMaker来说有点奇怪。你能补充更多细节吗?但在所有情况下,QnAMaker答案都只是字符串,因此如果您想在其中设置链接,可以使用markdown(用于在某些频道上直接呈现),或者在将回复发送给用户之前,在代码中放置您将处理的特定标志/标记