简体   繁体   中英

Microsoft Teams bot - debug link unfurling

I'm trying to implement pretty simple teams bot but constantly facing an issues with unpredictable behavior. Eg documentation clearly says that Teams applies Adaptive card as link unfurling response but when I'm sending pretty simple response like:

var card = new AdaptiveCard(new AdaptiveSchemaVersion(1, 0));
card.Body.Add(new AdaptiveTextBlock { Text = "Title", Size = AdaptiveTextSize.ExtraLarge });
var attachment = new MessagingExtensionAttachment { ContentType = AdaptiveCard.ContentType, Content = card };
var result = new MessagingExtensionResult(AttachmentLayoutTypes.List, "result", new[] { attachment });
return new MessagingExtensionResponse(result);

Teams doesn't render anything or follback to the default behavior. So the question is - are there any way to debug why it doesn't work?

Had the same issue, the problem is this is not documented at all. You'll need to send a hero card (maybe something else works as well?) as preview and the adaptive card as full card:

return {
        composeExtension: {
            type: 'result',
            attachmentLayout: 'list',
            attachments: [{
                preview: CardFactory.heroCard("title", "description")
                ...CardFactory.adaptiveCard(card)
            }]
        }
    };

This will display an "expandable" hero card which resolves to the adaptive card.

one easy way to find out what's going on and if your part is generally ok is by sending a full "static" card as a test. Just create the JSON layout somewhere, load it and sent it unchanged to MS Teams.

Also creating AdaptiveCard's like that is not the best way to do it, have a look at https://docs.microsoft.com/en-us/adaptive-cards/templating/ its a lot easier to handle cards like that.

Specific to your question there's no real way to debug anything inside ms teams. You can get a few errors in the analytics part of the bot framework and some times console output of your browser gives a few hints.

I wrote a similar thing some time ago which inserts a card on specific links similar to what you're trying to do and generally, that was (and still is) working fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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