Ste*_*nls 6 json microsoft-teams
我在 Cherwell 中有一个步骤,它根据条件触发 Web 服务并将 MessageCard 发送到 MS Teams 中的通道。当消息到达频道时,我找不到触发@提及的方法。在当前的 WFH 中,所有技术人员都在 Teams 中,并且没有太多电子邮件,因此 Cherwell 通知电子邮件可能会在一段时间内无人阅读。如果@提及是一件事,那么我们对其中一些事件会有更动态的响应,我们需要有人在他们进入系统时介入,谢谢。
截至 2021 年 9 月 21 日,Microsoft 已提供有关如何支持此功能的文档。但是,Teams 尚未(2021 年 10 月)触发实际通知,请参见下文。
从文档复制:
使用自适应卡在传入 Webhook 中提及用户传入 Webhook 开始支持使用 AAD 对象 ID 和 UPN 在自适应卡中提及用户。
笔记
在传入 webhook 的架构中启用用户提及以支持 AAD 对象 ID 和 UPN。使用 AAD 对象 ID 和 UPN 提及的用户不需要进行 UI/UX 更改。带有用户提及的传入 Webhook 的活动源通知将在未来版本中提供。
传入 Webhook 中用户提及的示例如下:
JSON
{
"type": "message",
"attachments": [
{
"contentType": "application/vnd.microsoft.card.adaptive",
"content": {
"type": "AdaptiveCard",
"body": [
{
"type": "TextBlock",
"size": "Medium",
"weight": "Bolder",
"text": "Sample Adaptive Card with User Mention"
},
{
"type": "TextBlock",
"text": "Hi <at>Adele UPN</at>, <at>Adele AAD</at>"
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.0",
"msteams": {
"entities": [
{
"type": "mention",
"text": "<at>Adele UPN</at>",
"mentioned": {
"id": "AdeleV@contoso.onmicrosoft.com",
"name": "Adele Vance"
}
},
{
"type": "mention",
"text": "<at>Adele AAD</at>",
"mentioned": {
"id": "87d349ed-44d7-43e1-9a83-5f2406dee5bd",
"name": "Adele Vance"
}
}
]
}
}
}]
}
Run Code Online (Sandbox Code Playgroud)
下图说明了传入 Webhook 中的用户提及:
为了完整起见,这是我用来测试上述内容的代码:
HttpResponseMessage response = await new HttpClient().PostAsync("https://XXXXXXX.webhook.office.com/webhookb2/XXXXXXXXXXX/IncomingWebhook/XXXXX/XXXXXXXXXXX",
new StringContent(cardWithMentionsAsJsonString, Encoding.UTF8, "application/json"));
Run Code Online (Sandbox Code Playgroud)