Skip to content
Docs

When a Run Finishes

When a Run Finishes starts a flow when a run of another flow ends. Use it to alert a team when an import fails, to hand a failed run to an agent that investigates it, or to start the next step once a long job is done. You find it on the node picker’s Triggers — start the flow shelf.

The node has a single webhook handle, which connects into Start’s trigger handle. Like every inbound trigger it is not one of the run’s steps: it decides when a run starts and what the start data is, and the run itself begins at Start.

Pick the flow to watch, and the ways a run of it may end that start this flow: completed, failed (on by default) or stopped by someone. A run that ends any other way starts nothing.

Two rules keep flows from starting each other forever:

  • A flow never starts itself. A trigger that watches its own flow does not start when one of its own runs ends.
  • A chain of flows started by each other’s runs finishing stops after four steps.

Leave Flow empty to watch every flow in the workspace with one trigger. This is how you build one alert, or one repair agent, for every failure instead of a trigger per flow.

A trigger that watches every flow is quieter than one that watches a single flow, so that one problem reaches you once:

  • It starts at most once per Cooldown for each watched flow. The default is 60 minutes. A flow that fails every minute starts your alert once an hour, and a second flow that fails in the same hour still starts it. Set the cooldown to 0 to start on every run.
  • It skips the run of a Subflow. When a Subflow fails, the run that called it fails too, and that run is the one you hear about.
  • It skips a run that failed because a service was already known to be down and the call was refused without being made. That outage was reported when it began.

A start the cooldown or an outage held back is recorded with its reason, so a start you expected and did not get is explained when you open the trigger’s last deliveries.

A trigger you added and never opened watches nothing, and the flow’s card says that no flow is chosen. Open the trigger and save it with Flow left empty to watch every flow.

$start->payload->run describes the run that finished:

Field What it holds
id The finished run’s id.
flowId, flowTitle The flow it was a run of.
status completed, failed or stopped.
startedAt, finishedAt, durationSeconds When it ran, and for how long.
failedStep For a failed run, the name of the node it failed at, as the node was named when the run ran: the node the run’s page names.
failedNodeId For a failed run, the id of that node, for an agent that goes on to read or repair it.
error For a failed run, why it failed, in a sentence.
handled For a completed run, how many nodes’ failures an error path took: 0 for a run that needed none, and for a failed run. Its status is completed either way. A failure a Subflow or a Parallel continued past is not counted. See Handling errors.
handledAt For a completed run whose error path took a failure, the name of the first node that failed, as it was named when the run ran.
url The link to the run’s page in Publicus, to put in the message you send.

$start->payload->depth counts how many finished runs in a row led to this one: 0 when the watched run was not itself started this way.

To send an alert, read the fields in the message, for example {{ $start->payload->run->flowTitle }} failed at {{ $start->payload->run->failedStep }}: {{ $start->payload->run->error }}.

The When a Run Finishes node's settings form, with the fields described below
The When a Run Finishes node's settings form, with the fields described below
FieldTypeDefaultDescription
Flow (flowId)string ✦ (optional) — The flow whose finished runs start this flow. Leave empty to watch every flow in this workspace.
Completed runs (onCompleted)boolean (optional) false Start a run when a run of that flow completes.
Failed runs (onFailed)boolean (optional) true Start a run when a run of that flow fails: the alert, the repair agent.
Stopped runs (onStopped)boolean (optional) false Start a run when someone stops a run of that flow.
Without overlapping (withoutOverlapping)boolean (optional) false Prevent a new run from starting while a previous run for this trigger is still in progress.
Cooldown (minutes) (cooldownMinutes)integer (optional) 60 For a trigger that watches every flow: the minutes after a start before the same watched flow can start it again. 0 starts on every run.

Fields marked ✦ accept expressions.