top of page
  • Writer's pictureStephen Port

Capturing Praise from Microsoft Teams - Updated

Updated: Feb 24, 2023

OK, so a quick update! Microsoft has changed the way this works so if you have previously implemented this approach you will need to update it. A link to the right section is here...


Did you know we have a solution for this built into Dataverse for Teams? It captures all praise from all channels and displays it in a pretty awesome dashboard. We've also extended the workflow to capture praise from any channel and 1-2-1 chats!

If you would like a demo please book a time slot using the link below!


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 and the channel. To stop the workflow from triggering for every message set the trigger conditions to only fire when a praise card is sent.

@contains(first(triggerBody()?['attachments'])?['content'],'praise')
@contains(first(triggerBody()?['attachments'])?['content'],'AdaptiveCard')


Next, add 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. 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'])

***UPDATED SECTION***

You now need to add in two compose actions.

For the first one you will need to put in the following:

outputs('AttachmentsContent')?['body'][0]

For the second,

outputs('Compose')?['items'][4]

Next, we need to extract some of this information. Add another operation below using the 'initialize variable' action.



Set the Name as PraiseMessage and Type as String. Then add the following as an expression into the Value field.

outputs('Compose_2')?['text']

You should now have something that looks like the one below.


Almost there, we now need to do some magic to ensure we can get the people praise is being sent to.

To do this, we need to add in an 'Apply to each' condition. Add a new action and then click on Control

Then click on Apply to each

In the 'Select an output from previous steps' box, you need to add the dynamic content of the Message Mentions

Next, add in a Get user profile (V2) action and in the User (UPN) field enter the following expression.

items('Apply_to_each')?['Mentioned']?['user']?['id']

Lastly, add in a Create item SharePoint action and add in the following in the fields.

SharePoint List Field

Type

Code/Info

Site Address

Selected

Select from dropdown

List Name

Selected

Select from dropdown

Title

Text

​Enter your own text

Badge

Expression


first(skip(first(outputs('AttachmentsContent')?['body'])?['items'],3))?['url']

Giver Claims

Dynamic content

From user display name

Receiver Claims

Dynamic

Mail

Praise Type

Expression


first(skip(first(outputs('AttachmentsContent')?['body'])?['items'],1))?['altText']

Date Received

Dynamic

CreatedDateTime

Praise Reason

Dynamic

​PraiseMessage

Your 'Apply to each' condition should now look like the below.

OK so we're done, Save and Test the workflow by posting a piece of Praise into the channel and you will see the praise populate into the SharePoint list for people mentioned.

You can watch the video walkthrough if you would like. Please like and subscribe to our channel for more useful tips!


3,732 views

Related Posts

See All
bottom of page