botframeworkmicrosoft-teamsadaptive-cards

Displaying response to user from bot in different color in Teams


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.


Solution

  • 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.