1
votes

I am using Bot framework to build bot.

I am using the following line to send the response to user:-

dc.Context.SendActivityAsync(activity);

In teams the response from bot to user in black text.

Do we have a feature to send text to user in different Color(like red, blue...).

Please help.

Thanks.

1
I'm pretty sure there's no option to color a normal text message, but have you looked into sending a card of some sort (e.g. Adaptive Card)? In that case you set styles, sizes, background images, and so on. For instance, if it's an "alert" type of message you could send have a relevant image on the card.Hilton Giesenow
Bear in mind though, whatever you choose in terms of these (backgrounds, styles, etc.) should be tested for different themes in Teams (Dark, Light, High Contrast) and may also render differently on desktop vs. mobile (e.g. something in italics on one form factor might not render the same on another), so you should test all these scenarios where possibleHilton Giesenow
Do you mean changing the color of the actual font, or highlighting phrases?JJ_Wailes
Yes @Hilton, Since I couldn't find any option I'm using adaptive card with text box element but even the adaptive card is supporting six colors.Krishna089
Yes, formatting, especially colours, is quite limited. As I mentioned above, I think the idea with this is to support all theme/device/screen scenarios best. What do you need the colours for, out of interest? Is it something like "alert" vs "warning"?Hilton Giesenow

1 Answers

2
votes

Following some of the conversation in the comments above, here's a more complete answer:

There's no way to set the color or style of the text in a normal "text" message - to do that, you need to use an Adaptive Card. Adaptive Cards don't have "real" colours in the normal sense (like you don't choose "red" or "blue" or hex code or anything like that), but they support use cases like "good" or "warning", and the environment in question (i.e. Teams in this case) will render that appropriately, based on the user's theme (so it will have an appropriate way to display "warning" in light theme, dark theme and high contrast theme).

You can see more about this here. Aside from that, Adaptive Cards also support some limited markdown format for things like bold and italics - see here.

As a final option, you can use the backgroundimage property of the card to represent certain features. For instance, in a "success" scenario you might want to have a background image that represents that.

Hope that helps.