.Net开发者:Azure Bot Framework开发Skype for Business机器人自定义UI可行性咨询
Hey there! I’ve worked with Azure Bot Framework and Skype for Business (SfB) integrations before, so let’s tackle your problem head-on.
First, why is the ThumbnailCard showing as raw text in SfB?
Skype for Business has limited support for Bot Framework's native card types compared to the Bot Emulator or modern Teams. ThumbnailCard isn’t natively supported by SfB, so it falls back to rendering the raw JSON/text representation instead of the formatted card.
Can you customize the UI for Skype for Business?
Yes, but with some constraints. SfB doesn’t offer the same flexible custom UI as modern platforms, but you have two reliable approaches to get better-looking content than raw text:
1. Use Adaptive Cards (Recommended)
Adaptive Cards are the best option for consistent rendering across SfB and other channels. SfB supports Adaptive Cards up to version 1.2 (avoid newer versions with advanced features). You can replicate the ThumbnailCard's functionality with an Adaptive Card that SfB will render properly.
Here’s a .NET code example to create and send an Adaptive Card that mimics a ThumbnailCard:
using Microsoft.Bot.Schema; using AdaptiveCards; // Build the Adaptive Card var adaptiveCard = new AdaptiveCard(new AdaptiveSchemaVersion(1.2)) { Body = new List<AdaptiveElement> { // Card title new AdaptiveTextBlock { Text = "Your Card Title", Size = AdaptiveTextSize.Large, Weight = AdaptiveTextWeight.Bold }, // Thumbnail image new AdaptiveImage { Url = new Uri("https://your-image-url.com/thumbnail.jpg"), Size = AdaptiveImageSize.Medium, Style = AdaptiveImageStyle.Default }, // Card description new AdaptiveTextBlock { Text = "Your card description content here", Wrap = true } }, // Optional action button Actions = new List<AdaptiveAction> { new AdaptiveOpenUrlAction { Title = "View Details", Url = new Uri("https://your-link-url.com") } } }; // Convert to Bot Framework attachment var attachment = new Attachment { ContentType = AdaptiveCard.ContentType, Content = adaptiveCard }; // Send the card to the user await turnContext.SendActivityAsync(MessageFactory.Attachment(attachment), cancellationToken);
Key Notes for Adaptive Cards in SfB:
- Stick to basic elements (text blocks, images, simple actions) – avoid complex layouts or newer features like column sets if you want full compatibility.
- Test directly in the SfB client, not just the emulator, since the emulator supports more features than SfB.
2. Use Restricted HTML Formatting
If Adaptive Cards don’t fit your needs, SfB supports a limited set of HTML tags for message content. You can format your content to look like a card using these tags (though it won’t be as interactive as an Adaptive Card).
Allowed HTML tags in SfB:
<b>(bold),<i>(italic),<u>(underline)<br>(line break)<a href="url">link text</a>(hyperlinks)<img src="image-url" alt="alt text">(images, keep sizes small for best rendering)
Example HTML message:
var htmlMessage = @" <b>Your Card Title</b><br> <img src='https://your-image-url.com/thumbnail.jpg' alt='Thumbnail'><br> Your card description content here<br> <a href='https://your-link-url.com'>View Details</a> "; await turnContext.SendActivityAsync(MessageFactory.Text(htmlMessage, htmlMessage, InputHint.AcceptingInput), cancellationToken);
Important:
- Avoid complex CSS, divs, or spans with styles – SfB will ignore them.
- Keep HTML as simple as possible to ensure consistent rendering.
Final Checks
- Verify your Azure Bot's SfB channel configuration is set up correctly (no disabled features that block card rendering).
- Always test your bot directly in the SfB desktop or web client – the emulator's rendering doesn’t match SfB's capabilities.
This should help you replace the raw text output with a properly formatted UI that works in Skype for Business.
内容的提问来源于stack exchange,提问作者Bala Manikanta Koorakula

