Coffee Watcher solution uses Canvas App to capture images and sends them to Power Automate flow for further processing. When calling flow from app there needs to be connection references setup properly to get the flow trigger working. Sometimes the trigger just don’t work. There could be obvious reason or sometimes it just does not work and gives no error message.

I built the first workflow for sending the picture from Canvas App to Power Automate flow. It worked well, but when I added Teams action the flow started giving me error.

Trigger error in flow summary page
Trigger error in flow summary page was either Network error or BadRequest
Error when triggering flow from app
Error when triggering flow from app

I checked the trigger and fixed the error. I did not get error message anymore, but the Power Automate flow did not trigger at all. I was thinking maybe the error is in the run-only settings and set them to use my account – in production you should use the service account which runs the flow and calls the object detection in AI hub.

Setting up run-only user for Power Automate flow
Setting up run-only user for Power Automate flow

Still I got the error. I was searching internet for solution but I could not get proper error message. I refreshed the Power Automate flow to get all working normally. I was checking that I run the app with account that has permission for Teams and object detection. Still I could not get the flow trigger neither in app in my mobile nor in the maker portal edit view Play mode.

Refresh Power Automate properties and connection references in calling Canvas App
Refresh Power Automate properties and connection references in calling Canvas App

I started to use jump flows meaning breaking the Power Automate flow in one parent flow which were calling child flows inside it. I setup the child flows run-only users and tackled most of the situations with trigger errors.

But still continuous Timer count down did not trigger the Power Automate flows and did not give any error

I went my solution over and over again. Re-created Power Automate flows one by one and then realized that when I call the flow for the first time and if it runs into error, it will save the global variables in error state. I needed these variables for updating the same adaptive card when the first card was created instead of creating a new post every minute. And as well have the knowledge was the coffee pot already full when getting the first full object detection, so that we inform the Teams chat only once when the coffee pot was not full and first time is full.

Global variables with proper values
Global variables with proper values

When the Canvas App tried to call Power Automate flow with erroneous values passing them as parameters to the flow, the flow did not trigger, the Canvas App did not give error message nor the Power Automate flow gave any indication that the call was not successfully done.

I fixed this issue by adding try-catch statement in the Canvas App code which were calling my main Power Automate flow. If the flow returns error, it will set the variables with initial values instead of the erroneous values which will fail the next call of the flow one timer starts again.

Try-catch statement in Canvas App when calling Power Automate flow fails
Try-catch statement in Canvas App when calling Power Automate flow fails

Another issue was also that if the picture was not ready in mobile app, it tried to send null valued picture which also crashed the solution. I added nullcheck in the Canvas App Code, so that it does not even execute the call if there is not picture file to be sent.

Nullcheck for image variable in Canvas App
Nullcheck for image variable in Canvas App

Other posts in this solution

  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