Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

microsoft teams : escaping underscores in text posting to webhook

I am posting a list of Azure resource groups to a channel in teams using incoming webhook.

Some Azure resource groups have underscores in them, these are getting parsed and the text between two underscores is italicized. From the docs I could gather that it's Markdown behavior but I am unable to escape underscores using a \ (backslash) similar to how you would do in Markdown.

What is the right way to post text with underscores such that its rendered correctly?

(Would be nice to know what variant of Markdown is being used.)

Sample payload:

{
  "text": "<br/><h1>Some text (some azure subscription id)</h1><br/>some text (more text): <br/>['resource_group_name_1', 'resource_group_name_2', 'resourcegroup-rg-foo-bar']<br/><br/>some text (more text): <br/>['resourcegroupname']<br/><br/>See <a href="https://someaccount.visualstudio.com/_git/reponame?path=%2FREADME.md">documentation</a> and <a href="https://someaccount.visualstudio.com/someproject/_build?definitionId=1234&_a=summary">sometext</a>."
}

resourcegroup-rg-foo-bar appears as is, but resource_group_name_1 appears like resourcegroupname1.

like image 217
dparkar Avatar asked Oct 28 '19 21:10

dparkar


People also ask

Does Microsoft Teams support Webhooks?

The webhook is available in the Teams channel. You can create and send actionable messages through Incoming Webhook or Office 365 Connector.

How do I post to a team on Webhook?

To send a message through your Incoming Webhook or Office 365 Connector, post a JSON payload to the webhook URL. This payload must be in the form of an Office 365 connector card. You can also use this JSON to create cards containing rich inputs, such as text entry, multiselect, or selecting date and time.

How do I send a formatted text to a team?

There are several formatting options for messages. beneath the compose box. In this expanded view, select the text you want to format, then choose an option such as B, I, or U to bold, italicize, or underline the text.


1 Answers

Disabling markdown at a section level is now supported in Cards. You can set markdown to false.

Details here

Example

{
    "@type": "MessageCard",
    "@context": "https://schema.org/extensions",
    "summary": "Office 365 Notification",
    "title": "Office 365 Service Degradations",
    "sections": [
        {
            "markdown": false,
            "facts": [
                {
                    "name": "Service Incident:",
                    "value": "ID"
                },
                {
                    "name": "Start time:",
                    "value": "check_disk_critical"
                },
                {
                    "name": "Service:",
                    "value": "SERVICENAME"
                },
                {
                    "name": "Description:",
                    "value": "MESSAGE"
                }
            ],
            "title": "Office 365 Service Problem"
        }
    ]
}
like image 74
shahalpk Avatar answered Sep 22 '22 13:09

shahalpk