Business Metrics Summary

Generate executive summaries from analytics data with insights and anomaly detection.

This workflow analyzes metrics across multiple sources, identifies trends, and creates narrative summaries for leadership.

Implementation

1import { relay } from "@relayplane/workflows";
2
3const result = await relay
4 .workflow("metrics-summary")
5
6 // Step 1: Analyze growth metrics
7 .step("analyze-growth")
8 .with("openai:gpt-4o")
9 .prompt(`Analyze these growth metrics:
10
11Current Period: {{currentMetrics}}
12Previous Period: {{previousMetrics}}
13YoY Comparison: {{yoyMetrics}}
14
15Calculate:
16- MoM growth rate for each metric
17- YoY growth rate
18- Identify acceleration or deceleration
19- Compare to targets ({{targets}})
20
21Metrics to analyze:
22- Revenue (MRR/ARR)
23- Customer count
24- Average deal size
25- Churn rate
26- Net revenue retention
27
28Return structured analysis with percentages.`)
29
30 // Step 2: Detect anomalies
31 .step("detect-anomalies")
32 .with("anthropic:claude-3.5-sonnet")
33 .depends("analyze-growth")
34 .prompt(`Identify unusual patterns or anomalies:
35
36Growth Analysis: {{analyze-growth.output}}
37Daily Time Series: {{timeSeriesData}}
38
39Look for:
40- Sudden spikes or drops (>20% change)
41- Unexpected trends
42- Day-of-week patterns
43- Seasonal deviations
44- Metric correlations (e.g., traffic up but conversions down)
45
46For each anomaly:
47- What changed
48- When it started
49- Potential causes
50- Whether it's concerning`)
51
52 // Step 3: Identify key drivers
53 .step("identify-drivers")
54 .with("openai:gpt-4o")
55 .depends("analyze-growth", "detect-anomalies")
56 .prompt(`Identify what's driving the metrics:
57
58Analysis: {{analyze-growth.output}}
59Anomalies: {{detect-anomalies.output}}
60
61Additional context:
62- Marketing campaigns: {{campaigns}}
63- Product launches: {{productUpdates}}
64- Sales initiatives: {{salesInitiatives}}
65
66Determine:
67- Primary growth drivers
68- What's working well
69- What's underperforming
70- External factors (market, seasonality)
71
72Connect metrics to business activities.`)
73
74 // Step 4: Generate executive summary
75 .step("executive-summary")
76 .with("anthropic:claude-3.5-sonnet")
77 .depends("analyze-growth", "detect-anomalies", "identify-drivers")
78 .prompt(`Create executive summary:
79
80Growth: {{analyze-growth.output}}
81Anomalies: {{detect-anomalies.output}}
82Drivers: {{identify-drivers.output}}
83
84Format:
85# Business Summary - {{period}}
86
87## Headline Metrics
88- Key numbers with MoM/YoY change
89
90## Performance vs Targets
91- On track / ahead / behind for each goal
92
93## What's Working
94- Top 3 wins with supporting data
95
96## Areas of Concern
97- Top 3 risks or underperformance
98
99## Recommended Actions
100- 3-5 specific, actionable recommendations
101
102Keep under 500 words. Data-driven but narrative style.
103Target audience: C-suite executives.`)
104
105 .run({
106 currentMetrics: {
107 mrr: 285000,
108 customers: 142,
109 avgDealSize: 2007,
110 churnRate: 2.1,
111 nrr: 118,
112 },
113 previousMetrics: {
114 mrr: 268000,
115 customers: 134,
116 avgDealSize: 2000,
117 churnRate: 2.8,
118 nrr: 112,
119 },
120 yoyMetrics: {
121 mrr: 195000,
122 customers: 98,
123 },
124 targets: {
125 mrr: 300000,
126 customers: 150,
127 churnRate: 2.0,
128 },
129 timeSeriesData: dailyMetrics,
130 campaigns: "Product Hunt launch, LinkedIn campaign",
131 productUpdates: "v3.0 released with new features",
132 salesInitiatives: "Hired 2 new AEs, started outbound program",
133 period: "November 2024",
134 });
135
136console.log("Summary:", result.steps["executive-summary"].output);

Automated Reporting

1// Weekly metrics summary
2import { relay } from "@relayplane/workflows";
3import { fetchAnalytics } from "./analytics";
4
5async function weeklyMetricsReport() {
6 const current = await fetchAnalytics({ period: "last_7_days" });
7 const previous = await fetchAnalytics({ period: "previous_7_days" });
8 const yoy = await fetchAnalytics({ period: "same_week_last_year" });
9
10 const summary = await relay
11 .workflow("metrics-summary")
12 .run({
13 currentMetrics: current,
14 previousMetrics: previous,
15 yoyMetrics: yoy,
16 targets: await getTargets("monthly"),
17 timeSeriesData: await fetchTimeSeries("last_30_days"),
18 period: `Week of ${new Date().toLocaleDateString()}`,
19 });
20
21 // Send to leadership
22 await sendSlack({
23 channel: "#executive-metrics",
24 message: summary.steps["executive-summary"].output,
25 attachments: [{
26 title: "Detailed Analysis",
27 text: summary.steps["analyze-growth"].output,
28 }],
29 });
30
31 // Save to data warehouse
32 await saveReport({
33 type: "weekly_summary",
34 content: summary,
35 generatedAt: new Date(),
36 });
37}
38
39// Run every Monday at 9am
40cron.schedule('0 9 * * MON', weeklyMetricsReport);

Sample Output

# Business Summary - November 2024 ## Headline Metrics - **MRR:** $285K (+6.3% MoM, +46% YoY) - **Customers:** 142 (+6.0% MoM, +45% YoY) - **Churn:** 2.1% (-25% improvement MoM) - **NRR:** 118% (+6pp MoM) ## Performance vs Targets - **On track:** Customer growth (95% to monthly target) - **Ahead:** Churn reduction (beat 2.0% target) - **Behind:** MRR target ($285K vs $300K goal, need +$15K) ## What's Working 1. **Expansion revenue up 40%** - Existing customers upgrading to higher tiers 2. **Churn improvement** - New onboarding flow reducing early churn by 35% 3. **Deal size growth** - Average deal at $2,007 (+0.4% MoM) ## Areas of Concern 1. **New sales pipeline slowing** - Only 8 new deals vs 12 target 2. **Conversion rate dip** - Trial-to-paid down from 28% to 24% ## Recommended Actions 1. Accelerate outbound program to hit MRR target 2. Investigate trial conversion drop (survey churned trials) 3. Double down on expansion - highest ROI channel right now

Integration with BI Tools

  • Connect to Mixpanel, Amplitude, Google Analytics
  • Pull data from Stripe for revenue metrics
  • CRM integration (Salesforce, HubSpot) for sales data
  • Export to Looker/Tableau for visualization