2026-02-19-building-your-first-automation-workflow-with-openclaw
Building Your First Automation Workflow with OpenClaw
OpenClaw empowers you to create powerful automation workflows that run on your own hardware, giving you complete control over your AI assistant and its interactions. Whether you want to monitor your inbox, manage your calendar, or execute complex multi-step processes, OpenClaw's robust tools provide the foundation. This guide will walk you through building your first automation using the core concepts of cron jobs and heartbeats.
Choosing the Right Tool: Cron vs Heartbeat
Before diving into building, it's crucial to understand when to use cron jobs versus the heartbeat mechanism. Both allow you to schedule tasks, but they serve different purposes and have distinct advantages.
The Heartbeat: Your Agent's Pulse
The heartbeat is like a periodic check-in. It occurs at regular intervals (typically every 30 minutes) and runs within your agent's main session. This is ideal for tasks that benefit from your agent's full context and memory.
Use the heartbeat when you need to:
-
Batch multiple checks together. Instead of running 3-4 separate cron jobs, your agent can scan your inbox, check your calendar, review notifications, and assess project status in a single, efficient heartbeat.
-
Make context-aware decisions. Your agent can use its knowledge of your recent tasks and priorities to determine what requires immediate attention versus what can wait.
-
Perform low-overhead monitoring. A single heartbeat is more efficient than multiple isolated cron jobs for routine health checks.
The heartbeat is controlled by the HEARTBEAT.md file in your workspace. When your agent receives a heartbeat poll, it checks this file for instructions. For example:
# HEARTBEAT.md
- Check email for urgent messages
- Review calendar for events in the next 2 hours
- If a background task finished, summarize the results
- If I've been idle for over 8 hours, send a brief check-in
Your agent processes all these items in one turn, replying with HEARTBEAT_OK if nothing needs attention, or with a summary of key findings.
Cron Jobs: Precision and Isolation
Cron jobs are perfect for tasks that require precise timing, isolation, or run completely independently of your main agent conversation.
Use cron jobs (isolated) when you need to:
- Run at an exact time. For instance, ensuring a "Good morning" message is sent at exactly 7:00 AM.
- Execute a standalone task. Run a weekly deep analysis that uses a different, more powerful model (like Opus) without interfering with your main session.
- Manage noisy or frequent tasks. Keep your main chat history clean by running routine reports in isolation.
- Schedule one-shot reminders. "Remind me to make that call in 20 minutes."
Cron jobs are created using the openclaw cron add command. Here's an example of a daily morning briefing that runs in an isolated session and delivers its summary directly to WhatsApp:
openclaw cron add \
--name "Morning briefing" \
--cron "0 7 * * *" \
--tz "America/New_York" \
--session isolated \
--message "Generate today's briefing: weather, calendar, top emails, news summary." \
--model opus \
--announce \
--channel whatsapp \
--to "+15551234567"
This job will execute every day at 7:00 AM, use Opus for its high-quality processing, generate a briefing, and announce a summary directly to your specified WhatsApp number.
The Decision Flowchart
To help you choose, follow this simple decision flow:
- Does it need to run at an EXACT time? โ Use cron.
- Does it need to run in a completely isolated environment? โ Use cron (isolated).
- Can it be bundled with other periodic checks (inbox, calendar, etc.)? โ Use heartbeat.
- Is it a one-shot reminder? โ Use cron with
--at.
The most powerful automation systems often combine both. Use the heartbeat for routine awareness and context-rich checks, and reserve cron jobs for precision timing, isolated heavy-lifting, and automated deliveries.
Your First Workflow in Action
Let's build a simple but practical workflow combining both concepts.
Step 1: Set Up Your Heartbeat Checklist
First, define what your agent should monitor periodically. Edit your HEARTBEAT.md file to include:
# HEARTBEAT.md
- Every 30 minutes, silently scan for new emails with "URGENT" in the subject and summarize them if found.
- Check if I have any meetings scheduled in the next 60 minutes and remind me 15 minutes before.
This gives your agent a persistent, context-aware presence.
Step 2: Automate a Daily Summary with Cron
Next, create a cron job to send you a comprehensive daily summary. This task is perfect for cron because it runs at a fixed time and delivers directly to your phone.
Run the following command to create the job:
openclaw cron add \
--name "Daily Summary" \
--cron "0 17 * * *" \
--tz "America/New_York" \
--session isolated \
--message "Compile a concise summary of today's key accomplishments, unresolved tasks, and a preview of tomorrow's priorities. Include any critical emails." \
--model llama \
--announce \
--channel whatsapp \
--to "+15551234567"
This job will trigger every workday at 5:00 PM, generating a summary and sending it directly to you.
Step 3: Create a One-Shot Reminder
Finally, let's add a one-time reminder. Maybe you need to remember an appointment in two hours:
openclaw cron add \
--name "Dentist appointment" \
--at "2h" \
--session main \
--system-event "Reminder: Dentist appointment in 30 minutes. Prepare everything now." \
--wake now \
--delete-after-run
This reminder will enqueue a system event in your main session two hours from now, and your next heartbeat will trigger immediately to deliver the alert.
Conclusion
You've now built a multi-layered automation workflow. Your agent maintains a regular pulse with the heartbeat for ongoing awareness, sends a scheduled report at day's end via a cron job, and can handle immediate one-off reminders. This combination of tools forms the foundation for building sophisticated, reliable automations that keep you informed and in control. Start with a few simple workflows, and as you become more comfortable, you can create even more complex systems to manage your digital life with ease.
Enjoyed this article?
Join the ClawMakers community to discuss this and more with fellow builders.
Join on Skool โ It's Free โ