Power Platform : Get an Instant Email alerts with Direct link on Power Automate Flow Fails.

.
“Try a little harder to be a little better.”
.
Hello Everyone,
Hope you all are doing well.
Today in this article I am going to discuss about how to get email alerts on Power Automate flow fails.
Also we have good number of articles on Power Platform, please have a look.
https://knowledge-junction.in/category/technology-articles/power-platform/
So without getting late, lets get started.
Background
In one of our project requirement is get the flow failed alert asap if Power Automate flow failed, without wait a week for it to send a report message or check daily the flow run history. By using these steps we can get instant email alert whenever the flow fails.
Introduction
Power Automate:
Power Automate is a service that helps us create automated workflows between our favorite apps and services to synchronize files, get notifications, collect data, and more.
- Automate business processes
- Send automatic reminders for past due tasks
- Move business data between systems on a schedule
- Connect to more than 500 data sources or any publicly available API
- We can even automate tasks on our local computer like computing data in Excel.
Instant Flow:
Instant Flows allow us to start a flow with a click of a button, and can be used across desktop or mobile devices. They are commonly used to automate a wide range of tasks such as requesting an approval in Teams or SharePoint or sending a reminder to the team with a push of a button from mobile.
High Level Steps:
Create instant flow in Power Automate.
Add Steps: Choose an operations and actions.
Use Scope action after end of the flow.
Add actions inside the Scope to get flow failure notifications.
Detailed Steps:
- Go to office.com, and sign in to our M365 account – https://www.office.com/?auth=2
- Launch Power Automate from Office365 app launcher.

- In Power Automate Click on Create and select Instant Cloud flow.

- Give the Flow name and Choose Trigger and then click on Create.

- Add our flow actions and conditions.

- To get email alerts with direct links to the flow run any time our flow fails by adding this set of actions to the end of our flow.
- Now add a Scope control.

- Click on more options (…) of scope and select Configure run after.

- Choose the run after options as per our requirement (successful/failed/skipped/timeout).
- In our prospect we select failed and timeout as shown below.

- Next we are going to get the link of the failed flow.
- For that add a action compose and the below code as compose input in Expressions.
concat('https://india.flow.microsoft.com/manage/environments/', workflow()?['tags']?['environmentName'], '/flows/', workflow()?['name'], '/runs/', workflow()?['run']['name'])

- We can send the email alert to either user or owner.
- If we want to send the alert to owner only. Then we can give the particular email address in the send mail action.
- If we want to send the alert to user, we need to get the user.
- So add get my profile action here.

Now add send an email action and give the details.

At last add the action Terminate to stop the flow once complete.

- Once all the steps added rename the steps as per our requirement.
- Complete set of Scope steps.

- Whenever our flow fails, we receive the mail like below.
- By click on Flow Run Link in mail, will redirect to the failed flow.

Direct Code for Scope Steps
- We have the direct steps for the total steps of Scope control.
- Either download the template attached to this post & copy the Scope in the template, or copy the Scope action’s code, navigate to the My clipboard tab on a new action and press Cntrl + V to get this Scope as a new action option.
Scope Code to Copy & Paste into our Flow
{"id":"fd3dfdb1-5fc7-4bb4-b830-978bffcb68b9","brandColor":"#8C3900","connectionReferences":{"shared_office365users":{"connection":{"id":"/providers/Microsoft.PowerApps/apis/shared_office365users/connections/4492902ae6154e088865fbb98252807a"}},"shared_office365":{"connection":{"id":"/providers/Microsoft.PowerApps/apis/shared_office365/connections/shared-office365-02d46624-0d5c-40fe-89f0-c5df-8c7ffde7"}}},"connectorDisplayName":"Control","icon":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHZlcnNpb249IjEuMSIgdmlld0JveD0iMCAwIDMyIDMyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPg0KIDxwYXRoIGQ9Im0wIDBoMzJ2MzJoLTMyeiIgZmlsbD0iIzhDMzkwMCIvPg0KIDxwYXRoIGQ9Im04IDEwaDE2djEyaC0xNnptMTUgMTF2LTEwaC0xNHYxMHptLTItOHY2aC0xMHYtNnptLTEgNXYtNGgtOHY0eiIgZmlsbD0iI2ZmZiIvPg0KPC9zdmc+DQo=","isTrigger":false,"operationName":"Scope_Failure_Notifications","operationDefinition":{"type":"Scope","actions":{"Compose_Flow_run_link":{"type":"Compose","inputs":"@concat('https://us.flow.microsoft.com/manage/environments/', workflow()?['tags']?['environmentName'], '/flows/', workflow()?['name'], '/runs/', workflow()?['run']['name'])","runAfter":{},"metadata":{"operationMetadataId":"304e2c8e-c6d8-4bd0-ac4d-57951dd57763"}},"Get_my_profile_(V2)":{"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_office365users","operationId":"MyProfile_V2","apiId":"/providers/Microsoft.PowerApps/apis/shared_office365users"},"parameters":{},"authentication":{"type":"Raw","value":"@json(decodeBase64(triggerOutputs().headers['X-MS-APIM-Tokens']))['$ConnectionKey']"}},"runAfter":{"Compose_Flow_run_link":["Succeeded"]},"metadata":{"operationMetadataId":"16453b92-e67e-40aa-acf4-fbd90183a4f0"}},"Send_an_email_(V2)_Failure_notification":{"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_office365","operationId":"SendEmailV2","apiId":"/providers/Microsoft.PowerApps/apis/shared_office365"},"parameters":{"emailMessage/To":"@outputs('Get_my_profile_(V2)')?['body/mail']","emailMessage/Subject":"Your @{workflow()?['tags']?['flowDisplayName']} flow failed","emailMessage/Body":"<p>Check your flow.<br>\n<br>\n<a href=\"@{outputs('Compose_Flow_run_link')}\">Flow Run Link</a> </p>"},"authentication":{"type":"Raw","value":"@json(decodeBase64(triggerOutputs().headers['X-MS-APIM-Tokens']))['$ConnectionKey']"}},"runAfter":{"Get_my_profile_(V2)":["Succeeded"]},"metadata":{"operationMetadataId":"bd4b39c2-3462-4a00-b21d-d8ac056f00d2"}},"Terminate_Mark_flow_run_failure":{"metadata":{"operationMetadataId":"c3050a38-c258-4145-b3fa-4d5e80d70b67"},"type":"Terminate","inputs":{"runStatus":"Failed"},"runAfter":{"Send_an_email_(V2)_Failure_notification":["Succeeded"]}}},"runAfter":{"Compose_(All_Your_Flow_Actions_Here)":["Failed","Skipped","TimedOut"]},"description":"Set this Scope's Configure run after settings to \"has failed\", \"is skipped\", and \"has timed out\".","metadata":{"operationMetadataId":"072e1b99-2b98-4cdc-bb50-f9ef10d9a137"}}}
- We get the steps in our clipboard.

- We got the Scope actions below our flow directly.

.
Hope this article will help us to get instant email alert on flow failure in Power Automate.
Also get my article updates on my social media handles.
LinkedIn – https://www.linkedin.com/in/khasim-shaik-8784a1232/
Twitter – https://twitter.com/KhasimShaik2009
Facebook – https://www.facebook.com/profile.php?id=100078255554660
Thank you for your support, will catch up with new article soon.
Keep learning and keep smiling.
Have a great day.
Thanks.
Thanks for sharing this article, good one!
Keep it up Khasim!!