Example: a failure that tells you
An alert is only as useful as its first line. When a script fails on purpose with a precise message — which record, what was wrong — the alert carries that sentence to your channel, and whoever reads it knows what to fix before opening the run. This example builds both halves and watches one failure and one recovery.
- Fail a run on purpose with a message worth reading
- Route that failure, and the recovery, to a channel
The error becomes the alert
An alert message carries the item, the first line of the error, the failing step for a flow, what started the run and a link to it — never the run’s inputs, outputs or variables. So the error you raise is the headline. A plain KeyError: 'amount' says little; order 2 has no amount says everything.
The script
DEFAULT = [{"id": 1, "amount": 10}, {"id": 2, "value": 5}]
def main(orders: list[dict] = DEFAULT):
for o in orders:
if "amount" not in o:
raise ValueError(f"order {o.get('id')} has no amount")
total = sum(o["amount"] for o in orders)
return {"orders": len(orders), "total": total}- Add a channel
On Alerts → Channels, add an e-mail or Slack channel and press Send test.
- Write the rule
New rule → What: Chosen items, this script → When: Failed and Working again → Where: your channel → Save rule.
- Fail, then recover
Run the script with the default orders; then fix order 2’s field to
amountin the input and run again.
In production
For a scheduled script, choose Only unattended instead: runs a person starts from the editor stay quiet. Repeats are grouped, so a schedule failing every minute is one message and one follow-up per window, not hundreds. Raise errors for the cases a person must act on, and handle the expected ones in code instead — an alert that fires for normal situations quickly stops being read.