ExamplesExample

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.

What you will learn
  • 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.

AlertsGet told when a script, flow, schedule or robot fails — without opening Runs.
Add channelNew rule
Rules3Channels2History
Anything failsEverything · Failed, Working againChannels#opsGrouping15 minActive
Campaign flowcampaign · FailedChannelsops@shop.devGroupingOffActive
Nightly jobsOnly unattended · FailedChannelsTeamsGrouping1 hActive
The Alerts page: the rule, its channel, and the history of what was sent.

The script

nightly_import.py
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}
  1. Add a channel

    On Alerts → Channels, add an e-mail or Slack channel and press Send test.

  2. Write the rule

    New rule → What: Chosen items, this script → When: Failed and Working again → Where: your channel → Save rule.

  3. Fail, then recover

    Run the script with the default orders; then fix order 2’s field to amount in 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.