在 Microsoft Teams 上推送 Notifications/Toasts 自适应卡片摘要

Push Notifications/Toasts Summary for Adaptive Cards on Microsoft Teams

我已经构建了一些通过 webhook 将消息发送到 Microsoft Teams 的工具,我决定切换到自适应卡片以使发送的消息更容易阅读和布局,因为自适应卡片可以风格化比标准 MessageCard (0365 Connector) 多很多,我已经设法实现了,但不幸的是在终点线上遇到了一些障碍。

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

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

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

我看到以下内容作为 Bot 框架的建议提供:

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 [schema]

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

有什么想法吗?还是使用自适应卡片意味着我需要牺牲在 notifications/toasts 中总结信息的能力?

更新

问题已解决。您可以尝试发送下面的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)"
                }
            ]
         }
      }
   ]
}

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