向 MS Teams 频道发送主动自适应卡片消息卡片、自适应、主动、消息

2023-09-06 17:45:41 作者:差点心动

我一直在尝试向 MS TEAMS 中的频道发送带有按钮的主动自适应消息卡,但我找不到任何解决方案.

REST API (

解决方案 EXCEL行高可以自动适应字数吗 怎么设置

根据希尔顿的推荐,我可以解决这个问题

您可以在这里设计自己的自适应卡片:自适应卡片设计并编辑 attachments.body 根据您的要求.

发送主动消息

方法:发布网址:https://smba.trafficmanager.net/{api}/v3/conversations/{channelId}/activities

作为机器人发送回复

方法:发布网址:https://smba.trafficmanager.net/{api}/v3/conversations/{channelId};messageid={messageid}/activities

{类型":消息",附件":[{"contentType": "application/vnd.microsoft.card.adaptive",内容": {"type": "AdaptiveCard",版本":1.0",身体": [{类型":文本块",大小":中",重量":更大胆",文字":文字"},{类型":文本块",尺寸":小",文本":文本",包装":真},],行动":[{"type": "Action.Submit","title": "接受",数据": {接受":真}},{"type": "Action.Submit",身份证":身份证",标题":标题",数据": {msteams":{类型":任务/获取",}}}]}}]}

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.

解决方案

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