How to send an Alert if a frequently running flow has an Error

If a flow needs to be constantly running and want to create an alert to check if the flow stops processing, please follow the below instructions.

The image below is an example of a flow that runs every 10 minutes to fetch a list of crypto exchanges and writes it to a buffer. If, for any reason, the API stops functioning or the flow encounters an error, we want to be alerted so we can investigate and remedy the issue quickly.

Illustrated in the image below is an example of a flow that uses the Runs step to retrieve the runs information of a flow and checks if it ran since the last time the current flow has run then sends out an email if the criteria do not match.

Ensure the schedule on the flow checker is set to a duration greater than the flow we want to check against, For this example we will set our schedule to run every 15 minutes. Add a source to begin the flow such as a Start flow or Empty Record Generator then include a Subflow control step.

Within the Subflow control step, Add a Runs source step, In the query builder add a check if processingDates.created is greater than or equal to the last time the current flow has run and if the status of the last run was Completed, The field we are looking at is the runId, created date and we only need to return one record.

The below image shows a sample of the response from the Runs source step

Add a Rollup mapper step that will group records by an identifiing field and then aggregate the grouped values

N.B: Add a blank Calculator step with the defaults after the step when testing to see the results of the Rollup mapper step

At the end of the Subflow control step ensure the Log errors step has been added then click on the return box as highlighted in the image below

In the Return Value window, Choose type as Object, Source as record and add the records to a new field called counts

After the Subflow control step, Add a calculator step with the Javascript code below

let inputRecord=input.record;

let count=inputRecord.counts&&inputRecord.counts.count?inputRecord.counts.count:0

    return false;
return inputRecord;

Code Explained:

Check if inputRecord.counts is true and if inputRecord.counts.count is true. If both conditions are true, the value of count will be inputRecord.counts.count.
If either condition is false, meaning inputRecord.counts or inputRecord.counts.count is not true, the value of count will be set to 0.

In the If statement, count is greater than 0 then records will be omitted (Meaning the flow is running) and the proceeding steps will not be executed resulting in the flow ending at this point, however if count is 0 (Meaning the flow is not running) then we can send out an alert

Add an Email destination step to send an alert and notify all parties if the flow has stopped processing, Include a meaningful subject and body

When the flow stops processing the below email alert will be sent every 15 minutes until the being checked completes successfully.