Lesson 6. Automation#

Why you need this#

Until now, we’ve been communicating with the assistant on demand — sent a message, got a response. But OpenClaw can work on its own: check email on a schedule, send a morning summary every day, react to events. Automation turns the assistant from a “conversationalist” into a truly autonomous helper that works while you sleep.


Four automation mechanisms#

Mechanism Purpose Analogy
Heartbeat (pulse) Periodic checks An alarm that goes off every 30 minutes
Cron Scheduled tasks A planner with scheduled activities
Webhooks Reaction to external events A doorbell — someone arrives, the assistant reacts
Hooks Reaction to internal events An answering machine — triggered by a specific event

Heartbeat — the assistant’s “pulse”#

Heartbeat is the assistant periodically “waking up.” Every N minutes it wakes up, checks the situation, and decides if it needs to tell you something.

How to set up#

{
  agents: {
    defaults: {
      heartbeat: {
        every: "30m",        // every 30 minutes
        target: "last",      // send to where the last conversation was
      }
    }
  }
}

every — the interval. Examples: "15m" (15 minutes), "1h" (1 hour), "2h" (2 hours). A value of "0m" disables the pulse.

target — where to send messages:

  • "last" — to the last used messenger
  • "telegram", "whatsapp" — to a specific messenger
  • "none" — nowhere (the assistant works but stays silent)

The HEARTBEAT.md file#

Create a HEARTBEAT.md file in the workspace — this is the assistant’s checklist:

# Checklist on wake-up

- Are there urgent tasks for today?
- Check if any project deadlines have passed
- If it's daytime — briefly check if everything is in order

If nothing important is found, the assistant responds with HEARTBEAT_OK and stays silent.

Active hours#

To keep the assistant from disturbing you at night:

{
  agents: {
    defaults: {
      heartbeat: {
        every: "30m",
        target: "last",
        activeHours: {
          start: "09:00",      // from 9 AM
          end: "22:00",        // until 10 PM
          timezone: "America/New_York"
        }
      }
    }
  }
}

Cron — scheduled tasks#

Cron (pronounced “kron”) is a task scheduler. Unlike heartbeat, cron lets you set exact times and specific actions.

One-time reminder#

openclaw cron add \
  --name "Reminder" \
  --at "2026-02-20T10:00:00Z" \
  --session main \
  --system-event "Reminder: call the doctor" \
  --wake now \
  --delete-after-run

Let’s break it down:

  • --name — task name (for you)
  • --at — when to execute (date and time)
  • --session main — execute in the main session
  • --system-event — reminder text
  • --wake now — wake the assistant immediately
  • --delete-after-run — delete the task after execution

Quick “in N minutes” reminder#

openclaw cron add \
  --name "Phone call" \
  --at "20m" \
  --session main \
  --system-event "Time to call!" \
  --wake now

Daily task#

openclaw cron add \
  --name "Morning summary" \
  --cron "0 7 * * *" \
  --tz "America/New_York" \
  --session isolated \
  --message "Create today's summary: weather, tasks, important events." \
  --announce \
  --channel telegram \
  --to "123456789"

What does 0 7 * * * mean? This is the cron schedule format: minute hour day month day_of_week

  • 0 7 * * * — every day at 7:00 AM
  • 0 9 * * 1-5 — weekdays at 9:00 AM
  • 30 12 * * * — every day at 12:30 PM

Managing tasks#

# View all tasks
openclaw cron list

# Run a task manually (for testing)
openclaw cron run <task-id>

# View execution history
openclaw cron runs --id <task-id>

# Edit a task
openclaw cron edit <task-id> --message "New text"

# Delete a task
openclaw cron remove <task-id>

Two execution modes#

Mode Description When to use
main Executes in the main session (in the context of your conversation) Reminders, simple notifications
isolated Executes in a separate session Complex tasks, morning summaries, background checks

Webhooks — reaction to external events#

A webhook is an HTTP address that external services can send notifications to. For example, Gmail can notify about a new email, and GitHub — about a new commit.

Configuration in openclaw.json#

{
  hooks: {
    enabled: true,
    token: "your-secret-key",     // password for protection
    path: "/hooks",                // address for webhooks
    mappings: [
      {
        match: { path: "gmail" },      // react to path /hooks/gmail
        action: "agent",               // send to agent
        agentId: "main",
        deliver: true
      }
    ]
  }
}

Now an external service can send a request to http://your-server:18789/hooks/gmail, and the assistant will receive the notification.


Hooks — reaction to internal events#

Hooks are scripts that run on certain events within OpenClaw.

Built-in hooks#

Hook Event What it does
💾 session-memory /new Saves session context to memory before reset
📝 command-logger Any command Logs all commands to a file
🚀 boot-md Gateway start Executes instructions from BOOT.md on startup

Managing hooks#

# View available hooks
openclaw hooks list

# Enable a hook
openclaw hooks enable session-memory

# Disable a hook
openclaw hooks disable command-logger

# Detailed information
openclaw hooks info session-memory

Recommendation#

Enable the session-memory hook — it automatically saves important moments from the conversation to memory files on every /new. This way you won’t lose context:

openclaw hooks enable session-memory

Heartbeat or Cron — which to choose?#

Task Use
“Check the situation every 30 minutes” Heartbeat
“Send a summary at 9 AM every day” Cron
“Remind me in 20 minutes” Cron (one-time)
“Check for updates once a week” Cron
“Stay alert in case something happens” Heartbeat

General rule: heartbeat — for “stay in the loop,” cron — for “do it at a specific time.”


Lesson summary#

  • Heartbeat — periodic assistant “wake-up” for checking the situation
  • Cron — tasks on a precise schedule (reminders, daily summaries)
  • Webhooks — reaction to external events (new email, GitHub commit)
  • Hooks — reaction to internal OpenClaw events (session reset, startup)
  • The HEARTBEAT.md file is a checklist for heartbeat checks
  • Enable the session-memory hook for automatic context saving
  • Heartbeat is for monitoring, Cron is for scheduled actions

Next lesson: Mobile Devices (Nodes)