3
votes

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

2

2 Answers

4
votes

There is a bunch of documentation around this, like here and here and here, so make sure you've read those, and there are several relevant samples to look at like this one and this one. There are also lots of questions relating to this here on Stack Overflow - here's an example question, specifically dealing with node: Sending proactive messages to a channel in Teams

In a very quick summary - there are two options to sending the messages, as you've said (rest api of botbuilder), but you can also consider webhooks or Graph API. If you go with one of the first two (rest api or botbuilder), then you need to have certain information for the destination (group chat, 1-1, or team channel), like the tenant id, conversation id, service url, and so on. You need to have saved that information before, like when your bot was added to the conversation (using the conversationUpdate event), as an example.

3
votes

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",
                    }
                  }
            }]
        }
        }
    ]
}