This would be my approach, at first I thought it would be quite complex, but you can get it done quite easily:
https://ibb.co/dcsgq3q

Explanation:
- Get messages
- Go into an apply each loop for each message.
- The reactions array associated with each message is filtered to match every type of reaction.
- A compose action outputs the message ID along with the length of each reaction array (the count of each reaction type).
- The final array of results is produced outside of the apply-each loop.
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.