• Stephen Port

Capturing Praise from Microsoft Teams

Updated: Aug 19

Praise in teams is a great way to show your colleagues that they are appreciated. But what happens if you want to capture that praise, say maybe for gamification, team building or to use in a PowerApp? Well, the below solution will show you how to do this in an easy step by step approach.


Create a list to store the results

First, you will need to create a SharePoint list to capture the data we're going to be getting. The list will need to be on a SharePoint Team's site, ideally, the one associated with where you are capturing praise from.


Call the list Team Praise or another similar name. The list will need to have the following fields.

Column Name

Field Type

Column Formatting

Title

Single line of text

None

Badge

Single line of text


{   "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",   "elmType": "img",   "style": {     "width": "100px"   },   "attributes": {     "src": "@currentField"   } }


Giver

People Picker

None

Recipient

People Picker

None

Praise Type

Single line of text

None

Date Received

Single line of text

None

Reason

Single line of text

None

If you are not sure how to format the list column then you can do so using the below example.


Build the Workflow

We now need to build the workflow to capture praise.

Go to flow.microsoft.com and select Create > Automated cloud flow

Give the workflow a name such as 'Capture Praise' and set the workflow trigger to 'When a new channel message is added'

In the workflow builder screen, select your team where praise will be posted to and the channel. Next, add in the action Get message details.


The message should be the 'Message id' from the dynamic content selector as shown below.


When a Teams Praise post is sent in Teams, it is sent as an adaptive card. The main detail of this card contains a rather horrible looking string that you will need to convert into JSON so that you can grab the attributes. The below is an example of what you need to tidy up!

"content": "{\r\n  \"type\": \"AdaptiveCard\",\r\n  \"body\": [\r\n    {\r\n      \"items\": [\r\n        {\r\n          \"horizontalAlignment\": \"center\",\r\n          \"isSubtle\": true,\r\n          \"text\": \"Stephen Port sent praise to\",\r\n          \"wrap\": true,\r\n          \"type\": \"TextBlock\"\r\n        },\r\n        {\r\n          \"horizontalAlignment\": \"center\",\r\n          \"size\": \"large\",\r\n          \"text\": \"Daniel Fowle, Jack Wilson\",\r\n          \"weight\": \"bolder\",\r\n          \"wrap\": true,\r\n          \"type\": \"TextBlock\"\r\n        },\r\n        {\r\n          \"altText\": \"Thank you\",\r\n          \"horizontalAlignment\": \"center\",\r\n          \"url\": \"https://statics.retailservices.teams.cdn.office.net/ui/static/praise/master/all/assets/badgesV2/en-GB/ThankYouBadge.65a93bb5ed.png\",\r\n          \"width\": \"124px\",\r\n          \"height\": \"auto\",\r\n          \"spacing\": \"medium\",\r\n          \"type\": \"Image\"\r\n        },\r\n        {\r\n          \"horizontalAlignment\": \"center\",\r\n          \"size\": \"large\",\r\n          \"text\": \"Thanks you for helping with the webinar\",\r\n          \"wrap\": true,\r\n          \"spacing\": \"medium\",\r\n          \"type\": \"TextBlock\"\r\n        }\r\n      ],\r\n      \"type\": \"Container\"\r\n    }\r\n  ],\r\n  \"$schema\": \"https://adaptivecards.io/schemas/adaptive-card.json\",\r\n  \"version\": \"1.1\"\r\n}"

We can do this quite easily with Power Automate by adding a Compose operation as the next step.

In the Inputs enter the following as an expression and click on Update

json(first(triggerBody()?['attachments'])?['content'])