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
Solved! Go to Solution.
Hey,
you could do something like this:
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.
Then add a Get messages action to get all messages in the Channel.
Second Part:
Explanation - Second Part
In an Apply to each action, use the Message list Dynamic content to loop all messages.
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.
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
Hey,
you could do something like this:
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.
Then add a Get messages action to get all messages in the Channel.
Second Part:
Explanation - Second Part
In an Apply to each action, use the Message list Dynamic content to loop all messages.
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.
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
oooh WOW.
it sounds perfect.
let me test it, I'll send back a feedback in few days 🙂
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!
User | Count |
---|---|
94 | |
39 | |
24 | |
22 | |
16 |
User | Count |
---|---|
128 | |
49 | |
48 | |
32 | |
24 |