Power Automate: send a notification by email when a flow fails

When a flow fails, I want to receive straight away an email to notify me so I can take appropriate actions immediately. Let’s say I have this flow:

power automate

So I want an email to be sent when “run script” or “run script 1” will fail, for that, I will have to use the “run after” option. First, I will add the “send an email” action:

power automate

In its “settings”, I will find the “run after” option:

power automate

By clicking on “select actions”, I will add the “run script” action:

power automate power automate

I will configure them like that:

power automate

My final flow:

power automate

NOTE: just above the “send an email” action, there are some coloured dots corresponding to the “run after” configuration

I will explain the logic behind. The condition between the scripts is AND not OR meaning that in order to trigger the notification, I need that in the email, each script meets the correct result so:

  • To send an email when the first script fails, the result of “run script” is “failed” AND “run script 1” is “skipped”
  • To send an email when the second script fails, the result of “run script” is “successful” AND “run script 1” is “failed”

With this configuration, I will not know which script has failed. To remediate, put a “send an email” action after each script:

power automate

For each email, configure like that and for “run script 1” like that:

email configuration run script 1 configuration
power automate power automate

NOTE: don’t forget to put in the “title” and/or in the “description” of the email, the name of the script

The logic for this configuration is the following:

  • To send an email when the first script fails, the result of “run script” is “failed”
  • To send an email when the second script fails, the result of “send an email (V2)” is “skipped” and “run script 1” is “failed”

To know more about the “run after” option, read Power Automate: run the flow even if an action fails.

Interesting Topics