30

I'm trying to mention a user from an incoming webhook.

I tried a few iterations via Postman of

{
"text": "test @user"
}

or

{
"text": "test @user@email.com"
}

but none of these seem to work. Is this simple but very important thing just not possible?

Thanks.

David O'Brien
  • 813
  • 1
  • 9
  • 18
  • Does this answer your question? [How to mention a user/group in a new message to a channel?](https://stackoverflow.com/questions/41440803/how-to-mention-a-user-group-in-a-new-message-to-a-channel) – LbISS Sep 04 '20 at 09:36
  • Here is a [an answer](https://stackoverflow.com/a/69365035/375958) – Jalal Oct 10 '21 at 15:01
  • Does this answer your question? [@mention via incoming webhook in MS Teams using MessageCard](https://stackoverflow.com/questions/61494475/mention-via-incoming-webhook-in-ms-teams-using-messagecard) – Jalal Oct 10 '21 at 15:01

4 Answers4

22

I'm afraid this isn't possible yet - the only way to do @ mentions is by using the full Bot Framework APIs.

You're not the only one to have asked for this though, so I'll get it on the backlog.

Bill Bliss - MSFT
  • 3,553
  • 1
  • 14
  • 17
  • 4
    Thanks Bill. We're using lots of notifications during builds and deployments for our customers (mainly AWS) into their Slack channels. I have now come across my first Teams customer and was quite surprised to see this not work. Is that task something I can follow on Github? – David O'Brien Feb 02 '18 at 08:45
  • 1
    @Bill Bliss - Is there an ETA on that functionality? The only thing I could see on [uservoice](https://microsoftteams.uservoice.com/forums/555103-public/suggestions/32313991-allow-webhooks-extensions-to-mention-individuals) only had 17 votes which doesn't fill me with confidence! :-). – John Stephenson Apr 12 '18 at 06:31
  • What is this https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/group_post_threads used for - if it isn't to mention a user - in a Team thread? It is listed under **"Conversation Thread"** so appears tantalisingly relevant to Teams: "newParticipants": [{ "emailAddress": { "name": "John Doe", "address": "jdoe@acompany.com – Jerry Weeks Apr 24 '18 at 08:03
  • @bill Could you please update if this is possible yet ? – GoodSp33d Feb 18 '19 at 13:33
  • 1
    I'm feeling so frustrated because this is often the case with MS ecosystem at the moment. I can't recommend it. – Cobolt May 28 '20 at 09:06
  • @bill bliss guessing this still isn't possible? With all the ads for teams in lockdown, would be great to have such functionality, this is such a common effective usecase in slack. – jabberwocky Jun 11 '20 at 14:18
  • 1
    It appears that it took over two years for Mr. Bliss to get it on the back log, if @Jakob 's link has accurate information. So: progress, but excruciatingly slow progress. In the mean time the documentation is better than it was, but can still be a little confusing on these points. – Justin Aug 03 '21 at 15:27
  • It's highly confusing in that it implies it is possible and doesn't explicitly say that you can't do it form a plain webhook and need to use a bot to post the message instead. This was the change to the docs from April 2021: https://github.com/MicrosoftDocs/msteams-docs/pull/3130/files – sahmeepee Mar 08 '23 at 11:59
  • Downvoted, as the answer is outdated. I was able to use a webhook to post an adaptive card which included a mention based on my AAD-login-name. – Rick Moritz Jul 27 '23 at 15:23
20

This is now supported and documented here (https://learn.microsoft.com/en-us/microsoftteams/platform/task-modules-and-cards/cards/cards-format?tabs=adaptive-md%2Cconnector-html#user-mention-in-incoming-webhook-with-adaptive-cards).

Sample:

{
  "type": "message",
  "attachments": [
    {
      "contentType": "application/vnd.microsoft.card.adaptive",
      "content": {
        "type": "AdaptiveCard",
        "body": [
          {
            "type": "TextBlock",
            "size": "Medium",
            "weight": "Bolder",
            "text": "Sample Adaptive Card with User Mention"
          },
          {
            "type": "TextBlock",
            "text": "Hi <at>Adele UPN</at>, <at>Adele AAD</at>"
          }
        ],
        "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
        "version": "1.0",
        "msteams": {
          "entities": [
            {
              "type": "mention",
              "text": "<at>Adele UPN</at>",
              "mentioned": {
                "id": "AdeleV@contoso.onmicrosoft.com",
                "name": "Adele Vance"
              }
            },
            {
              "type": "mention",
              "text": "<at>Adele AAD</at>",
              "mentioned": {
                "id": "87d349ed-44d7-43e1-9a83-5f2406dee5bd",
                "name": "Adele Vance"
              }
            }
          ]
        }
      }
    }
  ]
}
MohamadKh75
  • 2,582
  • 5
  • 28
  • 54
Ariel Popovsky
  • 4,787
  • 2
  • 28
  • 30
  • 3
    The docs currently have a Note saying notifications "will be available in the future release". It seems to be working for [some](https://stackoverflow.com/a/69365035/675674) already, but not for everyone. – lapis Oct 31 '21 at 12:02
  • How do I get the user ID? – Anand Undavia Sep 22 '22 at 11:20
  • 1
    @AnandUndavia according to the sample, you can use either their email address or the id from the Active directory. But I cannot test this as I'm not working on this project anymore. – Ariel Popovsky Sep 23 '22 at 12:09
  • One clarification: that ID may look like an e-mail address, but it's really the domain name of the user principal. It's usually, _but not necessarily_ also an e-mail address. The e-mail-address shown in Teams will specifically _not_ work as an ID, if it is different from the actual user ID. – Rick Moritz Jul 27 '23 at 15:25
1

If it helps anybody, after looking in to this and seeing it couldn't be done (still!?), a workaround for me was to change the channel notification settings to banner + feed for all new posts for relevant users in the channel. This eliminates the need to use the tag (if tagging the team).

Callum.
  • 146
  • 12
  • 2
    Is it possible to enable notifications for all users from the admin console or a centralized place without having to ask each user to do it manually? – Guille Mar 19 '20 at 19:57
  • I can't find the setting to change notification settings per-user per-channel. Where is this setting accessible? Is this only in the teams admin app? The only related setting I see is in each user's CHannel Notifications settings as linked below. This isn't a viable solution bc it requires each user to make this same change. https://support.microsoft.com/en-us/office/customize-channel-notifications-in-teams-c72b8c07-37e1-4a0b-82c9-fdfda04f15b2 – timblaktu Jan 13 '21 at 20:01
0

It is supported in Teams now, however the sample code does not work in Microsoft card playground, I didn't know the code actually worked until I tried in Postman.

Janet W.
  • 401
  • 4
  • 3