How to notify an alert for unresponsive channel post in Microsoft teams?
Use Case
For scenarios relying on replying to messages posted in teams channel, it becomes cumbersome to track each & every reply. Instead of spending lot of hours in monitoring the messages replies manually, we can automate this activity using standard connectors in power automate cloud flow. In this blog, I will explain the steps to send notification alert for an unresponsive channel post to the concern team after a specified period of time internal. The flow will monitor new incoming messages on teams channel & remind the team to take the necessary action if no reply is sent by 5 minutes.
Scenario
We have a MS teams channel where reply to new message needs to be responded within 5 minutes. If not responded after 5 minutes of its arrival, then a notification should be triggered on MS teams:
Solution
1. Create an automated flow & choose “When a new channel message is added” as the trigger:
2. Select the teams & channel from the respective drop down in the trigger action:
3. Next, we will add “Delay” action to pause the execution of flow. In this action, specify 5 to pause the flow for 5 minutes. You may change this value as per the requirements:
4. Post that add “Get message details” action to get the detailed properties of the message. Pass the value of message Id from the dynamic content window:
Choose ‘Channel‘ in ‘Message type’ drop down. We will extract the Teams Id & Channel Id from the output of trigger action using expressions. Expression needs to be added in the ‘Function’ window as shown below. Select ‘Enter custom value’ before entering expression in Team & Channel input parameter:
Expression used for Team parameter:
triggerOutputs()?['body/channelIdentity/teamId']
Expression used for Channel parameter:
triggerOutputs()?['body/channelIdentity/channelId']
5. After that we will add “Send a Microsoft Graph HTTP request” action to verify the replies for a message. We will query for the replies using graph API:
https://graph.microsoft.com/v1.0/teams/@{outputs('Get_message_details')?['body/teamId']}/channels/@{outputs('Get_message_details')?['body/channelId']}/messages/@{outputs('Get_message_details')?['body/id']}/replies
PS: Just copy & paste the above URI in the action:
6. Now, we will check if a message is responded using “Condition” action. We can get the count of replies from the output body of “Send a Microsoft Graph HTTP request” action by using an expression. Expression needs to be added in the ‘Function’ window:
body('Send_a_Microsoft_Graph_HTTP_request')?['@odata.count']
Choose ‘is equal to’ as the operator & enter numeric 0 in the right operand as shown below:
7. Lastly, add “Reply with a message in a channel” action in the true branch to send reminder for unresponsive post. Choose ‘Channel‘ in ‘Post in’ parameter. Dynamically pass the message id from the output of “Get message details” action:
Similarly, pass the value of Team Id & Channel Id from the dynamic content window. You need to select ‘Enter custom value’ before setting the Team Id & Channel Id in input parameters:
Enter the reminder text in the message body as per the requirements:
Save the flow & post some messages on teams to test it.
Output
A new message is posted to team channel:
Successfully reminder sent to teams channel for taking action:
Conclusion
Following are the takeaways:
- We can automate the activity of monitoring replies for team messages using automate flow with standard teams connector & actions
- Object Properties value can be extracted using expressions
- Using standard action “Send a Microsoft Graph HTTP request“, we can query graph API to find the responses or replies of a teams message
Mohammed
This is a great use-case, thanks Manish. For PM’s managing projects and have a Teams space this can be very beneficial. Will the notification from the Workflow app also be considered a new channel message and will the flow be re-triggered?
Manish Solanki
Hi Mohammed,
Thank you! I am glad that you found it useful. You have highlighted a good use case to implement this flow for project management. Thanks again for that 🙂
Yes, flow should trigger if a new message is posted in teams channel by workflow bot. But the flow will not trigger for replies of messages.
Thank you!
Marisa
Hi Manish,
thanks for your great help!
It´s working properly! Is there also a possibility in step “Enter the reminder text in the message body as per the requirements:”, to mention the channel, here: eg: “@Demo” ?
Regards, Marisa