Search code examples
microsoft-teamsazure-logic-appspower-automateadaptive-cards

Issue with Stopping Power Automate Flow with Combined "Post Adaptive Card and Wait for a Response" Action


I am facing a challenge with Microsoft Power Automate with the usage of the "Post Adaptive Card and Wait for a Response" action within Microsoft Teams.

We have implemented Power Automate to automate a critical process within Microsoft Teams. The automation flow involves sending an adaptive card and Wait for a Response action inside a chat group to gather input from the group members. This process is embedded within a loop "Apply to each" that allows us to retrieve multiple responses from different members of the group.

While this setup has proven effective in facilitating communication and data collection, we have encountered an issue related to stopping the flow when needed. Once the adaptive card is posted and the Wait for a Response action is triggered, we have not been able to find a reliable way to terminate the flow under certain circumstances.

Our primary concern is that during holidays and weekends, when group members may not be available to respond, the flow continues to run indefinitely. Consequently, this leads to numerous flow instances being active without receiving the required responses, leading to inefficiencies and resource utilization concerns.

We have attempted various approaches, including setting multiple conditions before and after the "Post Adaptive Card and Wait for a Response" action to manage the flow execution. Unfortunately, it appears that the action itself imposes limitations on the flow's termination process.

How we can address this situation effectively? Our goal is to ensure that the flow can be stopped gracefully, regardless of whether a response is received for the adaptive card.

I am using Schedule trigger flow, its run every day at a specific time.

Are there alternative methods or best practices available to handle this scenario?

I tried to Create another flow that would terminate that flow, but I didn't find a way to so so.

I used Terminate action but its not reached once the post adaptive card is sent to the group!


Solution

  • Without seeing the full extent of your flow, there is a way to make the step continue after a period of inactivity. This basic flow shows you what to do ...

    Flow

    There are two thing you need to do to make this work ...

    1. Configure the timeout of the adaptive card action.

    Settings

    For the benefit of testing, I made the time out a mere 5 seconds.

    Timeout

    1. Configure the run after settings for the subsequent step.

    Run After

    Once the timeout occurs, this setting will ensure that the next step runs and does whatever it is you need it to do.

    Result

    Result

    Caveats

    There are a couple things that need consideration here.

    1. When a timeout occurs, you're unable to access all of the data that was supplied by the response of the original webhook. The step is essentially dead and of no use to you whatsoever. That will leave the adaptive card sitting there idle and unable to be actioned, it's essentially orphaned.
    2. To overcome the short comings of the first point, you can get a list of messages from the relevant channel and then use the Update an adaptive card in a chat or channel to essentially cancel the orphaned card and update it with a card that explains how the previous card timed out. To do this though, you'll need to work out which cards are orphaned. My suggestion would be to bake a hidden element into the card which can then be searched for/filtered in from the list of messages returned and then only deal with and update those.