cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
gtufano
Regular Visitor

Sending a message to teams channel

Hi,

 

i am trying to create a flow to send a Message to a Teams Channel everytime I received a specific email to my inbox.

 

i want the flow to POST a message if it is the first execution of the day, and to reply to the same message if it is a next execution

 

Example:

email arrives with subject = ALERT 1

--> on teams a new post is created "ALERT 1 - 11/02/2022"

 

[...few hours later]

email arrives with subject = ALERT 1

--> on teams a reply message is created "new ALERT 1" int "ALERT 1 - 11/02/2022" post

 

thank you

1 ACCEPTED SOLUTION

Accepted Solutions
Caspar_Rubin
Solution Supplier
Solution Supplier

Hey,

 

you could do something like this:

 

Caspar_Rubin_6-1667421783184.png

 

 

Explanation - First Part:

 

As trigger you select "When a new email arrives (V3). 

Then add a Compose action to compose your message title.

For example: (the red part is an Expression)

 

ALERT 1 - formatDateTime(utcNow(),'dd/MM/yyyy')

 

Then your intitialize two new variables using the Initialize variable action.

The first one is called alreadySent, Type is Boolean and Value is the Expression false

The second one is called messageID, Type is String and leave the Value empty.

Caspar_Rubin_3-1667421547695.png

 

Then add a Get messages action to get all messages in the Channel.

 

Second Part:

 

Caspar_Rubin_4-1667421660467.png

 

Explanation - Second Part

 

 

In an Apply to each action, use the Message list Dynamic content to loop all messages.

 

Caspar_Rubin_8-1667422143638.png

 

 

You add a Condition Action to check if the Dynamic content "Message body" contains the Dynamic content Output (The Compose action from the first part of the flow...)

 

In the If yes section, you add a Set variable action, select the alreadySent variable and use the Expression true as it's value.

Add another Set variable action to set the variable messageID to the Dynamic content Message id.

 

What this basically does it loop all messages and check for "Alert 1 - TODAYsDATE" in the messages bodies. If it finds that value somewhere, it sets the alreadySent variable to true and sets the messageID variable to the message's ID.

 

Now below the Apply to each loop we simply add another Condition action, check if the variable alreadySent is equal to the Expression true

 

 

Caspar_Rubin_7-1667422095536.png

 

 

If yes - Reply to the message - using the variable messageID to target the today's message

If no - Post a new message with the Compose inside it so it can be searched for that string in the next run...

 

Let us know if this works for you - cheers,

caspar

 

View solution in original post

3 REPLIES 3
Caspar_Rubin
Solution Supplier
Solution Supplier

Hey,

 

you could do something like this:

 

Caspar_Rubin_6-1667421783184.png

 

 

Explanation - First Part:

 

As trigger you select "When a new email arrives (V3). 

Then add a Compose action to compose your message title.

For example: (the red part is an Expression)

 

ALERT 1 - formatDateTime(utcNow(),'dd/MM/yyyy')

 

Then your intitialize two new variables using the Initialize variable action.

The first one is called alreadySent, Type is Boolean and Value is the Expression false

The second one is called messageID, Type is String and leave the Value empty.

Caspar_Rubin_3-1667421547695.png

 

Then add a Get messages action to get all messages in the Channel.

 

Second Part:

 

Caspar_Rubin_4-1667421660467.png

 

Explanation - Second Part

 

 

In an Apply to each action, use the Message list Dynamic content to loop all messages.

 

Caspar_Rubin_8-1667422143638.png

 

 

You add a Condition Action to check if the Dynamic content "Message body" contains the Dynamic content Output (The Compose action from the first part of the flow...)

 

In the If yes section, you add a Set variable action, select the alreadySent variable and use the Expression true as it's value.

Add another Set variable action to set the variable messageID to the Dynamic content Message id.

 

What this basically does it loop all messages and check for "Alert 1 - TODAYsDATE" in the messages bodies. If it finds that value somewhere, it sets the alreadySent variable to true and sets the messageID variable to the message's ID.

 

Now below the Apply to each loop we simply add another Condition action, check if the variable alreadySent is equal to the Expression true

 

 

Caspar_Rubin_7-1667422095536.png

 

 

If yes - Reply to the message - using the variable messageID to target the today's message

If no - Post a new message with the Compose inside it so it can be searched for that string in the next run...

 

Let us know if this works for you - cheers,

caspar

 

gtufano
Regular Visitor

oooh WOW.

it sounds perfect.

 

let me test it, I'll send back a feedback in few days 🙂

gtufano
Regular Visitor

I finally tested it. it works great!!!

 

i added 2 steps:

- mark email es "Read"

- move it to "managed alerts" folder

 

thank you sooooo much!

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (4,942)