我一直试图将带有按钮的主动式自适应消息卡发送到MS TEAMS中的某个频道,但是我找不到任何解决方案。
赞赏使用任何针对Node.js的REST API(https://smba.trafficmanager.net)或BotBuilder SDK中的解决方案。
[这周围有很多文档,例如here和here和here,因此请确保您已阅读它们,并且有几个相关的示例需要查看,例如this one和this one 。堆栈溢出中还有许多与此相关的问题-这是一个示例问题,专门处理节点:Sending proactive messages to a channel in Teams
简要总结-正如您所说的(有botbuilder的api),有两种发送消息的选项,但是您也可以考虑使用webhooks或Graph API。如果您使用的是前两个(REST API或botbuilder)之一,那么您需要具有目的地的某些信息(群聊,1-1或团队频道),例如租户ID,对话ID,服务网址,等等。例如,您需要先保存该信息,例如,当您的机器人被添加到对话中时(使用sessionUpdate事件)。
根据希尔顿的建议,我可以弄清楚这一点
您可以在此处设计自己的自适应卡:Adaptive Card Design,然后根据需要编辑attachments.body
。
发送主动消息
方法:POST网址:https://smba.trafficmanager.net/{api}/v3/conversations/{channelId}/activities
以机器人身份发送回复
方法:POST网址: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",
}
}
}]
}
}
]
}