Scheduled Reports

Run automations on a schedule using the Schedule trigger with CONNECTOR, DATABASE, and FUNCTION steps.

Time
Level
Prerequisites

20 minutes

Beginner

Basic Flow knowledge


What You'll Build

An automation that:

  1. Runs every morning at 9 AM (Schedule trigger)
  2. Fetches data using CONNECTOR or DATABASE step
  3. Formats a report using FUNCTION step
  4. Sends via email using CONNECTOR step

Step 1: Create the Automation

  1. Go to Automations
  2. Click + New Automation
  3. Name: Daily Sales Report
  4. Click Create

Step 2: Add Schedule Trigger

Configure Trigger

  1. Click Add Trigger
  2. Select Schedule
  3. Configure the schedule:
Field Value
Type Recurring
Frequency Daily
Time 9:00 AM
Timezone Your timezone

Cron Expression (Advanced)

For complex schedules, use cron syntax:

Schedule Cron Expression
Every day at 9 AM 0 9 * * *
Weekdays at 9 AM 0 9 * * 1-5
First of month 0 9 1 * *
Every 6 hours 0 */6 * * *

Step 3: Fetch Report Data

You have two options: use CONNECTOR for APIs or DATABASE for direct SQL.

Option A: CONNECTOR Step (API)

  1. Click + below the trigger
  2. Select CONNECTOR from the step palette
  3. Configure:
Field Value
Connector Your API connector
Connection Your connection
Operation getDailySales (or similar)

Option B: DATABASE Step (SQL)

  1. Click + below the trigger
  2. Select DATABASE from the step palette
  3. Configure:
Field Value
Connection Your database connection
Operation QUERY

SQL Query

SELECT 
  DATE(created_at) as date,
  COUNT(*) as total_orders,
  SUM(total) as total_revenue,
  json_agg(json_build_object('name', product_name, 'units', quantity) 
    ORDER BY quantity DESC LIMIT 5) as top_products
FROM orders
WHERE DATE(created_at) = CURRENT_DATE - INTERVAL '1 day'
GROUP BY DATE(created_at)

Step 4: Format the Report

Add FUNCTION Step

  1. Click + after the data fetch step
  2. Select FUNCTION from the step palette
  3. Name: formatReport

Write the Formatting Code

// Get data from previous step
const data = context.step.fetchData.output;

// Build HTML report
const report = `
<!DOCTYPE html>
<html>
<head>
  <style>
    body { font-family: Arial, sans-serif; }
    table { border-collapse: collapse; width: 100%; }
    th, td { border: 1px solid #ddd; padding: 8px; text-align: left; }
    th { background: #4CAF50; color: white; }
    .summary { margin: 20px 0; }
  </style>
</head>
<body>
  <h1>Daily Sales Report</h1>
  <p><strong>Date:</strong> ${data.date}</p>
  
  <div class="summary">
    <h2>Summary</h2>
    <ul>
      <li>Total Orders: ${data.total_orders}</li>
      <li>Total Revenue: $${data.total_revenue.toFixed(2)}</li>
    </ul>
  </div>
  
  <h2>Top Products</h2>
  <table>
    <tr><th>Product</th><th>Units</th></tr>
    ${data.top_products.map(p => 
      `<tr><td>${p.name}</td><td>${p.units}</td></tr>`
    ).join('')}
  </table>
</body>
</html>
`;

return { html: report, subject: `Daily Sales Report - ${data.date}` };

Step 5: Send the Report

Add CONNECTOR Step for Email

  1. Click + after the FUNCTION step
  2. Select CONNECTOR from the step palette
  3. Choose your email connector (SendGrid, SES, etc.)
Field Value
Connector SendGrid (or your email connector)
Connection Your email connection
Operation sendEmail

Configure Email Parameters

Parameter Value
to team@yourcompany.com
subject {{ steps.formatReport.output.subject }}
html {{ steps.formatReport.output.html }}

Step 6: Add Error Handling

Use CONDITION for Error Check

After the data fetch step, add a CONDITION:

{{ steps.fetchData.output != null }}

True Branch (Success)

Continue with formatting and sending.

False Branch (Error)

Add a CONNECTOR step to send error notification:

Subject: ⚠️ Daily Report Failed
Body: The daily sales report could not be generated. 
      Please check the data source.

Complete Workflow

┌─────────────────────┐
│  Schedule Trigger   │
│  Daily 9:00 AM      │
└──────────┬──────────┘
           │
           ▼
┌─────────────────────┐
│  DATABASE           │
│  Fetch sales data   │
└──────────┬──────────┘
           │
           ▼
┌─────────────────────┐
│  CONDITION          │
│  Data exists?       │
├──────────┬──────────┤
│ True     │   False  │
└────┬─────┴────┬─────┘
     │          │
     ▼          ▼
┌────────┐  ┌────────┐
│FUNCTION│  │CONNECTOR│
│Format  │  │Error   │
└────┬───┘  │Email   │
     │      └────────┘
     ▼
┌────────────────────┐
│  CONNECTOR         │
│  Send report email │
└────────────────────┘

Step 7: Test and Activate

Manual Test

  1. Click Save
  2. Click Test
  3. The automation runs immediately (ignoring schedule)
  4. Verify the email arrives

Activate

  1. Toggle Active
  2. The automation will run on schedule

Monitoring Scheduled Jobs

View Run History

  1. Open your automation
  2. Click Runs tab
  3. See all scheduled executions

Check Run Details

For each run, view:

  • Trigger timestamp
  • Step-by-step execution
  • Output from each step
  • Errors (if any)

Common Schedule Patterns

Business Reports

Report Cron Description
Daily summary 0 9 * * 1-5 Weekdays 9 AM
Weekly digest 0 8 * * 1 Monday 8 AM
Monthly report 0 6 1 * * 1st of month 6 AM

Operational Tasks

Task Cron Description
Data cleanup 0 2 * * * Daily 2 AM
Cache refresh 0 */6 * * * Every 6 hours
Health check */5 * * * * Every 5 minutes

Best Practices


Next Steps