将主动自适应卡片消息发送到 MS Teams 频道
Send Proactive Adaptive Card Message to MS Teams Channel
我一直在尝试将带有按钮的主动自适应消息卡发送到 MS TEAMS 中的频道,但我找不到任何解决方案。
REST API (https://smba.trafficmanager.net) 或 BotBuilder SDK for nodejs 中的任何解决方案都值得赞赏。
关于这个有很多文档,比如 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:
在一个非常简短的总结中 - 如您所说(botbuilder 的其余 api),有两种发送消息的选项,但您也可以考虑 webhooks 或 Graph API。如果你选择前两个之一(rest api 或 botbuilder),那么你需要有目的地的某些信息(群聊、1-1 或团队频道),比如租户 ID、对话 ID , 服务 url, 等等。例如,您之前需要保存该信息,例如当您的机器人被添加到对话中时(使用 conversationUpdate 事件)。
根据希尔顿的推荐,我想出了这个
您可以在此处设计自己的自适应卡:Adaptive Card Design 并根据您的要求编辑 attachments.body
。
发送主动消息
方法:POST
URL: https://smba.trafficmanager.net/{api}/v3/conversations/{channelId}/activities
作为机器人发送回复
方法: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",
}
}
}]
}
}
]
}
我一直在尝试将带有按钮的主动自适应消息卡发送到 MS TEAMS 中的频道,但我找不到任何解决方案。
REST API (https://smba.trafficmanager.net) 或 BotBuilder SDK for nodejs 中的任何解决方案都值得赞赏。
关于这个有很多文档,比如 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:
在一个非常简短的总结中 - 如您所说(botbuilder 的其余 api),有两种发送消息的选项,但您也可以考虑 webhooks 或 Graph API。如果你选择前两个之一(rest api 或 botbuilder),那么你需要有目的地的某些信息(群聊、1-1 或团队频道),比如租户 ID、对话 ID , 服务 url, 等等。例如,您之前需要保存该信息,例如当您的机器人被添加到对话中时(使用 conversationUpdate 事件)。
根据希尔顿的推荐,我想出了这个
您可以在此处设计自己的自适应卡:Adaptive Card Design 并根据您的要求编辑 attachments.body
。
发送主动消息
方法:POST
URL: https://smba.trafficmanager.net/{api}/v3/conversations/{channelId}/activities
作为机器人发送回复
方法: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",
}
}
}]
}
}
]
}