Via Microsoft Teams, you can mention a Team or Channel and the members will be alerted to a new message being posted. Currently, via the default Power Automate actions, you are not able to mention either, unless you are familiar with Graph. It’s not as difficult as it seems though. Let me show you how via my solution below.
First, choose your Team and Channel
By using the List Channels Action in Power Automate, we are able to obtain a list of Channels for a particular Group, but not only that, we are able to retrieve the Group ID from the Input Parameters as shown in the last of the four actions below (the Compose – GroupTeamID). We are going to post on the General Channel, and for us to obtain the Channel ID, we filter the array from the List Channels Action for “General” and then retrieve the first() and most likely the only object returned by the filter by using a compose and selecting the Id.
Constructing our Graph API Request
Thankfully, due to a new action, calling the Graph API has recently been made a lot simpler and the message will be posted as you, the logged-on user. You would have previously had to construct a couple of HTTP calls or build a custom connector in order to achieve this.
The Channel Mention and Team mention have slightly different JSON Body Payloads, which I will provide for you to copy below but the endpoint is exactly the same. Details of which can be read here.
graph.microsoft.com/v1.0/teams/{teamId}/channels/{channelId}/messages
Note that for both actions, you must call the mention with an HTML AT tag. Your Mentions Array can have multiple users, channels, or teams to tag. I will show you in my YouTube video how I was able to individually tag all users in a security group using a select action.
Channel Mention
{ "body": { "contentType": "html", "content": "<at id=\"0\">General</at> This is a channel alert! 🔔" }, "mentions": [ { "id": 0, "mentionText": "General", "mentioned": { "conversation": { "id": "@{outputs('ChannelID')}", "displayName": "General", "@odata.type": "microsoft.graph.teamworkConversationIdentity", "conversationIdentityType": "channel" } } } ] }
Team Mention
{ "body": { "contentType": "html", "content": "<at id=\"0\">TheWholeTeam</at> Hello Team! 😉" }, "mentions": [ { "id": 0, "mentionText": "TheWholeTeam", "mentioned": { "conversation": { "id": "@{outputs('GroupTeamID')}", "displayName": "TheWholeTeam", "@odata.type": "microsoft.graph.teamworkConversationIdentity", "conversationIdentityType": "team" } } } ] }
Note that for both Mentions, you must update the mentionText, displayName and value contained within the HTML AT Tag for this to work. My values are fixed, you can of course make these dynamic.
Mention the Channel and Team in one Post
Using the above examples you can now automatically tag a team or a channel in Teams via Power Automate. Please let me know below how you might use this in your scenario.
Good morning,
This is just what I have been looking for! Sadly, my flow fails on the compose Team ID. An error message states –
Correct to include a valid reference to ‘Listchannels’ for the input parameter(s) of action ‘Team_ID’.
I’m using the exact expression you have stated. Am I doing anything wrong?
Hi Lee, it might just be the space. When I was building this out, I renamed my action List Channels to ListChannels. The actions() expression is calling on the name of the Action. Can you try removing the space from the action name or including as space in your actions() expression?
I’ve got HTTP 400 error on “send an http request -Channel mention” step
Here is the error details
Bad Request
Bad Request – Invalid Hostname
HTTP Error 400. The request hostname is invalid.
I’ve no ideal how to fix it? Could you please advice
Hi Alex, thanks for reaching out. Can you take a look at your flow history. It sounds like the url for graph api isn’t constructed correctly.
Thanks for sharing good content. have a question, is it possible to populate separate excel file template dynamically for each row in separate cell. Basically when a row is added in one excel, we need to populate new excel file template with file name as date-name-status, and populate the values to new file template created. Is it achievable?? If so can you guide me on this
It’s not possible to trigger on an excel row but you can on a file being modified and then get row(s). I would recommend having a status column to update once processed. An easier way is using a list which can be triggered on a new list item. Populating an excel template, if not a simple row and is specific cells, can be done with an office script https://damobird365.com/perfectly-complete-an-excel-invoice-template/
is it possible to mention a channel/team in a reply to previous post in a channel?
Hi there, try https://docs.microsoft.com/en-us/graph/api/channel-post-messagereply?view=graph-rest-1.0&tabs=http and if you get stuck I can try and take a look.
Hi!
Thanks for sharing, this is exactly what I’m trying to achieve. However I’ve got an error on the action Send an HTTP Request (Preview). I’ve tested my query and I’m able to send message to a channel through the Graph Explorer but not from Power Automate. I got an error “Not found” State “404”. Does this solution required to give permission “ChannelMessage.Send” in the graph somewhere in AAD? Regards
Not found would suggest the endpoint can’t be found?
Brilliant flow, but sadly doesn’t not work for me. Very frustrating! Same error as above ‘404 Not found’.
Has anyone found a solution to this as yet. Very confusing. Any help would be much appreciated to get this working.
Have you tested this in the graph explorer? To see if it’s your user or PowerAutomate.
Hey, great post!
I am having an annoying problem with this solution…
My flow runs smoothly, but I get no notification when the team or channel are mentioned. I checked my notification configurations but everything seems ok, but still no notification when the mention is posted.
Am I missing something?
I guess you need to check carefully the ID’s and the tags again. I’ve used this in a recent video and it worked OK.
I was facing the same issue as this. The message was there and the mention (channel, in my case), was noted, but no Activity notification. I *believe* it was because I was checking Teams of the user that was making the post. As soon as I logged in as another user and triggered it, the notification worked as intended.
Really appreciate you posting this tutorial, DamoBird!!
Is there a way to add an @user to the same flow?
I got the flow working after getting the Channel and Team IDs around the wrong way so if you are having issues, make sure the TeamsID is first and the ChannelID is second (Channel ID can include colons).
try:
“mentions”: [
{
“id”: 0,
“mentionText”: “Alex”,
“mentioned”: {
“user”: {
“displayName”: “Alex”,
“id”: “123280d2-a522-4d92-8fd9-3dd0b9660497”,
“userIdentityType”: “aadUser”
} ]
Hi Damo,
I’ve tried the following and am getting a JSON error message and was wondering if you had seen it before?
{
“body”: {
“contentType”: “html”,
“content”: “General Everyone please wish @{outputs(‘Get_user’)?[‘body/displayName’]} a happy 1st anniversary! ”
},
“mentions”: [
{
“id”: 0,
“mentionText”: “General”,
“mentioned”: {
“conversation”: {
“id”: “@{outputs(‘ChannelId’)}”,
“displayName”: “General”,
“@odata.type”: “microsoft.graph.teamworkConversationIdentity”,
“conversationIdentityType”: “channel”
}
}
}
{
“id”: 1,
“mentionText”: “@{outputs(‘Get_user’)?[‘body/displayName’]}”,
“mentioned”: {
“user”: {
“displayName”: “@{outputs(‘Get_user’)?[‘body/displayName’]}”,
“id”: “@{outputs(‘Get_user’)?[‘body/id’]}”,
“userIdentityType”: “aadUser”
}
}
}
]
}
It comes out with an error of
”
Unable to read JSON request payload. Please ensure Content-Type header is set and payload is of valid JSON format.
You need to insert a comma between objects.
conversationIdentityType”: “channel”
}
}
}, <—— { “id”: 1,
That worked.
Thanks a lot for your help.
It’s amazing that you’ve helped a random Australian with this.
No problems, I love knowing I’ve helped. Thanks for letting me know and good luck with your solution.
Will this same process work for private channels? Not able to pull the Team/groupID (cannot get the link to the channel when clicking on the three dots of the private channel).
Try using the groupID from the general channel and obviously the channel ID from the private channel link. I have just tested hellow world on graph explorer https://developer.microsoft.com/en-us/graph/graph-explorer?WT.mc_id=DX-MVP-5004666 and this worked for me in a private channel – i’ve not test tagging though.
Hi I tried the code but i am getting below error
404 page not found
Error:
Action ‘Send_an_HTTP_request’ failed
Check your endpoint. There are variations depending on location. 404 not found suggests the one you have used, cannot be found 👍
Have been searching for a non-premium solution, this looks great but sadly I am getting a code 400 error Action ‘Send_an_HTTP_request’ failed with message ‘URI path is not a valid Graph endpoint, path is neither absolute nor relative or resource is not one of the supported (me, users, groups, sites, search, planner, teams, chats):’
I have double checked not finding anything off from the provider instructions.
Time might come on this to be honest, it’s unpublished and a hack using the existing api in teams. There are caveats for USA or GCC, different URL. Can you share the endpoint you are using and do either of the above apply to you?
I am in the US. I tried running the URI through Graph Explorer and hit some permissions issues. I suspect the flow may be failing due to security settings within my organization. I’d happily have it be an error on my side meaning I can fix on my side.
graph.microsoft.com/v1.0/teams/f6fe6a4d-2279-4e6b-b4eb-8bdb52fcff2c/channels/19:3bSSQ73iCQCCtZvjE3DdxsYNLyP0oAZMZ9pWt_TdYy41@thread.tacv2/messages
Shame on me. The HTTPS:// fell off my URI. Got it working now. Great solution!
Glad you got it sorted and thanks for coming back to me. Enjoy!
How have you sorted out? I got same error, I’m from Europe.
Many thanks
my error is
{
“error”: {
“code”: 400,
“message”: “URI path is not a valid Graph endpoint, path is neither absolute nor relative or resource is not one of the supported (me, users, groups, sites, search, planner, teams, chats): graph.microsoft.com/v1.0/teams/668c8ef2-dc73-4af1-8f9a-b29fb629fd57/channels/19:c5f2072fd0d14225ae23b75fe92746f8@thread.skypemessages”,
“source”: “flow-apim-europe-001-northeurope-01.azure-apim.net”,
“path”: “choose[9]\\when[1]”,
“policyId”: “”,
“clientRequestId”: “9646c174-d849-43d2-8d17-715e44286b05”
}
I have now this error: Action ‘Send_an_HTTP_request_-_Channel_mention’ failed
how can I add a hyper link into this to link to a SharePoint document
Hi there, i’m running this flow but I am unable to receive notifications even though the message arrives correctly. What can be wrong with that?
Hey Thank you for knowledge share. I am getting error: An action failed. No dependent actions succeeded.
Send an Http request output:
{
“error”: {
“code”: “BadRequest”,
“message”: “Neither Body nor adaptive card content contains marker for mention with Id ‘0’. Add ‘PULSE’ to the body or an adaptive card.”,
“innerError”: {
“date”: “2022-05-16T12:44:37”,
“request-id”: “f453f958-bb1b-4870-a445-abd14fe0932b”,
“client-request-id”: “f453f958-bb1b-4870-a445-abd14fe0932b”
}
}
}
Hi
I’m getting the following error….The template validation failed: ‘The template action ‘Get_Group_ID’ at line ‘1’ and column ‘6714’ is not valid: “The template function ‘body’ is not expected at this location.
{
“body”: {
“contentType”: “html”,
“content”: “Luke Test This is a channel alert! 🔔”
},
“mentions”: [
{
“id”: 0,
“mentionText”: “Luke Test”,
“mentioned”: {
“conversation”: {
“id”: “@{outputs(‘Get_Channel_ID’)}”,
“displayName”: “Luke Test”,
“@odata.type”: “microsoft.graph.teamworkConversationIdentity”,
“conversationIdentityType”: “channel”
}
}
}
]
}
Hi – is there a way this message can be sent from a bot user type rather than using the user’s account?
Hello!
The flow works perfect for me, but I would like to edit the message with functions like bold, spaces and hyperlink.
I tried to do it with HTML but it tells me that there is an error with the JSON. Thank you very much!
Note the slashes that break up the “at id” line..you need back slashes in any HTML containing ” to send it as a literal instead of a piece of line code.
I have managed to get this to work but does anyone know how to send a URL for people to click on. Currently i can send the URL but its unclickable. I’ve tried regular HTML but it says the JSON is not correct then. I want to alert the channel when there has been a new submission on a SharePoint List and send the link to the item within the Channel Mention. Any help would be appreciated.
Hi Melissa, you should be able to use https://www.w3schools.com/tags/att_a_href.asp but will need to escape double quotes with a forward slash.
Thanks a lot DamoBird,
I managed to make it work for my use case. One thing strange though. I was only able to make it work by using the beta version of the API instead of v1.0 with this URL:
https://graph.microsoft.com/beta/teams…
instead of
https://graph.microsoft.com/v1.0/teams…
any idea why?
Another question. My Team contains an ampersand, let’s say “Fun & Games”
I’m not able to figure out the proper syntax for the mentions to include the ampersand.
Could you advise please?
Actually found the answer to my question.
displayName doesn’t seem to support “&” but the and the mentionText do. So, the following seems to be working:
{
“body”: {
“contentType”: “html”,
“content”: “Fun & Games Hello Team! 😉”
},
“mentions”: [
{
“id”: 0,
“mentionText”: “Fun & Games”,
“mentioned”: {
“conversation”: {
“id”: “@{outputs(‘GroupTeamID’)}”,
“displayName”: “Fun and Games”,
“@odata.type”: “microsoft.graph.teamworkConversationIdentity”,
“conversationIdentityType”: “team”
}
}
}
]
}
Hi, Thanks for your support and for this solution. It is very helpful. I´m trying to insert an image into the body, but the flow failed when I tray it to do it. What is your suggestion. Is it possible to implement?
Thank you in advance!
Hi DamoBird365, Excelent Video, Is exactly what I need, but in step “send HTTP an request”, I have an error because the url doesn’t work.
graph.microsoft.com/v1.0/teams/{teamId}/channels/{channelId}/messages
this is the error:
URI path is not a valid Graph endpoint, path is neither absolute nor relative or resource/object is not supported for this connector. Resources: groups. Uri: graph.microsoft.com/beta/teams/319e1b3b-6f9e-47a9-a4f2-c7dcb231383d/channels/19:b9b6f5a6f4d34ae29bace5ad5ff02fb8@thread.tacv2/messages
How I get the correct url of my teams?
Thanks for your help 😀
Hi Ruben, your copied uri has beta instead of v1.0? Could you check this and report back?
Hi DemoBird365.
I did both. this is a error with v1.0 :
URI path is not a valid Graph endpoint, path is neither absolute nor relative or resource/object is not supported for this connector. Resources: groups. Uri: graph.microsoft.com/v1.0/teams/319e1b3b-6f9e-47a9-a4f2-c7dcb231383d/channels/19:b9b6f5a6f4d34ae29bace5ad5ff02fb8@thread.tacv2/messages
I need a team mention and I paste this code:
{
“body”: {
“contentType”: “html”,
“content”: “TheWholeTeam Hello Team! 😉”
},
“mentions”: [
{
“id”: 0,
“mentionText”: “TheWholeTeam”,
“mentioned”: {
“conversation”: {
“id”: “319e1b3b-6f9e-47a9-a4f2-c7dcb231383d”,
“displayName”: “TheWholeTeam”,
“@odata.type”: “microsoft.graph.teamworkConversationIdentity”,
“conversationIdentityType”: “team”
}
}
}
]
}
I really appreciate your help
hey Ruben, were you able to finally get it working? seems i’m stuck at the very same error message. using v1.0/ tried beta as well, made sure and checked for every single typos, still no luck
“URI path is not a valid Graph endpoint, path is neither absolute nor relative or resource/object is not supported for this connector. Resources: groups Objects: messages,mailFolders,events,calendar,calendars,outlook,inferenceClassification.
getting same error response
Microsoft have released a v2 which restricts endpoints. You would have to use the entra id http action, which is premium.
How to include a image in the body
Hey, thanks for providing this info! I am getting a 404 error. When I review the flow, in the HTTP request where the output for GroupTeamID goes it is showing blank. I have followed the compose actions expression as you have it above. But every time there is no output. Not sure what to do.
Take a look at the history output. See if you can spot the guid. 404 means not found. Wonder if a url has changed or is typed wrong. Can you share ?
I got and it works. Do you need to use “Send a http request V1”, DO NOT USE “V2” cause is partial restricted, this is the Key. And be carefull with doble cuotes on “content” text, remember use \ before. (use \” when “). thank you for the post.
Thanks for sharing Isa 👍
Hello, thaks a lot for your post, it was really really helpful. i need to add something else. i have it triggered when a sharepoint file is added. i need to post in the channel the creator’s email
i have added with “compose” the created by email object but i need to be clickable, or to @mention the creator. Any ideas?
The out put should be something like this :
{channel tag} hey everyone. the user : {created by email} has added a new file !
Have you tried html tags? https://www.w3schools.com/tags/att_a_href.asp
Hi Damian,
Thanks for the great video. As I’m trying to reproduce your steps, it seems to be that Microsoft did some updates. For instance, the Compose block gets automatically embedded in an Apply_to_each block now. This is fine but the problem now is in the next “Send an HTTP request” blocks, I’m unable to get the “Outputs” blocks, they are not available in the list of dynamic content after the “Apply_to_each” and I read that it’s because “Apply_to_each” only successes or fails, it doesn’t provide an output array.
Your help would be appreciated!
I solved my issue, so no need to reply 🙂
Thanks for letting me know.
Is there any way that I can post to the channel as Flow Bot using this Send HTTP Request method?
Thank you! Appreciate your help.
Hi , i am also facing the same issue
I got and it works. Do you need to use “Send a http request V1”, DO NOT USE “V2” <- unfortunately i do not see the V1 version how can i get to this?