Coffee Watcher solution uses Canvas App to capture images and sends them to Power Automate flow for further processing. Parent flow calls object detection and then informs in Teams chat when there is fresh coffee. This post demonstrates how to post updated state of the coffee pot into a Teams channel or post with adaptive card.

Create SharePoint folder for image repository for adaptive card

Open the SharePoint site and go to the document library. Open the folder permission management

SharePoint folder permission management
SharePoint folder permission management
Go to advanced management
Go to advanced management

Stop inheriting permissions and Grant permissions for Everyone except external users so that permission looks like picture below. Make sure you have the Email users box unchecked.

Make folder content available for everyone in the tenant
Make folder content available for everyone in the tenant

Resize Image and Update Card Power Automate flow

Adaptive card could not take the picture because it exceeds the bytes limit. I need to make it smaller and be visible to everyone. I used SharePoint site under one Teams and made the library folder permissions read to whole tenant users. Using that folder I upload the picture there and use the thumbnail in that site in the adaptive card because did not want to use any 3rd party action to resize the image and move bytes aroung.

Child flow to delete and add file into SharePoint and post adaptive card to Teams
Child flow to delete and add file into SharePoint and post adaptive card to Teams

Delete file first, because we want to delete the existing picture. Ensure that Create file action is executed if the Delete file action is successful or failed. Then get file properties.

Replace picture in SharePoint folder
Replace picture in SharePoint folder

Create condition whether the adaptive card needs to be created or update. Initial value is 0000 from Power Apps. The adaptive card JSON is in the code segment below the picture.

{
    "type": "AdaptiveCard",
    "body": [
{
            "type": "TextBlock",
            "text": "Kahvipannun tilanne Turun konttorilla  @{convertFromUtc(utcNow(), 'FLE Standard Time', 'd.M.yyyy klo HH:mm')}",
            "wrap": true
        },
        {
            "type": "Image",
            "url":"@{outputs('Get_file_properties')?['body/{Thumbnail}/Large']}"
        }
    ],
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "version": "1.4"
}

Set the message id from Teams action to variable and pass it to the parent flow in response action

Other posts in this solution

Please stay tuned once I will write the rest of the blog posts

  1. Solution presentation “Is there and coffee left”
  2. Teaching custom AI model for object detection
  3. Power Apps Canvas to capture picture every minute
  4. Solution architecture and trigger errors
  5. Flows to use Object Detection and informing of fresh Coffee
  6. Adaptive card updating every minute with thumbnail picture