Chris Bardon
Chris Bardon

Reputation: 480

Is it possible for a teams messaging extension to return a plaintext response instead of a card?

I'm trying to create a messaging extension for Teams based on the v4 bot SDK that searches a knowledge base and provides suggested responses that can be placed into a chat. The search works, and I can select a card to put into the chat, but I'd like to strip out the formatting and just return a block of text to the chat (i.e. I don't want anyone else in the chat to see that the response came from an extension). I'm able to specify a list of cards in my search results, and I tried setting the cardAction property of my heroCard search result result to "messageBack", but this still puts a full card into the team chat. I tried mocking up something simple that just has a static response to see if I could get this working:

        MessagingExtensionResult composeExtensionResult = new MessagingExtensionResult
        {
            Type = "result",
            AttachmentLayout = "list",
            Attachments = new List<MessagingExtensionAttachment>(),
        };

        HeroCard h = new HeroCard()
        {                
            Title="Intro",
            Text="Hello, my name is Inigo Montoya, you killed my father, prepare to die.",                 
            Tap=new CardAction()
            {
                Type= "messageBack",
                DisplayText="send message",
                Text="111",
            },
        };
        composeExtensionResult.Attachments.Add(h.ToAttachment().ToMessagingExtensionAttachment());

Any idea whether there's a way to get a plain text response, or do bot responses always come back attributed to the bot?

Upvotes: 3

Views: 657

Answers (1)

Chris Bardon
Chris Bardon

Reputation: 480

So it appears that the above example works after all (sort of). I tried changing the card to format like this:

        HeroCard h = new HeroCard()
        {                
            Text="Hello, my name is Inigo Montoya, you killed my father, prepare to die.",
        };

Which puts in a card-like response when I use the compose extension: image of compose extension card

If I look at this same post as another user though, I get this: Remote user view of card So it appears that this is intentional, but perhaps not documented as well as it could be. It is worth noting that the contents of the card will still be sent, just not the overall compose extension title and image.

Upvotes: 2

Related Questions