'How is Activity.Text encoded Microsoft Teams?

I am writing a custom Teams bot. I got some questions about Activity.Text field:

  • How is it encoded? I see some <at> tags when the bot is @mentioned, but I also see some &#39;. Can I use HttpUtility.HtmlDecodeto decode it?
  • Is there any document about the details of the Activity.Text field? The schema says it is

Text of the message that is sent from user to bot or bot to user. See the channel's documentation for limits imposed upon the contents of this property.

But it does not talk about the details about the field.



Solution 1:[1]

Nothing special about Activity.Text in Teams except for the tags. In general, depending on the Activity.TextFormat, the message you send might contain markdown or XML, but in general the message you receive from a user will be plain text.

Anything additional, like if the user sends bold text to your bot, can be extracted from the attachments object in the incoming payload, e.g. :

"attachments": [
    {
        "contentType": "text/html",
        "content": "<div><span itemscope=\"\" itemtype=\"http://schema.skype.com/Mention\" itemid=\"0\">Teams TestBot</span> |echo| <strong><strong>Hi</strong></strong>???????</div>"
    }
]

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dharman