← 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.

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}]}select region_name, net from {{ ref('delivery_sample') }}
where net < {{ var('alert_below', 0) }}
order by netdre run msg_alerts # threshold 0: both outputs skipped
dre run msg_alerts --set msg_slack # under €30,000: the alert goes to Slack