0
votes

I have created a Qna service using QnaMaker and registered a bot in azure with QnA template. I will be using this bot in my custom client application. So, I created a Direct Line channel and with the help of Direct Line API, I was able to embed my bot into mvc client.

Suppose, I have a video link or a simple link in one of the answer in knowledge base. Is there any way that I can know that ChatResponse has a link in it?

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)
    {

    }
}

I tried to add <attachment contentType="video/mp4" contentUrl="videourl" thumbnailUrl="thumbnailurl"/>

But on checking if message has attachment, count comes out to be zero.

1
You code extract is a bit strange for something around QnAMaker. Can you add more details? But in all cases, QnAMaker answers are just strings, so if you want to set a link inside you can use markdown (for direct rendering on some channels) or put specific flags/tags that you will handle in your code before sending the reply to the userNicolas R

1 Answers

2
votes

I have a video link or a simple link in one of the answer in knowledge base. Is there any way that I can know that ChatResponse has a link in it?

It seems that you’d like to detect if the answer(s) that QnA maker service return contain the link(s) and customize reply messages or handle attachments in your own handlers, you can override the default answer handler DefaultMatchHandler to achieve it.

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);
}

For detailed information about how to override QnAMakerDialog DefaultMatchHandler, please refer to this article.