0
votes

I'm experimenting with messaging extensions for MS Teams (using the .net SDK), and I'm running into a problem building a response to a query. I have a handler that can handle the invoke with composeExtension/query, and it works fine if I return a HeroCard, but not an AdaptiveCard. Here's my working HeroCard code:

        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());

And here's the version I'm trying with an adaptive card:

        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());

The code to create the adaptive card is taken directly from the docs.

The documentation on messaging extensions implies that adaptive cards should be supported in this scenario (with type application/vnd.microsoft.card.adaptive). When I get the initialFetch result from the extension, and I return an AdaptiveCard (either alone or with a working HeroCard in the array), I get the "Something went wrong with this app." message in Teams. Is there a way to get this to work?

1
Would this be for a v3 or v4 bot? The GitHub repo for this (github.com/OfficeDev/BotBuilder-MicrosoftTeams) states it is only for v3 at this time. There is no v4 offering yet. The doc link to the Nuget package also states it is only valid for Microsoft.Bot.Builder (>= 3.5.9 && < 4.0.0).Steven Kanberg
Good point, forgot to mention that. V4 with the 4.0.0 beta nuget package.Chris Bardon
Did you ever get this working? Are you still needing help?Steven Kanberg
No, I never managed to get it working. The answer I got on github was that adaptive cards aren't supported in previews though, so I suppose this is "not working as intended". github.com/OfficeDev/BotBuilder-MicrosoftTeams-dotnet/issues/15Chris Bardon

1 Answers

0
votes

Just to close this off, I opened this as a bug on the github project, and it looks like the answer is that it's not supported at this time: https://github.com/OfficeDev/BotBuilder-MicrosoftTeams-dotnet/issues/15