Microsoft Teams bot - debug link unfurling

你。 提交于 2021-02-11 15:27:31

问题


I'm trying to implement pretty simple teams bot but constantly facing an issues with unpredictable behavior. E.g. 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?


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/60232439/microsoft-teams-bot-debug-link-unfurling

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!