I'm working on a Teams bot and I'm trying various ways to send rich messages to users (we need clickable buttons) from my bot. I have tried adaptive cards, which are almost perfect, but noticed that on the toast popup for the message it just says "Testbot sent a card". This isn't ideal as we'd like an overview of the message to appear instead.
I noticed that when you use the weather app to send a card to another user, it has the desired effect- a short summary of the weather appears in the toast popup. Looking inside the JSON that represents that message shows that the "card" is actually an HTML attachment.
Am I able to replicate this by sending an HTML attachment? I have (naively) tried the following but it causes an exception:
Activity reply = new Activity();
reply.Type = ActivityTypes.Message;
reply.Text = "Test the toast";
reply.Conversation = new ConversationAccount()
{
Id = conversationResponse.Id
};
reply.Attachments.Add(new Attachment()
{
ContentType = "text/html",
Content = "<div>Some generated html</div>"
});
Am I just barking up the wrong tree completely?
Thanks.
Edit:
The exception I'm getting is "Operation returned an invalid status code 'BadRequest'" from within mscorlib.dll.
For an adaptive card, I can do the following, and it works fine:
reply.Attachments.Add(new Attachment()
{
ContentType = "application/vnd.microsoft.card.adaptive",
Content = JsonConvert.DeserializeObject("{Some generated JSON}")
});
When trying to send the attachment as HTML, I assume I need to do more than simply send a string as Content. I tried rendering an adaptive card to HTML and attaching the resultant RenderedAdaptiveCard object, but still got the same exception.
--
Edit 2:
When a colleague sends me a card using the weather app: https://i.imgur.com/BlBk557.png
I get the following toast: https://i.imgur.com/EoO8COj.png
When using that tool to send a message to the bot, I can see a message with an attachment of type text/html.
I was attempting to replicate this by sending a message from the bot to a user with an attachment of type text/html and some HTML in the content field. I now see that when I do this there is a 400 response from the serviceUrl which says
{"error":{"code":"BadArgument","message":"Unknown attachment type"}}
I think maybe the assumption I made was based on a misunderstanding. I take it that we can't have informative text on the toast for a card in the same manner as the weather app?