SOLUTIONS FOR MICROSOFT 365
A Million Ways of @Mention in Microsoft Teams using a Power Automate Flow.
This is a short story about mentioning people or a channel in Microsoft Teams from within a Power Automate flow — All with a happy end
It’s Tuesday 6 pm, and I’m ready to leave the home office 😉. One last check of social media and the online communities, to see if I can help somebody.
Oh yes, there is a question from a guy asking on “How to post an important message in Teams and mention the Channel using a Power Automate Flow?”
That’s an easy one, I think to myself. Let’s quickly do that…
(Mood radar while doing it “quickly”)
🙂 = 6 pm
😒 = 7 pm
😩 = 8 pm
😨 = 9 pm
😱 = 10 pm
It’s 10 pm, and I’m exhausted. I thought it would be easy, but it isn’t.
That’s how life in IT sometimes is…
TL; DR
After spending a couple of hours testing all available options, I’ve found a solution that satisfies all those needs. This story covers everything I tried and gives you some more insights. I hope it saves you some time too.
If you’re not interested in all the things I tried, jump to the Conclusion and Solution section at the end of this story.
There are various options to post a message in Teams from a Power Automate Flow. Those options include:
- Post a message as the Flow bot to a channel (preview) action
- Post a message (V3) action
- Invoke an HTTP request using Azure AD action
- HTTP request action with Incoming Webhooks
- Some hacks…
Disclaimer: I may have missed a straightforward way to achieve all of this. Please, please let us know if there is one. It would make this blog post obsolete, but I’m more than happy to learn something new.
If you’re looking for a way to @mention Tags in Microsoft Teams, check out my other article.
All the options
Post a message as the Flow bot to a channel (preview) action
@Mention of People: ✅
@Mention of Channel: ❌
Mark message Important: ❌
This action supports @Mention for people using the <at></at>
tag. It doesn’t support mentioning a Channel, or at least I haven’t found a way to do it. Furthermore, it is important that people haven’t blocked the flow bot. Marking a message important or urgent isn’t possible either. The visual aspects aren’t good as well, because it adds this nasty signature at the end of every message.
Post a message (V3) (Preview) action
@Mention of People: ❌
@Mention of Channel: ❌
Mark message Important: ❌
This action seems to be the most straight forward one to use, but none of our requirements is supported.
Get @mention token for a user (updated 04.08.2020)
@Mention of People: ✅
@Mention of Channel: ❌
Mark message Important: ❌
There is a new kid in town: Get @mention token for a user. This operation creates a token that can be inserted into a message or adaptive card to @mention a user. It doesn’t support mentioning channels. By using it in conjunction with Adaptive Cards, e.g. through the Post your own adaptive card as the Flow bot to a channel action, we can mention a single user. Marking the message as important isn’t possible either.
Incoming Webhook and HTTP action
@Mention of People: ❌
@Mention of Channel: ❌
Mark message Important: ❌
Using incoming Webhooks for Teams is always a good option to consider. If you don’t know how to do it, here’s the documentation. Unfortunately, incoming webhooks don’t support HTML, and it only supports legacy adaptive cards (see MessageCards). None of the requirements can be fulfilled this way.
Notable Mentions
There was once a hack to achieve this with the Post a Message (V2) action, but this no longer works with V3. It might change again, and it is worth knowing about this. See the Tweet below to learn more. Again, this doesn’t work anymore.
Conclusion and Solution
Mentioning people or a channel and marking the message as urgent or important, isn’t easy and far away from being intuitive for a citizen developer (also known as the user 😉).
The only solution I’ve found that fulfills all requirements is by using the Invoke an HTTP request using Azure AD action.
Invoke an HTTP request using Azure AD action
@Mention of People: ✅
@Mention of Channel: ✅
Mark message Important: ✅
(Bonus) @Mention of Tags: ✅ (See my other article)
With this action we can call the graph message endpoint directly having full control over everything. Of course, this is a bit more advanced, but it allows us to mention people, channels, and even mark the message as important or urgent.
The sad news is that this is a premium connector, so you might need additional licensing. The good news is that you don’t need this license for all users if the flow is triggered from an external source like SharePoint list. It’s enough to have a valid license for the flow owner (connection owner).
Doing this isn’t straight forward, so here is a short guide.
Add the action HTTP with Azure AD to your flow. Enter https://graph.microsoft.com
for both fields and click Sign in.
Choose POST as the method and add Content-Type: application/json
to the list of headers.
Use the URL below and add or replace the variables accordingly:
https://graph.microsoft.com/beta/teams/@{variables('teamsId')}/channels/@{variables('channelId')}/messages
I’ve prepared a sample request body from where you can start and adopt it as needed. Just copy and paste it from the gist below.
That’s it. Let me know if you’ve found a better way to achieve all of this. I’m sure that things will change in future versions and this will be made easier.
Make it so 👉,
Sebastian