Wrong user mentions in Teams message using AdaptiveCard in an incoming Webhook

Albert-Jan Verhees 0 Reputation points
2025-10-17T10:47:29.13+00:00

I'm using an automated process that mentions team members in a message every day. I use the AdaptiveCard and see some unexpected behavior when Teams cannot mention a specific user. Somehow the replacements of the <at>XXXXX</a> with a user mention is completely shifted in the message. If I enter a correct user id for that user, all the mentions seem to be in the right place again.

It looks like Teams removes users from the list that cannot be found, but it still uses an index to resolve them in the message:

Let me explain with an example message:

{
  "type" : "message",
  "attachments" : [ {
    "contentType" : "application/vnd.microsoft.card.adaptive",
    "content" : {
      "version" : "1.0",
      "type" : "AdaptiveCard",
      "body" : [
        {
          "type" : "TextBlock",
          "size" : null,
          "weight" : null,
          "text" : "Mention user <at>XXXXX</at>",
          "wrap" : true
        },
        {
          "type" : "TextBlock",
          "size" : null,
          "weight" : null,
          "text" : "Mention user <at>me</at>",
          "wrap" : true
        } ],
      "msteams" : {
        "entities" : [
          {
            "type" : "mention",
            "text" : "<at>XXXXX</at>",
            "mentioned" : {
              "id" : "******@our-company.com", <-- Non-existing user
              "name" : "XXXXX"
            }
          },
          {
          "type" : "mention",
          "text" : "<at>me</at>",
          "mentioned" : {
            "id" : "******@our-company.com", <-- Existing user
            "name" : "Me"
          }
        }
        ],
        "width" : "Full"
      },
      "$schema" : "http://adaptivecards.io/schemas/adaptive-card.json"
    }
  } ]
}

Now the message is displayed like:User's image

Notice that the first mention has been replaced by the second user.

If I swap the order of the mentions in the request, it works fine:

{
  "type" : "message",
  "attachments" : [ {
    "contentType" : "application/vnd.microsoft.card.adaptive",
    "content" : {
      "version" : "1.0",
      "type" : "AdaptiveCard",
      "body" : [
        {
          "type" : "TextBlock",
          "size" : null,
          "weight" : null,
          "text" : "Mention user <at>XXXXX</at>",
          "wrap" : true
        },
        {
          "type" : "TextBlock",
          "size" : null,
          "weight" : null,
          "text" : "Mention user <at>me</at>",
          "wrap" : true
        } ],
      "msteams" : {
        "entities" : [
          {
            "type": "mention",
            "text": "<at>me</at>",
            "mentioned": {
              "id": "******@our-company.com", <-- Existing user
              "name": "Me"
            }
          },
          {
            "type": "mention",
            "text": "<at>XXXXX</at>",
            "mentioned": {
			  "id" : "******@our-company.com", <-- Non-existing user
              "name": "XXXXX"
            }
          }
        ],
        "width" : "Full"
      },
      "$schema" : "http://adaptivecards.io/schemas/adaptive-card.json"
    }
  } ]
}

And the message looks like this, as expected:
User's image

I think this is a bug.

Microsoft Teams | Development
{count} votes

2 answers

Sort by: Most helpful
  1. Kudos-Ng 8,245 Reputation points Microsoft External Staff Moderator
    2025-10-17T11:49:53.9166667+00:00

    Hi Albert-Jan Verhees,

    Thank you for posting your question in the Microsoft Q&A forum. 

    Please note that our forum is a public platform, and we will modify your question to hide your personal information in the description. Kindly ensure that you hide any personal or organizational information the next time you post an error or other details to protect personal data.

    Based on the behavior you described and the accompanying JSON examples, I researched further through public resources and community discussions. Your hypothesis: “It looks like Teams removes users from the list that cannot be found, but it still uses an index to resolve them in the message” appears reasonable and does help explain the observed behavior.

    To elaborate, if Teams indeed uses this rendering mechanism, the process likely works as follows:

    • Teams parses the <at> tags in the message body sequentially and maps them to the msteams.entities array by index.
    • When an entity cannot be resolved (e.g., invalid mentioned.id), that entity is dropped from the array, but the original <at> tag remains in the text.
    • As a result, subsequent valid entities shift forward and replace earlier <at> tags, causing the mismatch you observed.

    To confirm this more precisely, you could test by sending three mentions where one in the middle is invalid and check whether the last two mentions shift positions.

    Thank you again for providing such a clear description and JSON samples, this is extremely helpful for the community. For even greater impact, I encourage you to raise this feedback on the official Microsoft Feedback Portal so the product team can review and consider improvements to make the experience more consistent.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".     

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. Kudos-Ng 8,245 Reputation points Microsoft External Staff Moderator
    2025-10-21T14:53:32.3633333+00:00

    Hi Albert-Jan Verhees,

    I noticed that Prasad mentioned earlier they couldn’t reproduce the issue in their environment, while you were able to. One detail that stood out: the Adaptive Card version Prasad used was 1.5, whereas your JSON shows 1.0.

    As far as I know, the Adaptive Card version can matter in certain scenarios. So, one last suggestion: could you try updating your card to version 1.5 and retest the issue? This will help confirm whether the behavior is tied to the older rendering logic.

    Let us know the outcome, it would be very useful for others following this thread.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.