Hello!
I am not sure if anyone has done this but we are looking to run a flow every day to retrieve the reactions from messages posted 14 days ago. We have allowed the post to be live for 14 days to ensure we allow users time to read and react to a post.
From previous flows I can filter the "Get messages" action to only show messages posted 14 days ago however, I am stuck trying to get total the "Message reactions" to show something like the below in a SharePoint list:
Message ID | like | heart | laugh | surprised | sad | angry |
486565156156 | 5 | 5 | 1 | 1 | 0 | 0 |
516168464644 | 2 | 5 | 0 | 3 | 0 | 0 |
618468464868 | 1 | 6 | 0 | 2 | 0 | 0 |
I believe I need to group the reactions by the "reactionType" then total the amount? Or potentially filter each message to just show where 'like' was used then do a length() to get the number of items and repeat that step for the other 5 reactions.
Unsure of the best way to do it so looking for guidance on how best to set this up 🙂
Solved! Go to Solution.
This would be my approach, at first I thought it would be quite complex, but you can get it done quite easily:
Explanation:
Results look like this:
[
{
"messageID": "1612948631606",
"like": "4",
"heart": "0",
"laugh": "0",
"surprised": "2",
"sad": "0",
"angry": "1"
},
{
"messageID": "1612948620934",
"like": "0",
"heart": "0",
"laugh": "2",
"surprised": "1",
"sad": "0",
"angry": "0"
},
{
"messageID": "1612948608713",
"like": "6",
"heart": "4",
"laugh": "0",
"surprised": "0",
"sad": "0",
"angry": "0"
}
]
What is nice about this solution is that because no variables are being used. You can change the concurrency control on the apply-each loop to make it run much faster.
The code in the messageReaction compose action is:
{
"messageID": "@{items('Apply_to_each')?['id']}",
"like": "@{length(body('filterLike'))}",
"heart": "@{length(body('filterHeart'))}",
"laugh": "@{length(body('filterLaugh'))}",
"surprised": "@{length(body('filterSurprised'))}",
"sad": "@{length(body('filterSad'))}",
"angry": "@{length(body('filterAngry'))}"
}
I've exported the flow and uploaded to my blog so you can download and change to your requirement.
https://www.tachytelic.net/wp-content/uploads/TeamsReactions_20210210094805.zip
Hopefully the output should make it easy for you to load directly into your SharePoint list.
Hello @burgett94 ,
I'd do it probably the brute force way. 🙂
Initialize 6 integer variables for each of the reactions and set them to 0, then loop through the messages and for each message loop through the reactions.
Inside the reactions loop, a Switch based on the reactionType that would increment the corresponding variable, e.g. reactionType = like -> increment variable with likes.
At the end of the reactions loop each variable will contain a number that you can update in the SharePoint list for the message ID. Then set the variables back to 0, and repeat with the next message.
This would be my approach, at first I thought it would be quite complex, but you can get it done quite easily:
Explanation:
Results look like this:
[
{
"messageID": "1612948631606",
"like": "4",
"heart": "0",
"laugh": "0",
"surprised": "2",
"sad": "0",
"angry": "1"
},
{
"messageID": "1612948620934",
"like": "0",
"heart": "0",
"laugh": "2",
"surprised": "1",
"sad": "0",
"angry": "0"
},
{
"messageID": "1612948608713",
"like": "6",
"heart": "4",
"laugh": "0",
"surprised": "0",
"sad": "0",
"angry": "0"
}
]
What is nice about this solution is that because no variables are being used. You can change the concurrency control on the apply-each loop to make it run much faster.
The code in the messageReaction compose action is:
{
"messageID": "@{items('Apply_to_each')?['id']}",
"like": "@{length(body('filterLike'))}",
"heart": "@{length(body('filterHeart'))}",
"laugh": "@{length(body('filterLaugh'))}",
"surprised": "@{length(body('filterSurprised'))}",
"sad": "@{length(body('filterSad'))}",
"angry": "@{length(body('filterAngry'))}"
}
I've exported the flow and uploaded to my blog so you can download and change to your requirement.
https://www.tachytelic.net/wp-content/uploads/TeamsReactions_20210210094805.zip
Hopefully the output should make it easy for you to load directly into your SharePoint list.
Learn to digitize and optimize business processes and connect all your applications to share data in real time.
Read the latest about new experiences and capabilities in the Power Automate product blog.
User | Count |
---|---|
25 | |
25 | |
25 | |
22 | |
14 |
User | Count |
---|---|
51 | |
40 | |
35 | |
31 | |
30 |