Search code examples
coffeescriptbotframeworkmicrosoft-teams

MS Teams Bot framework: Mentions break Markdown


Currently working with handling the custom bot framework, and having an issue where there's a mention included with a markdown formatted message.

res.json({
  'type':'message',
  'text': "<at>#{user.name}</at>\n\n#{str.replace(/\n/ig,'\n\n')}",
  'textFormat': 'markdown',
  'entities': [
    {
    'type': 'mention',
    'mentioned': {
      'id': user.id,
      'name': user.name
    },
    'text': "<at>#{user.name}</at>"
    }
  ],
  'replyToId': message.id
})

Yes, it's in coffeescript.

The problem I'm having is that the str variable will have markdown in it as well, but when the entities field is included, the markdown and linebreaks are unformatted.

Edit: Just to add some more info, removing the entities field does allow the message's markdown to work as desired, but then there's no mention. It's a bit of a tradeoff, but would be nice to have both, since there's no documentation saying that they shouldn't co-exist, from what I've found.


Solution

  • I was able to replicate, and I do not believe this is the desired behavior, so I'll file a bug.

    Note that html tags would work if you want to work around the current limitation...