Posting Mentions to Teams using Graph
I'm putting this out there because it took me some time to figure out and at the time I couldn't find any documentation on how to use the Graph API to post a mention to a Teams channel:
- GET Team ID: https://graph.microsoft.com/beta/me/joinedTeams
- GET Channel ID: https://graph.microsoft.com/beta/teams/{team-id}/channels
- GET User ID: https://graph.microsoft.com/v1.0/me/people/?$search="Firstname Lastname"
- POST https://graph.microsoft.com/beta/teams{Team ID}/channels/{Channel ID}/messages (Include the BODY of the POST as below)
Minimum JSON needed for body of the POST:
{
"body": {
"contentType": "html",
"content": "<at id=\"0\">Firstname Lastname</at>Boo"
},
"attachments": [],
"mentions": [
{
"id": 0,
"mentionText": "Firstname Lastname",
"mentioned": {
"application": null,
"device": null,
"conversation": null,
"user": {
"id": "0d7ac188-610b-4194-98de-db80b6019ed1", //From Step 3 above
"displayName": "Firstname Lastname",
"userIdentityType": "aadUser"
}
}
}
],
"reactions": []
}
Comments
Post a Comment