In this tutorial, I will explain how to send a message when a new post is added in Microsoft Teams team channel in Power Automate.
Here, I will cover a couple of scenarios like:
- Power Automate send an email to the team owner
- Post a message in the chat of all the Channel members, excluding the author of the post in Power Automate
Dive in to know more!
Send a Message When a New Post is added in Microsoft Teams Team Channel in Power Automate
To send a notification to Microsoft Teams team owners when a post is added to the team channel, follow the example below:
Example:
Requirement | Action |
When a new message is added to the Microsoft Teams team Channel. | Send an email to all the team owners. |
Follow the below-mentioned steps:
1. Open the Power Automate Home page, click + Create, and select ‘Automated cloud flow‘. In the next window, select the ‘When a new channel message is added‘ trigger, provide a flow name, and click the Create button.
Inside the trigger, add the below-mentioned parameters:
- Team: Choose a team from the drop-down.
- Channel: Select a specific channel under the team from the drop-down.
2. To get the details of the Microsoft Teams channel message, add a ‘Get message details‘ flow action.
Configure the below parameters:
- Message: Select Message id from the dynamic content.
- Message Type: Choose type as Channel from the drop-down options.
- Team: Select a particular team.
- Channel: Choose the specific channel from the drop-down.
In Power Automate, you can easily get the team members with the flow actions, but there is no action for owners.
To get the Microsoft team owners, we should call the Graph API.
3. Here, add the ‘Send an HTTP request V2‘ flow action from the Office 365 groups connector.
Provide the below details:
URI: https://graph.microsoft.com/v1.0/groups/@{body('Get_message_details')?['teamId']}/owners
Method: GET
In the URI, select the team id from Get message details of dynamic content.
4. To extract the owners from the previous action, take a ‘Select’ flow action.
Ensure to provide the below details:
From: @{body('Send_an_HTTP_request_V2')?['value']}
Map: @{item()?['mail']}
This will give an array of the email addresses of the owners of this specific Microsoft Teams team group.
4. Then, take a ‘Send an email(V2)‘ flow action. Fill in the required parameters:
- To: Provide the below-given expression.
- Subject: Enter a subject line for a mail.
- Body: Provide a detailed description of the mail.
Expression: join(body('Select'), ';')
5. Now the Power Automate flow is ready, save and run the flow manually.
6. Go back to the Microsoft Teams team channel and post a message in the channel as shown below:
7. If there is no error, the flow runs successfully and sends an email to all the team owners about the details of the post.
This way, we can create a Power Automate flow to send a notification when a new message is added to the Microsoft Teams team channel.
Power Automate Post message in a Chat When a Channel message is Added
Now, I will explain how to use Power Automate to notify all the team channel members in Microsoft Teams, excluding the message author.
Go through the below-mentioned steps:
1. Create a Power Automate ‘Automated cloud flow’ with ‘When a new channel message is added trigger.
2. In the next step, get the message details from the ‘Get message details‘ flow action.
3. To get the members of a Microsoft Teams team, use the ‘List group members’ flow action.
Provide the below parameter:
Group ID: Take team ID from the dynamic content to get message details.
The List group members flow action will retrieve all the members of a team. So, we wanted to extract the members, excluding the message author who is posting in the team channel of Microsoft Teams.
4. Here, take a ‘Filter array‘ flow action and provide the below-given parameters in it.
- From: Take dynamic content of body/ value from the list of group members.
- Filter Query: Insert the expression placed in the below code.
@not(equals(@{item()?['id']},@{outputs('Get_message_details')?['body/from/user/id']}))
This expression will filter out the members, excluding who is adding a message in team channel of Microsoft Teams.
5. Finally, add the ‘Post a message in chat or channel‘ flow action. Ensure to give the below parameters:
- Post as: Choose according to your requirement from the drop-down.
- Post In: Select the Chat with Flow bot option from the options drop-down.
- Recipient: Take ‘Mail’ from the dynamic content of the filter array. Make sure to place the semicolon(;).
- Message: Type the message body that you need to send.
For each loop will be added automatically, taking Body as an output from the filter array flow action.
6. Now, save the flow and run it manually.
7. To test the flow, post a message in the team channel of Microsoft Teams as shown below:
8. When the flow runs successfully, it will send a chat message to all the channel members, excluding the message author who is posting in the team channel.
This is how to send a notification to all the team channel members of the Microsoft team using Power Automate
Conclusion
I trust this Power Automate tutorial gave you the idea of how to notify when a new post is added to the Microsoft Teams team channel. It will be helpful and understanding.
Here, I have covered the following topics with Power Automate:
- How to notify the team owner whenever someone sends a post in the Microsoft Teams team channel using Power Automate
- Power Automate send a notification to all the team members when a post is done in the team channel of Microsoft Teams
Also, you may like:
- How to Send Teams Messages using Power Automate
- Post Image to Microsoft Teams Channel Using Power Automate
- Send Birthday Email using Power Automate
- Schedule Meetings in Microsoft Teams using Power Automate
- Power Automate Switch Case
After working for more than 15 years in Microsoft technologies like SharePoint, Office 365, and Power Platform (Power Apps, Power Automate, and Power BI), I thought will share my SharePoint expertise knowledge with the world. Our audiences are from the United States, Canada, the United Kingdom, Australia, New Zealand, etc. For my expertise knowledge and SharePoint tutorials, Microsoft has been awarded a Microsoft SharePoint MVP (9 times). I have also worked in companies like HP, TCS, KPIT, etc.