← All use cases

Send a message only when it matters

A daily “all fine” message trains people to ignore it. With when:, the message is sent only when the data calls for it, and on quiet days the run records it as skipped, not failed.

Try it yourself: Conditional Slack headline

Recorded from real runs: the quiet default is skipped, then the Slack Set sends the alert.

Recorded from real runs: the quiet default is skipped, then the Slack Set sends the alert.

A Slack message: Regions under €30,000, two regions under target with their net revenue
The alert in Slack (a real screenshot of a test workspace, cropped to the message).
reports/messages/msg_alerts/msg_alerts.yml
queries: [msg_low_regions]
output:
  - name: alert
    format: message
    when: "results.msg_low_regions.row_count > 0"
    title: "Regions under {{ var('alert_below') | currency('EUR') }}"
    text: |
      **{{ results.msg_low_regions.row_count }}** region(s) under target:
      {% for r in results.msg_low_regions.rows %}- {{ r.region_name }}: {{ r.net | currency('EUR') }}
      {% endfor %}
    destination: {profile: teams_mock}
  - name: note
    format: message
    text: "{% if results.msg_low_regions.row_count %}Low regions: {{ results.msg_low_regions.columns | join(', ') }}{% endif %}"
    destination: {profile: gchat_mock}
default_set: msg_quiet
sets:
  - {name: msg_quiet, vars: {alert_below: 0}}
  - {name: msg_loud, vars: {alert_below: 100000000}}
  - name: msg_slack
    vars: {alert_below: 30000}
    output: {name: alert, destination: [{profile: slack}]}
reports/messages/msg_alerts/msg_low_regions.sql
select region_name, net from {{ ref('delivery_sample') }}
where net < {{ var('alert_below', 0) }}
order by net
terminal
dre run msg_alerts                  # threshold 0: both outputs skipped
dre run msg_alerts --set msg_slack  # under €30,000: the alert goes to Slack