Back to Recipes

Daily Business Report Agent

An AI agent that gathers data from your tools every morning and emails you a personalized business report.

Best for: Founders, operators, and managers who want daily visibility

What You Get

  • -Multi-source data gathering
  • -Report generation with AI analysis
  • -Email delivery automation
  • -Customizable report sections
  • -Schedule management

Step by Step

1. Set up data source integrations

Create connector modules for each data source: Google Analytics API (page views, top pages, users), Stripe API (revenue, new customers, failed payments, MRR), HubSpot API (new leads, deal stage changes, email stats), Slack API (brand mentions in channels). Each connector returns typed data or a connection error.

2. Build the data gathering pipeline

Create a scheduled job (cron, runs at 6:45 AM). It calls each connector in parallel, collects results, and handles failures gracefully. If a source fails, log the error and continue with partial data.

3. Implement AI report generation

Send gathered data to OpenAI with a structured prompt. Request: a 3-paragraph executive summary (highlights, concerns, recommendations), key metrics table, top 3 action items. Parse structured JSON response.

4. Create the email template

Build a responsive HTML email template with: header (date, company name), executive summary section, metrics table (metric, value, change %), highlights as bullet points, action items with priority badges. Use inline CSS for email client compatibility.

5. Set up email delivery

Use Resend API to send the report. Configure: sender name (Daily Report Bot), reply-to (manager email), recipient list from settings. Schedule delivery for 8 AM via cron after report generation.

6. Build the settings page

Create a Next.js settings page: toggle data sources on/off, set delivery time, manage recipient list, set timezone, test email button. Store settings in PostgreSQL.

7. Add monitoring and error handling

Track: report generation success/failure, delivery status, data source health. Send Slack alert if report generation fails. Log all runs with timestamps and data point counts.

Stack

OpenAIPlaywrightResend / SendGridNext.js cronSupabase/PostgreSQL

Build This

Copy this prompt and paste it into Claude Code, OpenCode, Codex, or Cursor to build this recipe.

Build a daily business report agent that gathers data, analyzes trends, and delivers insights. ROLE: You are a daily business intelligence agent that collects data from multiple sources, generates AI-powered analysis, and delivers actionable reports via email. CONSTRAINTS: - Report generation must complete within 60 seconds; if a data source times out, skip it and note the failure - Maximum report length: 800 words; executive summary must be 3 paragraphs or fewer - Each data source must have retry logic: 2 attempts with 5-second delay between retries - Report delivery must respect timezone settings; default to UTC if not configured - Sensitive metrics (revenue, customer data) must be encrypted at rest in the database TOOL CALLING: - Use function calling for: fetch_analytics(date_range, metrics[]), fetch_stripe(date_range, metrics[]), fetch_hubspot(date_range, metrics[]), fetch_slack_mentions(channel, time_range), generate_report(data, template), send_email(recipient, subject, html_body) - Each tool returns structured JSON with source data and metadata STRUCTURED OUTPUT: - Report data must return JSON: { date: string, sources: { analytics?: { visitors: number, top_pages: [{ url: string, views: number }] }, stripe?: { revenue: number, new_customers: number, failed_payments: number }, hubspot?: { new_leads: number, deal_changes: [{ deal: string, from: string, to: string }] }, slack?: { mentions: [{ channel: string, message: string, timestamp: string }] } }, generated_at: string } - Executive summary must return JSON: { summary: string, highlights: string[], concerns: string[], recommendations: string[] } - Email payload must return JSON: { subject: string, html_body: string, recipient_count: number } CHAIN OF THOUGHT: - Data gathering: identify active sources → call each in parallel → handle failures gracefully → compile results - Analysis: examine metrics → compare to historical averages → identify anomalies → generate insights - Report generation: format data into template → populate sections → validate length → render HTML email FEW-SHOT EXAMPLES: Analytics Data: { visitors: 1247, top_pages: [{ url: '/pricing', views: 342 }, { url: '/blog/ai-agents', views: 289 }] } Stripe Data: { revenue: 4250, new_customers: 3, failed_payments: 1 } HubSpot Data: { new_leads: 12, deal_changes: [{ deal: 'Acme Corp', from: 'qualified', to: 'proposal' }] } Summary: 'Traffic up 15% from yesterday with pricing page leading. Revenue steady at $4,250 with 3 new customers. 12 new leads in pipeline with Acme Corp advancing to proposal stage.' EVALUATION CRITERIA: - Data completeness: percentage of requested data sources that return valid data - Report accuracy: metrics in the report match raw data source values - Delivery reliability: percentage of reports delivered on time - Insight quality: percentage of recommendations that are actionable and specific The system should: 1) Every morning at 7 AM, gather data from Google Analytics (last 24h visitors, top pages), Stripe (revenue, new customers, failed payments), HubSpot (new leads, deal stage changes), and Slack (mentions of the company name), 2) Use OpenAI to analyze the data and generate a 3-paragraph executive summary with highlights, concerns, and recommendations, 3) Format the report as a clean HTML email with sections: Summary, Metrics, Highlights, Action Items, 4) Email the report via Resend to the team at 8 AM, 5) Include a settings page where users can toggle which data sources to include and set delivery time, 6) Handle API failures gracefully: if a source is down, note it in the report and retry.

Common Failure Modes

  • !API credentials expire silently
  • !Report gets too long and gets ignored
  • !Data source rate limits
  • !Timezone confusion for scheduling

Implementation Notes

Store all API tokens encrypted. Keep reports to under 5 sections. Test each data source integration individually first.

Related skill: internal reporting agent

Ship daily business report agent in production with 4M Labs

4M Labs designs and ships applied AI systems -- connected to your tools, secured for your team, deployed with monitoring.

  • Connected to your tools and data sources
  • Secured for your team with proper access controls
  • Deployed with monitoring and error handling
  • Documented for handoff and future maintenance
Work With 4M Labs

Frequently Asked Questions

Can I use this recipe in production?
Yes. Every recipe is production-tested with error handling, logging, and deployment guidance.
Which LLM providers are supported?
Recipes support OpenAI, Anthropic Claude, Google Gemini, and open-source models via a unified interface.
How do I customize these recipes?
Each recipe includes a configuration section. Override model selection, API keys, and parameters without changing core logic.