Bots, Web

Microsoft Bot Framework – String to Markdown


What channels you’re using matters! Test out on all your desired platforms before publishing code.

Testing out the limits of the bot framework I tried to create multi-line responses for my bot. The Text property of replies was Markdown, so, I thought it should be easy enough to implement. However, I quickly realized it didn’t always look the way I wanted. Here’s some tips to getting your responses to look just right =).

These examples were all using the

reply = context.MakeMessage();

and implemented the PostAsync method since my responses are all Tasks.

  await context.PostAsync(reply);


Multi-Line Repsonses

You must use \n\n in the string.


reply.Text = "Hi I'm one line \n\n " +
"I'm line two" +
"I'm line three?" ; 

Output Web:

Output Facebook:


In a list you must have the new line syntax \n\n as well as an ‘*’ with a space after it, be careful here since ‘*’ are also used for italicization. You can also see that the spacing is slightly different between the two channels.


reply.Text = "Hi I'm one line \n\n" +
"* Item 1 \n\n" +
"* Item 2 " ; 

Output Web:

Output Facebook:

Block Quote with Horizontal Rule

Quoted Text must have ‘>’ with one space after to denote that the next chunk of text will be a quote. The Horizontal Rule is marked by ‘—‘. We can especially see the limitations between channels even more in this example.


  reply.Text = "Block quote below bar \n\n" +
    "---" +
    "\n\n > Something about life. I'm an existential quote \n\n" + 
    "-BOT ";

Output Web:

Output Facebook:

Headers / Bold, Italics and Strike Throughs

This time – drastic differences between Facebook versus the Web. Note that with headers you must type in \n\n after the header text or the entire string will be part of the first header syntax. And typing ‘ *** ‘ will get bold italics. However Facebook does not register ANY of these.


  reply.Text = "# Don't know if I need new lines \n\n" +
     "~~You **don't** *need* new lines~~ \n\n" +
     "***yes you do***";

Output Web:

Output Facebook:

Links and Pictures in an Ordered List

Some more differences with Facebook and the Web, but less so. Remember to put \n\n after every item in your list and to leave a space after the ‘.’ following the number.


  reply.Text = "### List \n\n" +
     "1. Link: [bing]( \n\n" +
     "2. Image Link: ![duck](";

Output Web:

Output Facebook:

Hope this little guide helps.

Happy Hacking!

– TheNappingKat

Leave a Comment

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