Mention a channel with Flow
Twitter is always great for the latest information on the Microsoft stack. But it is also great for inspiration from the community. Lately I have been following John Liu his Flow hacks. His tweet inspired me to create an at mention channel Flow example.
What the hack?
One of the things which was challenging in Flow was the use of the Microsoft Teams post message action. I have been struggling with this action to use for more advanced things like at-mentioning.
And then I saw this tweet from John:
at-mentions isn’t possible with the current post message, but can be done since the update to MSGraph API (ex 2) https://t.co/St6VzxgHtt
call this with HTTP with AzureAD premium action pic.twitter.com/VGNTn3zCzj
— John Liu ? (@johnnliu) May 10, 2019
My first attempt was of course to test his solution, which worked great. After that I wanted to try something different. I created a Flow which at-mentions the whole channel.
The Flow will use a manual trigger. After that the Flow initializes three variables.
Just like in John his example I am using the Invoke an HTTP request.
First make sure that you the Invoke an HTTP request action connection is using https://graph.microsoft.com as the Base Resource URL and Azure AD Resource URI values like in the screenshot below.
After you have done that you can use the ChannelPostUrl variable for the URL of the request and the code snippet below for the body.
Update 28-06-20: The following code snippet, has a small quote typo. The code widget I am using in this blog adds additional quotes. For some reason it has to many quotes to the channel id reference in the
Update 25-06-21: The following code snippet was invalid since a couple of days. pchaturvedi85 made me aware of that on GitHub.
Update 19-09-21: Thanks to Vlad and Josh for pointing out I accidently removed the conversationIdentityType property. Updated the codesnippet again.
Mark as important
While testing with the body of this request I was wondering if I could also make a message important. I know it is not directly related but it has a similar markup style in Microsoft Teams.
It is very easy. Just set the importance attribute to high.