microsoft/botbuilder-dotnet

Adaptive card sent by bot builder framework only shows "Sent a card" as the message, in iPhone

hussain-nz opened this issue · 0 comments

Version

4.11.1.0

Describe the bug

When sending an Adaptive card via bot builder framework, it only shows "Sent a card" as the message, in iPhone. The bug seems to be caused by the ampersand character &. See screenshot below in "Screenshot" section.

To Reproduce

Steps to reproduce the behavior:

  1. Bot message should be sent in the context of a custom Teams app, and will appear inside Chat/Activity tab of the custom Teams app. Code instructions below:
  2. Create "Activity" object.
  3. Populate ServiceUrl, Type, Summary.
  4. Populate Attachments with HeroCard. HeroCard "Message" property should have ampersand character &.
  5. Send Activity via turnContext.SendActivityAsync()
  6. Open the Teams bot message inside an iPhone (Chat/Activity tab of the custom Teams app).
  7. Code below in "Additional Context" section.

Expected behavior

MessageText should be shown correctly on iPhone (instead of "Sent a card"). It's working correctly on Android and PC.

Screenshots

Screenshot below that shows a working message on Android (left side) and incorrect message for iPhone (right side).
image

Additional context

Code to reproduce the issue:

    public async Task<string> Send(ITurnContext turnContext, string messageText, CancellationToken cancellationToken = default)
    {
        if (!turnContext.Activity.IsTeamsBot())
        {
            throw new BotException($"{turnContext.Activity.ChannelId} channel is not supported for this kind of bot messages.");
        }
    
        var campaignLaunchMessageActivity = new Activity();
        campaignLaunchMessageActivity.ServiceUrl = turnContext.Activity.ServiceUrl;
        campaignLaunchMessageActivity.Type = ActivityTypes.Message;
        campaignLaunchMessageActivity.Summary = messageText.StripHTML();
        campaignLaunchMessageActivity.Attachments = new List<Attachment>
        {
            new HeroCard
            {
                Text = messageText,
            }.ToAttachment(),
        };

        var response = await turnContext.SendActivityAsync(campaignLaunchMessageActivity, cancellationToken);

        return response.Id;
    }