← All use cases

A headline in Slack, the workbook attached

Most people who depend on a report never open the file: they want last month’s revenue, the change, the top regions. With a message output, one run of the queries builds the workbook and a short headline, and the headline arrives in Slack with the workbook attached.

Try it yourself: Conditional Slack headline

Recorded from a real run: --preview prints the message, then the run posts it.

Recorded from a real run: --preview prints the message, then the run posts it.

A Slack post from the DRE bot: the headline in bold, revenue, orders and the top regions, with the Excel workbook attached and previewed
The post in Slack (a real screenshot of a test workspace, cropped to the message).
The same headline as an HTML email in Mailpit, with the workbook attached
The same headline as an email body, with the workbook attached (Mailpit).
A Databricks Volume in Catalog Explorer listing the headline .md files
Every message is also a .md file, so any file destination delivers it as is: here a Databricks Volume (--set msg_volume; a real screenshot).
reports/messages/msg_daily/msg_daily.yml
queries: [msg_headline, msg_regions]
output:
  - name: workbook
    format: xlsx
    queries: [msg_regions]
    destination: {profile: local, path: "out/messages/regions-{{ run.date.yyyymmdd }}.xlsx"}
  - name: headline
    format: message
    title: "{{ var('company') }}: {{ period(var('period')).start.format('%B %Y') }}"
    text: |
      Net revenue: **{{ results.msg_headline.first.net | currency('EUR') }}** ({{ results.msg_headline.first.change | percent | signed }} on the month before)
      Orders: {{ results.msg_headline.first.orders | number }}
      Top regions:
      {% for r in results.msg_regions.rows[:3] %}- {{ r.region_name }}: {{ r.net | currency('EUR') }}
      {% endfor %}
    destination:
      - {profile: slack, attach: [workbook]}
reports/messages/msg_daily/msg_headline.sql
{% set p = period(var('period')) %}
{% set before = period('last_month', as_of=p.start.date) %}
select
  sum(net_amount) filter (where order_date between '{{ p.start.date }}' and '{{ p.end.date }}') as net,
  count(distinct order_id) filter (where order_date between '{{ p.start.date }}' and '{{ p.end.date }}') as orders,
  sum(net_amount) filter (where order_date between '{{ p.start.date }}' and '{{ p.end.date }}')
    / nullif(sum(net_amount) filter (where order_date between '{{ before.start.date }}' and '{{ before.end.date }}'), 0) - 1 as change
from {{ ref('paid_order_facts') }}
terminal
dre run msg_daily --preview   # print the message, send nothing
dre run msg_daily