首页 > 解决方案 > Microsoft Teams 上自适应卡片的推送通知/Toasts 摘要

问题描述

我已经构建了一些通过 webhook 向 Microsoft Teams 发送消息的工具,我决定切换到 Adaptive Cards 以使发送的消息更易于阅读和布局,因为 Adaptive Cards 的风格化程度远远超过标准MessageCard (0365 Connector)我已经设法做到了,但不幸的是在终点线遇到了一些障碍。

当使用自适应卡片发送推送通知时,它不会给出简短的细分或消息的前几行,而是简单地说Card。它也在 Microsoft Teams(PC 或移动)的“通知”选项卡下以这种方式显示,因此您可以想象这有点烦人,因为我发送了很多消息,您需要实际点击/单击才能阅读它们而无需事先看总结。

在旧式/O365 连接器中,我只需使用该summary字段,它就可以正常工作。

//O365 Connector
    "@type": "MessageCard",
    "@context": "http://schema.org/extensions",
    "summary": "John Doe commented on Trello",
    "title": "Project Tango",

我已经看到为 Bot Frameworks 提供的以下建议:

var response = MessageFactory.Text(string.Empty);
response.Attachments.Add(cardAttachment);
response.Summary = "showing custom greeeting from the Bot - rather than a card";
await turnContext.SendActivityAsync(response, cancellationToken);

但这不适用于这里,因为我使用的是 webhooks ......但我尝试Summary作为有效负载中的一个键来查看它是否有帮助,但它没有。

https://adaptivecards.io/schemas/adaptive-card.json [架构]

我查看了adaptive-card.json 架构,我看不到任何看起来会影响toast/push 通知的东西。我确实尝试fallbackText过,但我认为这仅在渲染器无法加载自适应卡的情况下使用,并且根本不用于摘要。

有任何想法吗?或者使用自适应卡片是否意味着我需要牺牲在通知/敬酒中总结信息的能力?

标签: webhooksmicrosoft-teamsadaptive-cards

解决方案


更新

问题已修复。您可以尝试在下面发送 JSON

{
   "type":"message",
   "summary": "my summary",
   "attachments":[
      {
         "contentType":"application/vnd.microsoft.card.adaptive",
         "contentUrl":null,
         "content":{
            "$schema":"http://adaptivecards.io/schemas/adaptive-card.json",
            "type":"AdaptiveCard",
            "version":"1.2",
            "body":[
                {
                "type": "TextBlock",
                "text": "For Samples and Templates, see [https://adaptivecards.io/samples](https://adaptivecards.io/samples)"
                }
            ]
         }
      }
   ]
}

目前没有解决此问题的方法,我们已向工程团队提出错误以在内部跟踪此问题。一旦我们有这方面的更新,我们会通知您。


推荐阅读