Advanced Automation with OpenClaw
Heartbeats, webhooks, multi-step workflows, and production patterns
Heartbeats, webhooks, multi-step workflows, and production patterns
This tutorial builds on the basic automation tutorial (cron jobs and webhooks). Here you add heartbeats for periodic checks, webhook-triggered flows, multi-step and multi-agent patterns, and error handling. Plan for about 30-40 minutes. Full options: Automation Reference.
Heartbeats run on an interval (e.g. every 5 or 15 minutes). Use for monitoring, health checks, or lightweight recurring tasks.
{
"heartbeat": {
"intervalMinutes": 15,
"command": "agent --message 'Check for urgent items: unread important emails, calendar in next 2 hours. Reply only if something needs attention.'"
}
}
Configure in the same config file as cron. Restart the Gateway after changes. For heavy workloads use a less frequent cron to avoid overlapping runs.
Webhooks let external systems (GitHub, Sentry, CI/CD) trigger the agent via HTTP. Exact schema and auth are in the Automation Reference. Always secure webhook endpoints: bind to localhost and put a reverse proxy with TLS and auth in front.
Chained cron jobs: one cron writes to a file or queue; another picks it up and runs the agent. Or use sub-agents: Set Up a Sub-Agent, Multi-Agent Team. Use Shared Context so multiple agents read/write the same state.
Check Gateway logs for cron/heartbeat/webhook runs. In the command you can ask the agent to send you a message only on failure. Design commands to be idempotent so re-running after a crash does not duplicate side effects.
Use a cheaper model for simple scheduled tasks and a stronger model for complex or user-facing work. See ClawRouter and Configuration reference.