Adding rich attachments to your QnAMaker bot responses

Recently I released a dialog, available via NuGet, called the QnAMaker dialog. This dialog allows you to integrate with the QnA Maker service from Microsoft, part of the Cognitive Services suite, which allows you to quickly build, train and publish a question and answer bot service based on FAQ URLs or structured lists of questions and answers.

Today I am releasing an update to this dialog which allows you to add rich attachments to your QnAMaker responses to be served up by your bot.  For example, you might want to provide the user with a useful video to go along with an FAQ answer.Right now the QnAMaker service only allows text based responses, so here is what you need to do to get going with rich attachments.

The first thing to do is to add attachment markup to your QnAMaker responses. An example markup snippet is below and you can alter this to return whatever type of attachment you wish, as long as it is supported by the Bot Framework and the channel you are targeting.


<attachment contentType=”video/mp4″ contentUrl=”″ name=”Video name” thumbnailUrl=”” />


Below is a screenshot of one of my services showing an answer with an attachment.



Next, you need to update to or install the latest version of the QnAMakerDialog via NuGet – you can read my original blog post which tells you how to setup and use the dialog.

If you are not using custom score handlers or overriding the DefaultMatchHandler then there should be nothing else to do. The dialog will now see the attachment markup in your answers, strip it out and send the appropriate attachment along with the answer 🙂

However, if you want to handle attachments in your own handlers you can use the helper method ProcessResultAndCreateMessageActivity which will generate a message activity with the answer and attachments ready to post back to the user. At this point you can override the answer text if you wish on the message activity, as shown below where I am overriding the DefaultMatchHandler.



That’s it! You should now be able to return rich attachments with the QnAMakerDialog! Reach out and let me know if you need any help implementing this or if you have any other great ideas for enhancements.


11 thoughts to “Adding rich attachments to your QnAMaker bot responses”

      1. I did not suceed to make it work with Teams. I used an image however not a video but I guess it should work two. Could be an error in what I wrote though, I will check.

  1. I need to suggest user some actions from my QnAMaker knowledge base. Please suggest as how we can achieve this? Basically, if user sends “horse”, and my bot does not returns proper result, I should be able to filter out the questions from my knowledge base and list some of them as SuggestedActions, so that user can directly tap on the Action, and my bot service should return results based on that action. Please suggest.

    1. You can use the NoMatchHandler and return whatever message to the user you wish, that should be a good approach for you I think.

  2. Hi Gary, is it possible to alter the chat window title within the bot code? Rather than the default “Chat” that comes with the qnamaker bot template?

    1. I’m afraid that I focus on C#, so haven’t implemented this for Node. You can easily call the service directly using Node and then parse your responses yourself to get what you are looking for though.

    1. Hi! I have just released a C# library which does just that. Take a look over at and it is also available as a NuGet package too.

Leave a Reply

Your email address will not be published. Required fields are marked *