Search code examples
botframeworkazure-qna-maker

Change the answer Layout in QnA maker


May I ask about how to change the layout of QnA Maker when the result is multiple answer? For example change to Carousel Layout with Hero Card? enter image description here

Thank you.


Solution

  • Using the v3 QnAMaker package that you referenced, you should be able to control the type and format of response yourself. Adding however many answers you feel appropriate as attachments and setting the attachment type to Carousel.

    You can override the method that returns the response to the user within the QnAMakerDialog as shown below;

    protected override async Task RespondFromQnAMakerResultAsync(IDialogContext context, IMessageActivity message, QnAMakerResults results)
            {
                if (results.Answers.Count > 0)
                {
                    // build your response here adding card attachment for each answer
                    // and set attachment type to carusel
                    await context.PostAsync(response);
                }
            }