📊 Module Progress
🎯 Learning Objectives
📚 Theory
What is Automation?
Automation = Tasks that run automatically at specific times or intervals.
OpenClaw can do things on a schedule — like a personal assistant who works while you sleep.
Examples
- Daily weather report every morning at 8AM
- Check email and notify you every 2 hours
- Backup important files every Sunday at midnight
- Send "Good morning" to your Telegram every day
How OpenClaw Handles Automation: Cron Jobs
Cron is a time-based job scheduler. OpenClaw uses it to schedule tasks.
Cron Job Structure:
{
"name": "Morning Weather",
"schedule": {
"kind": "cron",
"expr": "0 8 * * *",
"tz": "Asia/Kuala_Lumpur"
},
"payload": {
"kind": "systemEvent",
"text": "Check weather in Ipoh and send to Telegram"
},
"sessionTarget": "main"
}
- name: Identifies the job.
- schedule: When to run (8AM daily, MYT timezone).
- payload: What to do.
- sessionTarget: Where to run it (main session = your chat).
Schedule Types
1. at — One-Time
Run once at a specific date/time.
"schedule": { "kind": "at", "at": "2026-12-25T08:00:00+08:00" }
2. every — Recurring Interval
Run every X minutes/hours/days.
"schedule": { "kind": "every", "everyMs": 3600000 } // Every hour
3. cron — Cron Expression
Run on a schedule (like "every Monday at 9AM").
"schedule": { "kind": "cron", "expr": "0 9 * * 1", "tz": "Asia/Kuala_Lumpur" }
Cron expression breakdown:0 9 * * 1
│ │ │ │ └─ Day of week (0-6, 0=Sunday)
│ │ │ └─── Month (1-12)
│ │ └───── Day of month (1-31)
│ └─────── Hour (0-23)
└───────── Minute (0-59)
Setting Up Your First Cron Job
Method 1: Via Chat (Easiest)
You: "Remind me in 20 minutes to check the oven."
JiXe: "Got it! I'll remind you at [time]." creates cron job
Method 2: Via Config (Advanced)
Edit openclaw.json → add to cron.jobs array → restart gateway.
Best Practices
- Don't Overload — Too many cron jobs = OpenClaw busy all the time. Keep it reasonable (5-10 jobs max).
- Batch Similar Checks — Instead of 3 separate jobs (email, calendar, weather), make 1 job that does all 3.
- Use Heartbeat for Frequent Checks — If you need something checked every 30 minutes, use
HEARTBEAT.mdinstead of cron.
Key Takeaway
Automation makes OpenClaw work for you even when you're not actively chatting. Start simple, then expand!
🧪 Hands-On Exercise
Design a cron job for a real use case.
Step 1: Choose Your Use Case
Pick one: Daily weather report at 8AM • Reminder to drink water every 2 hours • Weekly summary every Sunday at 6PM • Custom: ________
Step 2: Determine Schedule Type
One-time? → kind: "at" | Regular interval? → kind: "every" | Complex schedule? → kind: "cron"
Step 3: Write the Cron Expression (if using cron)
Example: Every day at 8AM"expr": "0 8 * * *"
Your turn:
Use case: ________
Cron expression: ________
Step 4: Write the Payload (What to do)
Example:
{
"payload": {
"kind": "systemEvent",
"text": "Check weather in Ipoh and send to Telegram"
}
}
Your turn: Action: ________
Step 5: Assemble Full Cron Job
{
"name": "YOUR JOB NAME",
"schedule": {
"kind": "YOUR KIND",
"expr": "YOUR EXPRESSION"
},
"payload": {
"kind": "systemEvent",
"text": "YOUR ACTION"
},
"sessionTarget": "main"
}
Example Completed Job (Daily Backup)
{
"name": "Daily Backup",
"schedule": {
"kind": "cron",
"expr": "0 2 * * *",
"tz": "Asia/Kuala_Lumpur"
},
"payload": {
"kind": "systemEvent",
"text": "Backup C:\\Important\\ to cloud storage"
},
"sessionTarget": "isolated",
"failureAlert": {
"channel": "telegram",
"to": "YOUR-CHAT-ID",
"after": 1
}
}
Bonus: Uses isolated session and failure alert to Telegram.
📝 Quiz: Automation Basics
Q1: Cron is used for:
Q2: Which schedule type runs "every 2 hours"?
kind: "at"
kind: "every" with everyMs: 7200000
kind: "cron" with expr "*/2 * * * *"
kind: "magic"