Home Tutorials Categories Skills About
ZH EN JA KO
Advanced

OpenClaw Scheduled Messages and Automation Workflows

· 17 min read

Introduction

An AI Agent shouldn't just passively wait for user messages — it can take the initiative. OpenClaw has a built-in scheduling system that supports cron expression-based scheduling, enabling AI Agents to automatically execute tasks, send messages, or trigger workflows at specified times. From daily weather reports to periodic data summaries, the scheduled messaging feature greatly expands the range of Agent use cases.

This article covers the configuration of scheduled messages and techniques for building automation workflows.

Basic Scheduled Messages

Configuring Scheduled Tasks

Add scheduled tasks for an Agent in openclaw.json5:

{
  agents: {
    "my-agent": {
      schedules: [
        {
          // Task name
          name: "morning-greeting",
          // Cron expression (minute hour day month weekday)
          cron: "0 8 * * *",  // Every day at 8:00 AM
          // Timezone
          timezone: "Asia/Shanghai",
          // Target channel
          target: {
            platform: "telegram",
            chatId: "123456789"
          },
          // Message sent to the AI (the AI generates a reply based on this)
          prompt: "Generate a morning greeting that includes today's date and an inspirational quote."
        }
      ]
    }
  }
}

Cron Expression Quick Reference

Expression Meaning
0 8 * * * Every day at 08:00
0 8 * * 1-5 Weekdays at 08:00
*/30 * * * * Every 30 minutes
0 9,18 * * * Every day at 09:00 and 18:00
0 0 1 * * 1st of every month at 00:00
0 0 * * 0 Every Sunday at 00:00
0 */4 * * * Every 4 hours

Common Automation Scenarios

Scenario 1: Daily Weather Report

{
  schedules: [{
    name: "weather-report",
    cron: "0 7 * * *",
    timezone: "Asia/Shanghai",
    target: {
      platform: "telegram",
      chatId: "group_weather_123"
    },
    prompt: "Use the weather tool to check today's weather in Beijing, Shanghai, and Guangzhou, then generate a weather report.",
    // Specify which tools to use
    tools: ["weather"],
    // Response format
    format: "markdown"
  }]
}

Scenario 2: Weekday Standup Reminder

{
  schedules: [{
    name: "standup-reminder",
    cron: "0 9 * * 1-5",
    timezone: "Asia/Shanghai",
    target: {
      platform: "slack",
      channelId: "#dev-team"
    },
    // Static message (not processed by AI)
    staticMessage: "Good morning, team! It's standup time. Please reply with:\n1. What you completed yesterday\n2. What you plan to do today\n3. Any blockers",
    // Mention everyone
    mentionAll: true
  }]
}

Scenario 3: Periodic Data Summary

{
  schedules: [{
    name: "weekly-summary",
    cron: "0 17 * * 5",  // Every Friday at 5:00 PM
    timezone: "Asia/Shanghai",
    target: {
      platform: "discord",
      channelId: "analytics-channel"
    },
    prompt: "Query this week's user data and generate a weekly summary report including new users, active users, and key metric changes.",
    tools: ["sqlite", "http-fetch"]
  }]
}

Scenario 4: RSS Content Push

{
  schedules: [{
    name: "rss-digest",
    cron: "0 12 * * *",  // Every day at noon
    target: {
      platform: "telegram",
      chatId: "tech_news_123"
    },
    prompt: "Fetch the latest 10 articles from the following RSS feeds, filter for AI-related content, and generate a summary digest.",
    tools: ["rss", "http-fetch"],
    // Parameters passed to the prompt
    params: {
      feeds: [
        "https://news.ycombinator.com/rss",
        "https://techcrunch.com/feed/"
      ]
    }
  }]
}

Workflow Chained Execution

OpenClaw supports chaining multiple scheduled tasks into workflows, where the result of one task can be passed to the next.

Configuring Workflows

