Search code examples
node.jsbotframeworkmicrosoft-graph-apimicrosoft-teams

Send Proactive Adaptive Card Message to MS Teams Channel


I have been trying to send proactive adaptive message card with buttons to a channel in MS TEAMS, but I am not able to find any solution to this.

Any solution in REST API (https://smba.trafficmanager.net) or BotBuilder SDK for nodejs is appreciated.

Something like this


Solution

  • Based on recommendation from Hilton , I could figure out this

    You could design your own adaptive card here: Adaptive Card Design and edit attachments.body as per your requirement.

    sending a proactive message

    METHOD: POST URL: https://smba.trafficmanager.net/{api}/v3/conversations/{channelId}/activities

    sending reply as bot

    METHOD: POST URL: https://smba.trafficmanager.net/{api}/v3/conversations/{channelId};messageid={messageid}/activities

    {   
        "type": "message",
        "attachments": [
            {
           "contentType": "application/vnd.microsoft.card.adaptive",
           "content": {
            "type": "AdaptiveCard",
            "version": "1.0",
            "body": [
                {
                    "type": "TextBlock",
                    "size": "Medium",
                    "weight": "Bolder",
                    "text": "text"
                },
                {
                    "type": "TextBlock",
                    "size": "small",
                    "text": "text",
                    "wrap": true
                },
             ],
            "actions": [
                {
                    "type": "Action.Submit",
                    "title": "Accept",
                    "data": {
                        "accept": true
                    }
                },
                {
                    "type": "Action.Submit",
                     "id": "id",
                      "title": "title",
                      "data": {
                        "msteams": {
                          "type": "task/fetch",
                        }
                      }
                }]
            }
            }
        ]
    }