How do I format JSON data to send message in a table format to Microsoft Teams using POSTMAN or PHP cURL

Viewed 3847

I have a webhook for a specific channel of MS Teams. I have to send a message to that channel in the table format. The table will have a header and body. I am able to send a simple text message to MS Teams channel using POSTMAN and PHP cURL.

JSON format should be valid here: https://messagecardplayground.azurewebsites.net

1 Answers

You can use column set in adaptive card to render a table like card

Example: Card Json -

 {
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "type": "AdaptiveCard",
    "version": "1.2",
    "body": [
        {
            "type": "ColumnSet",
            "columns": [
                {
                    "type": "Column",
                    "items": [
                        {
                            "type": "TextBlock",
                            "weight": "Bolder",
                            "text": "TItle1",
                            "separator": true
                        },
                        {
                            "type": "TextBlock",
                            "separator": true,
                            "text": "body1"
                        },
                        {
                            "type": "TextBlock",
                            "separator": true,
                            "text": "body4"
                        }
                    ],
                    "width": "stretch",
                    "style": "accent"
                },
                {
                    "type": "Column",
                    "items": [
                        {
                            "type": "TextBlock",
                            "weight": "Bolder",
                            "text": "title2"
                        },
                        {
                            "type": "TextBlock",
                            "separator": true,
                            "text": "body2"
                        },
                        {
                            "type": "TextBlock",
                            "separator": true,
                            "text": "body5"
                        }
                    ],
                    "width": "stretch",
                    "style": "good"
                },
                {
                    "type": "Column",
                    "items": [
                        {
                            "type": "TextBlock",
                            "weight": "Bolder",
                            "text": "title3"
                        },
                        {
                            "type": "TextBlock",
                            "separator": true,
                            "text": "body3"
                        },
                        {
                            "type": "TextBlock",
                            "separator": true,
                            "text": "body6"
                        }
                    ],
                    "width": "stretch",
                    "style": "warning"
                }
            ]
        }
    ]
}

the card rendered as below:

enter image description here

Related