简体   繁体   English

使用 MessageCard 通过 MS Teams 中的传入 webhook @提及

[英]@mention via incoming webhook in MS Teams using MessageCard

I have a onestep in Cherwell that based on a criteria triggers a webservice and sends a MessageCard over to a Channel in MS Teams.我在 Cherwell 有一个基于条件触发 Web 服务并将 MessageCard 发送到 MS Teams 中的通道的步骤。 I cannot find a way to trigger an @mention when the message lands in the channel.当消息进入频道时,我找不到触发@提及的方法。 With the current WFH all the technicians are in Teams and no so much on email so a Cherwell notification email may go unread for a while.在当前的 WFH 中,所有技术人员都在 Teams 中,email 上没有那么多,因此 Cherwell 通知 email 可能有一段时间未读 go。 If the @mention was a thing then we have a more dynamic response to some of these incidents that we need someone to jump on when they come into the system Thanks.如果@提及是一件事,那么我们对其中一些事件有更动态的响应,当他们进入系统时,我们需要有人跳上去谢谢。

As of 21/09/2021 , this is now supported. 自 21/09/2021 起,现在支持此功能。 Copying from the documentation :文档中复制:

User mention in Incoming Webhook with Adaptive Cards Incoming webhooks start to support user mention in Adaptive Cards with the AAD Object ID and UPN.带有自适应卡片的传入 Webhook 中的用户提及传入 webhook 开始支持具有 AAD Object ID 和 UPN 的自适应卡片中的用户提及。

Note笔记

Enable user mention in the schema for Incoming webhooks to support AAD Object ID and UPN.在传入 webhook 的架构中启用用户提及以支持 AAD Object ID 和 UPN。 UI/UX changes are not required for user mentions with AAD Object ID and UPN.使用 AAD Object ID 和 UPN 的用户提及不需要 UI/UX 更改。 The activity feed notification for Incoming Webhook with user mention will be available in the future release.带有用户提及的传入 Webhook 的活动源通知将在未来版本中提供。

Example for user mention in Incoming Webhook as follows:传入 Webhook 中的用户提及示例如下:

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

Following image illustrates user mention in Incoming Webhook:下图说明了传入 Webhook 中的用户提及:

传入 Webhook 中的用户提及

For completeness, this is the code I used to test the above:为了完整起见,这是我用来测试上述内容的代码:

HttpResponseMessage response = await new HttpClient().PostAsync("https://XXXXXXX.webhook.office.com/webhookb2/XXXXXXXXXXX/IncomingWebhook/XXXXX/XXXXXXXXXXX",
    new StringContent(cardWithMentionsAsJsonString, Encoding.UTF8, "application/json"));

Note that even though they currently say " The activity feed notification for Incoming Webhook with user mention will be available in the future release. ", it already works.请注意,即使他们目前说“带有用户提及的传入 Webhook 的活动提要通知将在未来的版本中可用。 ”,它已经工作了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM