Examples / Daily revenue watch
Daily revenue watch
Every morning, Murmurator asks Snowflake for yesterday's revenue by region next to its trailing four-week average for the same weekday. JavaScript flags any region more than 20% off, your model writes a short read of what moved, and finance hears about it in Slack only when something did.
SnowflakeJavaScriptYour AI modelsSlack
What you tell the assistant
Why it works
- The query runs read-only on the Snowflake connection, under a role you can limit to one schema, with the threshold passed as a bound parameter rather than pasted into the SQL.
- Comparing against the same weekday keeps normal weekend dips from ringing the alarm.
- The JavaScript step decides what's unusual, and the Slack step is skipped on quiet days, so the model only writes when there's something to say.
What it builds
Trigger
Schedule
0 7 * * 1-5 · America/Toronto
tool
Yesterday against the usual
snowflake.query
javascript
Flag the unusual regions
→ unusual, count
llm
Write the read
smart
if flag.output.count gt 0
tool
Post to #finance
slack.post_message
if flag.output.count gt 0
View the definition
trigger:
kind: schedule
cron: "0 7 * * 1-5"
timezone: America/Toronto
steps:
- key: revenue
name: Yesterday against the usual
kind: tool
tool: snowflake.query
args:
sql: |
with daily as (
select region, order_date, sum(amount_usd) as revenue
from analytics.finance.orders
where order_date >= dateadd(day, -29, current_date()) and order_date < current_date()
group by region, order_date
)
select region,
max(iff(order_date = dateadd(day, -1, current_date()), revenue, null)) as yesterday,
avg(iff(order_date < dateadd(day, -1, current_date()) and dayofweek(order_date) = dayofweek(dateadd(day, -1, current_date())), revenue, null)) as usual
from daily
group by region
having usual > ?
order by region
params: [1000]
- key: flag
name: Flag the unusual regions
kind: javascript
inputs: { rows: "{{ steps.revenue.output.rows }}" }
outputs: { unusual: array, count: integer }
code: |
function main({ rows }) {
const unusual = rows
.map(row => ({ region: row.REGION, yesterday: row.YESTERDAY || 0, usual: row.USUAL, change: (row.YESTERDAY || 0) / row.USUAL - 1 }))
.filter(row => Math.abs(row.change) > 0.2)
.sort((a, b) => Math.abs(b.change) - Math.abs(a.change))
console.log(`${unusual.length} of ${rows.length} regions moved more than 20%`)
return { unusual, count: unusual.length }
}
- key: explain
name: Write the read
kind: llm
model: smart
if: { path: steps.flag.output.count, gt: 0 }
system: You write short, plain notes for a finance team. No speculation beyond the numbers given.
prompt: |
These regions' revenue yesterday differed from the average for the same weekday over the last four weeks by more than 20%.
Give one line per region with the dollar amounts and the change, biggest first, then one sentence on anything they have in common.
{{ steps.flag.output.unusual }}
- key: post
name: "Post to #finance"
kind: tool
tool: slack.post_message
if: { path: steps.flag.output.count, gt: 0 }
args:
channel: C05FINANCE
text: ":chart_with_downwards_trend: *Revenue moved yesterday*\n{{ steps.explain.output.text }}"
A sample run
What each step produces
Yesterday against the usual tool
succeeded
Yesterday against the usual tool
Calling snowflake.query
{
"columns": [
"REGION",
"YESTERDAY",
"USUAL"
],
"rows": [
{
"REGION": "APAC",
"YESTERDAY": 18240.5,
"USUAL": 26980.25
},
{
"REGION": "EMEA",
"YESTERDAY": 41870.0,
"USUAL": 40115.75
},
{
"REGION": "LATAM",
"YESTERDAY": 12960.0,
"USUAL": 9870.5
},
{
"REGION": "NA",
"YESTERDAY": 88310.25,
"USUAL": 86420.0
}
],
"row_count": 4,
"truncated": false
}
Flag the unusual regions javascript
succeeded
Flag the unusual regions javascript
2 of 4 regions moved more than 20%
{
"unusual": [
{
"region": "APAC",
"yesterday": 18240.5,
"usual": 26980.25,
"change": -0.324
},
{
"region": "LATAM",
"yesterday": 12960.0,
"usual": 9870.5,
"change": 0.313
}
],
"count": 2
}
Write the read llm
succeeded
Write the read llm
Using model smart (Claude Sonnet 5, Murmurator AI)
{
"text": "• *APAC* — $18,241 against a usual $26,980 (−32%).\n• *LATAM* — $12,960 against a usual $9,871 (+31%).\nThe two moved in opposite directions, so this looks regional rather than a platform-wide problem; APAC is worth checking first."
}
Post to #finance tool
succeeded
Post to #finance tool
Calling slack.post_message
{
"channel": "C05FINANCE",
"ts": "1758711600.000300"
}
Trigger payload
{
"scheduled_at": "2026-09-24T11:00:00Z"
}
More examples
Your next automation is one sentence away.
14-day free trial with $5 of built-in AI included. Cancel anytime.