Cannot mention user via Teams bot using BotFramework API

61 views Asked by At

I have fully configured and working Teams bot. It's able to start conversations with users and reply to their input. Now I want to mention user via my Teams bot in a group chat where that user is present.

I found docs describing how to achieve this:

I send the same payload as described in docs, but the content appearing in Teams has no mention or highlighting of the user, just regular text.

I test this on Web version of Teams and also on iOS.

So I tried this request:

POST https://smba.trafficmanager.net/apis/v3/conversations/{groupChatId}/activities

{
    "type": "message",
    "text": "Hey <at>Oleh</at>, check out this message!",
    "from": {
        "id": "{botId}",
        "name": "TestBot"
    },
    "conversation": {
        "id": "{groupChatId}"
    },
    "entities": [
        {
            "type":"mention",
            "mentioned":{
                "id":"{userId}",
                "name":"Oleh"
            },
            "text": "<at>@Oleh</at>"
        }
    ]
}

And text appears in Teams without user mentioning.

Also tried with Adaptive Cards - copied sample from the docs - behaviour is the same. Adaptive card is rendered correctly, but with no user mention.

I tried to put different user ID into "entities[0].mentioned.id" field:

  • user Teams ID (in the format "29:...")
  • user AAD Object ID
  • user email

And still no luck.

Am I passing something wrong, or it's an issue on the Teams side?


UPD Resolved!

After some digging I found that my raw request did not work as expected because I used different API url.

https://smba.trafficmanager.net/apis/v3/conversations/{converrsationId}/activities

sends message, but with broken mentions. Instead, this one:

https://smba.trafficmanager.net/emea/v3/conversations/{converrsationId}/activities

works as expected.

0

There are 0 answers