问题
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