In part 4 of this series we will create a simple Power Automate Flow that posts a message to a Team when a project is overdue. For part 3 of the series, here is the link if you missed it where we looked at adding a Bot for Project for the web into Teams: https://pwmather.wordpress.com/2019/11/22/office365-projectfortheweb-microsoftteams-integration-projectmanagement-ppm-msproject-powerplatform-powervirtualagents-part-3/
This post will use Teams messages and Adaptive Cards in Teams, this will be similar to the posts I created in the summer for Project Online: https://pwmather.wordpress.com/tag/adaptive-cards/
Firstly create the Power Automate Flow to get the data, in this simple example I have a scheduled Flow that runs once a week, queries the Projects entity in the CDS with a filter as seen below to only return the projects that are not 100% complete and the Finish date is before todays date:
Then an Apply to each action is used as the List Overdue Projects is more than likely to return more than one project:
Here you can see some additional Compose actions as I calculate the days overdue and also build up a Project Link, these are used in the Post a message action. The message is switched to code view so that I could build up a HTML link. I created most of the message when in the HTML view then switched it to the code view to create the Project Link. When this runs this posts a message for each project overdue, in my example test tenant I have two test projects that are overdue:
Before we move on to the adaptive card example, I will detail the example compose actions I have:
FinDateTickValue = ticks(items(‘Apply_to_each’)[‘msdyn_finish’])
TodayTickValue = ticks(utcNow())
DateDifference = div(sub(outputs(‘TodayTickValue’),outputs(‘FinDateTickValue’)),864000000000)
ProjLink = concat(‘https://project.microsoft.com/?org=cdsOrg#/taskgrid?projectId=projectId’,items(‘Apply_to_each’)[‘msdyn_projectid’]) – cdsOrg would be updated to your correct CDS org like below:
In the next example I will use the Teams Adaptive Card action to post this message as a card rather than a standard message:
The card is authored in JSON, I used the same process here as I documented my previous posts for Project Online, no need to hand craft the JSON, use adaptive card designer here: https://adaptivecards.io/designer. Once you have the card built and designed in the designer, copy the card JSON and paste into the Flow message input:
Add the dynamic content to the JSON message as seen below to pass in the correct data based on your card design:
When this Flow runs it posts cards to the Teams channel for the overdue projects as seen below:
The cards can be made to be as engaging as you like with images, text, fonts etc. this is just a basic example for this blog post.
There are many use cases for this type of simple Project for the Web and Microsoft Teams integration using Power Automate, I will look to post some other examples in the future.