Search code examples
c#botframeworkdirect-line-botframeworkazure-qna-maker

MS bot | QnAmaker- how to Display the answers in ordered /bulleted format


I'm using QnAMaker in the back end for my chat bot, which is running in direct line bot channel. I want to display some answers in bulleted / numbered format.

I tried some methods mentioned in some websites including this one.

like this

"Hi, Below is my list\n\n"+ "* Item 1\n\n"+ "* Item 2\n\n"+ "Item 1 ");

but nothing worked for me,
enter image description here

Also, I want to know if its possible to display table of data / or any HTML data as bot's reply.

If someone has any solution for this issue, please let me know


Solution

  • Seems you are trying to format your text in Azure Bot Framework. After having look on your code, I got to know, you are almost there, but approach was not correct.

    You could try following way

    Unordered list :

    await turnContext.SendActivityAsync(MessageFactory.Text("Hi, Below is my unordered list  " + Environment.NewLine+ " 1. Item 1\r2. **Bold Item 2**\r3. **" + YourDynamicObject + "**"), cancellationToken);
    

    Ordered list :

    await turnContext.SendActivityAsync(MessageFactory.Text("Hi, Below is my ordered list " + Environment.NewLine+ " - Item 1\r- **Bold Item 2**\r- [Hyperlink](https://stackoverflow.com/users/9663070/md-farid-uddin-kiron) 3"), cancellationToken);
    

    See the screen shot below:

    enter image description here

    How Would You Do It:

    I have already given you code example above, additionally keep in mind the space between the syntax for example when you would make hyperlink you have to follow it's structure like [title](URL) but if you put space after title angle bracket [] it won't work as expected, also for bold Bold it shouldn't contain any space before and after. Same things happened with your code.

    Another issue is new line you could use \n\n even Environment.NewLine

    I want to know if its possible to display table of data / or any HTML data as bot's reply?

    The answer is NO unfortunately you cannot display table data on bot at this moment. But it support few HTML Tag hope you got your answer.

    If you would like to know more about Azure Bot Card Formatting you could refer official document

    Hope it would help and feel free to ask when you would encounter any question in mind.