Agents

Automation

12 min

Make OpenClaw proactive with cron jobs, background tasks, Task Flow, hooks, standing orders, heartbeat behavior, and external webhooks.

Automation turns OpenClaw from a reply bot into an agent system that can wake up, schedule work, react to events, and run background tasks.

Automation Surfaces

SurfaceUse it for
Cron jobsTime-based scheduled work
Background tasksLong-running or isolated work with status tracking
Task FlowMulti-step orchestration above background tasks
HooksEvent-driven lifecycle behavior
WebhooksExternal systems triggering Gateway work
Standing ordersPermanent authority for recurring autonomous behavior
HeartbeatPeriodic check-ins and lightweight recurring action

Cron Jobs

Cron is for predictable schedules:

bash
openclaw cron create "0 8 * * 1-5" \
  "Prepare my workday briefing: calendar, urgent email, weather, and open follow-ups." \
  --name "morning-briefing" \
  --session isolated

Manage jobs:

bash
openclaw cron list
openclaw cron show <job-id>
openclaw cron remove <job-id>

Recent OpenClaw versions report cron state through the current storage layer rather than assuming a legacy jobs file. Prefer CLI commands over hand-editing runtime state.

Background Tasks

Background tasks track work that should continue beyond a single foreground turn. They are important for:

  • isolated cron runs
  • ACP harness sessions
  • subagent work
  • long CLI operations
  • Task Flow steps

Use task status before assuming work failed:

bash
openclaw tasks list
openclaw tasks show <taskId>

Task Flow

Task Flow is the orchestration layer above background tasks. Use it when a workflow has multiple steps, checkpoints, or recoverable progress.

Good Task Flow candidates:

  • research then draft then review
  • deploy then verify then report
  • classify inbox then prepare replies then request approval
  • run checks then summarize failures then open follow-ups

Hooks

Hooks respond to OpenClaw events. A hook can run on lifecycle events, commands, session changes, outbound delivery, or other configured triggers.

Use hooks for:

  • formatting reply payloads
  • usage footers
  • Slack outbound notifications
  • custom audit trails
  • workflow-specific post-processing

Inspect hooks through:

bash
openclaw hooks list
openclaw hooks info <name>

Webhooks

Webhooks let external systems wake OpenClaw:

  • CI/CD notifications
  • issue tracker events
  • support queue events
  • monitoring alerts
  • Gmail Pub/Sub runners where configured

Keep webhook paths protected with tokens, bind locally when possible, and expose through a trusted reverse proxy or tunnel when remote access is required.

Standing Orders and Heartbeat

Standing orders define durable authority. Use them sparingly. A standing order should say what the agent may do, how often, with what data, and when it must ask.

Heartbeat is a periodic check-in. It is better for lightweight monitoring than exact schedules.

Example: Safe Email Triage

  1. Install/authorize the mail capability.
  2. Test read-only inbox search.
  3. Create labels manually.
  4. Schedule a cron job that classifies new messages.
  5. Draft replies but require confirmation before sending.
  6. Add a usage footer or summary hook if desired.
bash
openclaw cron create "*/20 * * * *" \
  "Review new unread mail since the last run. Label only. Draft replies for action-required items, but do not send." \
  --name "email-triage" \
  --session isolated

Failure Modes

Watch for:

  • cron jobs using stale credentials
  • background tasks still running after the user assumes they stopped
  • hooks that modify replies unexpectedly
  • webhooks reachable without enough auth
  • standing orders that are too broad
  • automation using a powerful main session when an isolated session would be safer

Proactive agent design

Automation needs authority boundaries. A good recurring task specifies trigger, session, tools, credentials, output channel, and stop conditions before it runs unattended.

Continue with practice

You have finished the core ideas of Automation.

If you want to turn the idea into something reusable, continue practicing on AgentWay.