Search code examples
botframeworkmicrosoft-teams

How to change the notification text for a Teams bot posting a card?


I am using a bot to post messages with a single attachment (an adaptive card) to a teams channel using the code below. This is working fine. However, on both mobile and the Teams activity feed, rather than some useful text being shown in the notification when a card is posted, the notification text is simply "Card" (see image below).

notification text

I have tried setting the fallbackText parameter on the card, which doesn't adjust the text in the notification. I have also tried setting the text parameter on the Activity instance, but this results in an error saying it resulted in multiple Skype activities. How can I make it so the context displayed in the notification is something apart from just "Card"?

card = CardFactory.adaptive_card({
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "type": "AdaptiveCard",
    "version": "1.2",
    "fallbackText": "This is some notification text",
    "body": [ ... ]})

connector.conversations.create_conversation(ConversationParameters(
    is_group=True,
    channel_data={ "channel": { "id": "..." } },
    activity=Activity(
        type=ActivityTypes.message,
        attachments=[card])))

Solution

  • @ajshort, You need to add summary to it. Following code should give you the modified text rather than just card.

    var reply = MessageFactory.Text(string.Empty);
    reply.Attachments.Add(callAdaptiveCardhere());
    reply.Summary="Your message will go here!"
    await turnContext.SendActivityAsync(reply);