Email an alert when a Run fails
Build an automation that emails your team when a Run fails. Reecall produces a run.failed System event each time a Run ends with status: "failed". A Trigger on it starts a Process that emails why the Run failed.
The System event gives the error code, a sentence that describes the failure, and the position of the failed step. The sentence never holds the Run's data, such as a response body or a value from the conversation.
Prerequisites
- An API key. A project-scoped key watches the Runs of its Project. An organization-scoped key can watch every Project of the Organization.
- The email address that receives the alerts.
Step 1: Create the Process
The Process has one Email step that sends the fields of the System event:
Create the Process
Replace to with your address. Without from, the email comes from noreply@reecall.co.
A field that has no value renders as empty text, such as processId for a Run of steps sent with the API call.
Copy the id of the response for the next step.
Step 2: Create the Trigger
Link the Process to run.failed:
Create the Trigger
With a project-scoped key, the Trigger receives the failures of its Project. With an organization-scoped key, create the Process and the Trigger without projectId to receive the failures of every Project. See Scope.
Watch one Trigger only
To be alerted only for the Runs of one Trigger, such as the one from Send a call report to a webhook, add a condition on event.data.triggerId:
Conditions
Step 3: Make a Run fail
Start a Run of one request step whose host does not exist. The .invalid domain never resolves, so the step fails at once:
Start a Run that fails
The Run ends with status: "failed", errorCode: "REQUEST_ERROR", and errorMessage: "The host name could not be resolved". Reecall produces run.failed, and your Trigger starts the alert Process. Skip this step if you added the condition on triggerId: a Run started through the API has no Trigger, so the condition does not match.
Step 4: Check the alert
Read the Runs of the alert Trigger:
List the Runs of the alert Trigger
The newest Run has status: "succeeded", and its refId is the ID of the failed Run. The email reaches your inbox.
Result
When a Run of the call report Process fails because your endpoint answered 503, the alert looks like this:
Step 1 is the Request step of the call report Process. A 503 is safe to repeat, so turning on retries for the call report Trigger would have tried again before alerting.
- A Run with retries produces
run.failedonce, when its last attempt fails. - If the alert Process fails, no other alert follows: a Run started by
run.failednever producesrun.failed. - To see how each step of the failed Run went, read the Run with
GET /v2/runs/{id}. See Step records.
Troubleshooting
| Symptom | Check |
|---|---|
| No alert Run after the failure | The Trigger's enabled field, its eventType, and its scope. A project Trigger only receives the failures of its Project. |
The alert Run failed with EMAIL_ERROR | The alert Run's errorMessage, the to address, and from if you set one. See Email. |
| The alert Run succeeded but no email arrived | The spam folder of the recipient. The step's status reports the provider's acceptance, not the delivery. |