recommendation email notification
Power Automate
Manish Solanki  

How to send real time notification for desktop flow recommendations in unattended run scenarios?

Use Case

Microsoft recently introduced a very useful CoPilot feature to give recommendation to users for repairing & fixing error related to missing of UI elements in automation during run time. However, it does not provide real time notification to flow owners or admin or operation team to act swiftly.

  • As each recommendation has expiry datetime stamp, so it is impractical for the users to continuously track recommendation from “Automation Center” page.
  • Moreover, it becomes very difficult for users to remember schedule for every cloud flow that triggers Power Automate Desktop flow & be available to monitor recommendations at those given slots or duration.
  • There are chances that users may miss taking action on those recommendations and flow ends up in an error due to time out period (after expiry datetime).

Considering these challenges in mind, Personally I strongly felt the need for real time notification mechanism for desktop flow runs recommendation.

Solution

After deep diving into recommendation feature, I found that all recommendations are stored in ‘Flow Event‘ table. So, to receive real time notification we will design an “automated” cloud flow that triggers an email notification to flow owners with a hyperlink. The link will directly take users to recommendation section in “Automation Center” UI page and they can take the necessary action as on recommendation the moment it arrives.

Here are the steps to create an automated flow:

1. Create an automated cloud flow and choose “When a row is added, modified or deleted” as its trigger:

2. Create a new connection if required or reuse the existing dataverse connection. Set the input parameters as shown in the below screenshot. As we are only interested in sending notification for recommendations concerning desktop flows so we will use ‘Filter rows’ parameter so that flow will not trigger for any other recommendations:

parentobjectlogicalname eq 'flowsession'

3. Add “Get row by Id” action to fetch the run details for a desktop flow. Let’s rename this action as ‘Get flowsession row by ID’. Select the ‘Flow Sessions’ from table name drop down. From dynamic content window, pass the value of ‘Parent Object’ from the output of trigger action in ‘Row ID’ input parameter:

4. Add a compose action to get the workflow objects using an expression. Rename this action as ‘Workflow’. Using workflow object, we will fetch Id of the flow and environment. The environment Id will be used in following actions to get owners of flows and to create a direct link for flow recommendations. Expression needs to be added in the ‘Function’ window as shown below

workflow()

5. After that add “List Flow Owners” to get the owners of the cloud flow. Enter expression in both parameters to set the environment & flow Id from the output of workflow compose action:

Expression used in ‘Environment’ parameter:

outputs('Workflow')?['tags']?['environmentName']

Similarly, enter expression for ‘Flow’ input parameter:

6. Post that add “Filter array” action to filter the records for user types from the list of flow owners. Pass the value of body object from the output of previous action dynamically in ‘From’ parameter:

In filter query, pass the ‘Type’ property from the output of “List Flow Owners” action on left side of equals to operation.

Enter plain text as ‘User’ on the right side:

7. “List Flow Owners” does not return email addresses of the owners but returns the user ID so we need to iterate those Ids and get the email address. For that, add “Get user profile” action, that returns an email address of the user from its Id. Pass the user Id from the output of filter array action. The flow will automatically add “Apply to each” action as flows owners can be multiple and are stored as an array:

Just below “Get user profile” action withing “For each” block, add another compose action to collect the email address from the output of “Get user profile” action. From dynamic window, pass the ‘Mail’ property from the output of previous action:

**This is the last action in “For each” block**

8. To get the flow name and other details, add “Get a row by ID” action. Rename this action as ‘Get process row by ID’. Choose ‘Processes’ from the table name drop down. In ‘Row Id’ parameter, pass the value of regrading object (lookup column) from the flow session record:

*Note: This action should be added outside the “For each” action block.*

9. Finally, add “Send an email” action to notify flow owners about recommendations. Click ‘Switch to advanced mode’ and enter the below expression in ‘To’ parameter:

join(outputs('Compose_1'),';')

In subject, we will pass the notification level from the output of trigger action along with name of the flow from the output of “Get process row by Id” action:

@{triggerOutputs()?['body/level']} notification for @{outputs('Get_process_row_by_ID')?['body/name']} flow

*Just copy & paste the above code in the subject parameter*

To set text in email body, click ‘Toggle code view’ button:

Just copy & paste the below code in the body parameter:

<p class="editor-paragraph">Hi,</p><br><p class="editor-paragraph">Please take necessary action. This request will expired by @{convertFromUtc(triggerOutputs()?['body/expirydate'],'India Standard Time','MM/dd/yyyy hh:mm:ss tt')}<br><a href="https://make.powerautomate.com/environments/@{outputs('Workflow')?['tags']?['environmentName']}/monitor/automations/overview?openRecommendationSection=true" class="editor-link">Automation Center</a><br><br><br></p><br>

**You may adjust the time zone as per your requirement in the above expression**

Save the flow to test it.

Output

When a schedule cloud flow that runs desktop flow in unattended mode run failed. It waited for recommendation action to complete:

Automated flow trigger email notification to flow owners to take necessary action on recommendation. It specifies the direct link of action page along with expiry date time stamp of the recommended activity:

When user click the hyperlink in email body, it takes user directly to the recommendation:

Conclusion

Following are the takeaways:-

  • Using automated cloud flow we can trigger real time notification to users to take necessary actions based on the recommendations.
  • This will reduce the stress on users to keep monitoring recommendation activities as they expired in some time duration.
  • Setting up notification reduces the chances to miss taking a recommended action by users.
  • Flow Event‘ entity stores all the recommendations that require user action during flow execution.
  • We can leverage power automate connector to get the owners of a flow.
  • Expressions can be used for getting the properties values from an object.

2 thoughts on “How to send real time notification for desktop flow recommendations in unattended run scenarios?

  1. Kanna Krishnan

    “Creating Tickets for Azure AD Risky Users With Power Automate”
    Can You put the blog and explained In Detailed Step by Step

    1. Manish Solanki

      Hi,

      Can you please explain more on this topic? What do you mean by risky AD users and where you want the ticket to be created?

      Thank you!

Leave A Comment