{
  agents: {
    "workflow-agent": {
      workflows: {
        "daily-ops": {
          // Workflow trigger time
          cron: "0 9 * * 1-5",
          timezone: "Asia/Shanghai",
          // Step chain
          steps: [
            {
              name: "fetch-data",
              prompt: "Query yesterday's operational data from the database",
              tools: ["sqlite"],
              // Save output as a variable
              outputVar: "dailyData"
            },
            {
              name: "analyze",
              prompt: "Analyze the following operational data and identify anomalous metrics: {{dailyData}}",
              outputVar: "analysis"
            },
            {
              name: "report",
              prompt: "Generate a daily operations report based on the following analysis: {{analysis}}",
              // Send to target channel
              target: {
                platform: "slack",
                channelId: "#ops-daily"
              }
            }
          ],
          // Handling when a step fails
          onError: {
            notify: {
              platform: "telegram",
              chatId: "admin_123",
              message: "Workflow daily-ops failed: {{error}}"
            }
          }
        }
      }
    }
  }
}

Conditional Branching

Workflow steps support conditional logic:

{
  steps: [
    {
      name: "check-metrics",
      prompt: "Check whether key system metrics are normal",
      outputVar: "status"
    },
    {
      name: "alert",
      // Only execute when the previous step's output contains "anomaly"
      condition: "{{status}} contains 'anomaly'",
      prompt: "Generate an anomaly alert report: {{status}}",
      target: {
        platform: "telegram",
        chatId: "oncall_group"
      }
    },
    {
      name: "normal-log",
      condition: "{{status}} not contains 'anomaly'",
      staticMessage: "System health check passed.",
      target: {
        platform: "slack",
        channelId: "#monitoring"
      }
    }
  ]
}

Task Management

Command-Line Management

# List all scheduled tasks
openclaw schedules list

# Manually trigger a task (without waiting for cron time)
openclaw schedules run morning-greeting

# Pause a task
openclaw schedules pause weekly-summary

# Resume a task
openclaw schedules resume weekly-summary

# View task execution history
openclaw schedules history morning-greeting --last 10

Dashboard Management

The OpenClaw Web Dashboard provides a visual task management interface:

  • View the status and next execution time of all scheduled tasks
  • Manually trigger task execution
  • View execution logs and output
  • Pause/resume/edit tasks

Error Handling and Retries

{
  schedules: [{
    name: "critical-report",
    cron: "0 9 * * *",
    // Retry configuration
    retry: {
      maxAttempts: 3,
      backoffMs: 5000,  // Retry interval
      // Notification after all retries fail
      onFailure: {
        platform: "telegram",
        chatId: "admin_123",
        message: "Scheduled task critical-report failed 3 consecutive times"
      }
    },
    // Timeout setting (seconds)
    timeout: 120,
    // ...other configuration
  }]
}

Integration with External Cron

If you already have an existing cron system (such as Linux crontab or Kubernetes CronJob), you can trigger OpenClaw tasks via API:

# Configure in system crontab
0 8 * * * curl -X POST http://localhost:3000/api/v1/schedules/morning-greeting/run \
  -H "Authorization: Bearer sk-openclaw-xxx"

This approach lets you leverage your existing cron infrastructure while benefiting from OpenClaw's task orchestration capabilities.

Best Practices

  1. Explicit timezones: Always specify timezone explicitly to avoid confusion caused by server timezone settings
  2. Error notifications: Configure failure notifications for critical tasks to prevent silent failures
  3. Execution windows: Avoid scheduling large numbers of tasks during peak system hours
  4. Idempotent design: Tasks should be designed to be safely re-executable to prevent duplicate operations from retries
  5. Log review: Regularly check task execution history to confirm tasks are running properly

Summary

OpenClaw's scheduled messaging and automation workflow features upgrade the AI Agent from passive response to proactive service. With cron scheduling, workflow chaining, conditional branching, and error handling, you can build complete automation pipelines — from simple timed reminders to complex multi-step data processing workflows, OpenClaw handles them all.

OpenClaw is a free, open-source personal AI assistant that supports WhatsApp, Telegram, Discord, and many more platforms