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";23const result = await relay4 .workflow("metrics-summary")56 // Step 1: Analyze growth metrics7 .step("analyze-growth")8 .with("openai:gpt-4o")9 .prompt(`Analyze these growth metrics:1011Current Period: {{currentMetrics}}12Previous Period: {{previousMetrics}}13YoY Comparison: {{yoyMetrics}}1415Calculate:16- MoM growth rate for each metric17- YoY growth rate18- Identify acceleration or deceleration19- Compare to targets ({{targets}})2021Metrics to analyze:22- Revenue (MRR/ARR)23- Customer count24- Average deal size25- Churn rate26- Net revenue retention2728Return structured analysis with percentages.`)2930 // Step 2: Detect anomalies31 .step("detect-anomalies")32 .with("anthropic:claude-3.5-sonnet")33 .depends("analyze-growth")34 .prompt(`Identify unusual patterns or anomalies:3536Growth Analysis: {{analyze-growth.output}}37Daily Time Series: {{timeSeriesData}}3839Look for:40- Sudden spikes or drops (>20% change)41- Unexpected trends42- Day-of-week patterns43- Seasonal deviations44- Metric correlations (e.g., traffic up but conversions down)4546For each anomaly:47- What changed48- When it started49- Potential causes50- Whether it's concerning`)5152 // Step 3: Identify key drivers53 .step("identify-drivers")54 .with("openai:gpt-4o")55 .depends("analyze-growth", "detect-anomalies")56 .prompt(`Identify what's driving the metrics:5758Analysis: {{analyze-growth.output}}59Anomalies: {{detect-anomalies.output}}6061Additional context:62- Marketing campaigns: {{campaigns}}63- Product launches: {{productUpdates}}64- Sales initiatives: {{salesInitiatives}}6566Determine:67- Primary growth drivers68- What's working well69- What's underperforming70- External factors (market, seasonality)7172Connect metrics to business activities.`)7374 // Step 4: Generate executive summary75 .step("executive-summary")76 .with("anthropic:claude-3.5-sonnet")77 .depends("analyze-growth", "detect-anomalies", "identify-drivers")78 .prompt(`Create executive summary:7980Growth: {{analyze-growth.output}}81Anomalies: {{detect-anomalies.output}}82Drivers: {{identify-drivers.output}}8384Format:85# Business Summary - {{period}}8687## Headline Metrics88- Key numbers with MoM/YoY change8990## Performance vs Targets91- On track / ahead / behind for each goal9293## What's Working94- Top 3 wins with supporting data9596## Areas of Concern97- Top 3 risks or underperformance9899## Recommended Actions100- 3-5 specific, actionable recommendations101102Keep under 500 words. Data-driven but narrative style.103Target audience: C-suite executives.`)104105 .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 });135136console.log("Summary:", result.steps["executive-summary"].output);Automated Reporting
1// Weekly metrics summary2import { relay } from "@relayplane/workflows";3import { fetchAnalytics } from "./analytics";45async 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" });910 const summary = await relay11 .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 });2021 // Send to leadership22 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 });3031 // Save to data warehouse32 await saveReport({33 type: "weekly_summary",34 content: summary,35 generatedAt: new Date(),36 });37}3839// Run every Monday at 9am40cron.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