在Teams消息传递扩展程序中退还自适应卡,这可以工作吗?

时间:2019-02-26 19:05:33

标签: botframework microsoft-teams

我正在尝试针对MS Teams的消息传递扩展(使用.net SDK),并且在构建对查询的响应时遇到了问题。我有一个处理程序,可以处理composeExtension / query的调用,如果我返回HeroCard而不是AdaptiveCard,它可以正常工作。这是我正在使用的HeroCard代码:

        MessagingExtensionResult result = new MessagingExtensionResult
        {
            Type = "result",
            AttachmentLayout = "list",
            Attachments = new List<MessagingExtensionAttachment>(),
        };

        HeroCard h = new HeroCard()
        {
            Text = "Hello, my name is Inigo Montoya, you killed my father, prepare to die.",
            Tap = new CardAction()
            {
                Type = "messageBack",                   
                Text = "option1",
            },
        };
        result.Attachments.Add(new Attachment() { ContentType = HeroCard.ContentType, Content = h }.ToMessagingExtensionAttachment());

这是我正在尝试使用自适应卡的版本:

        AdaptiveCard card = new AdaptiveCard();

        card.Body.Add(new AdaptiveTextBlock()
        {
            Text = "Hello",
            Size = AdaptiveTextSize.ExtraLarge
        });

        card.Body.Add(new AdaptiveImage()
        {
            Url = new Uri("http://adaptivecards.io/content/cats/1.png")
        });

        result.Attachments.Add(new Attachment() { ContentType = AdaptiveCard.ContentType, Content = card }.ToMessagingExtensionAttachment());

创建自适应卡的代码直接来自docs

documentation on messaging extensions表示在这种情况下应支持自适应卡(类型为application / vnd.microsoft.card.adaptive)。当我从扩展名获得initialFetch结果,并返回AdaptiveCard(无论是单独使用还是与阵列中可用的HeroCard一起使用)时,我都收到“此应用程序出了点问题”。团队中的消息。有办法使它起作用吗?

1 个答案:

答案 0 :(得分:0)

只是为了解决这个问题,我将其作为github项目上的错误打开了,看来答案是目前不支持该错误: https://github.com/OfficeDev/BotBuilder-MicrosoftTeams-dotnet/issues/15