Complex OpenClaw Automations: Cron vs Heartbeat, and the Three Ways Agents Send Messages

Complex OpenClaw Automations: Cron vs Heartbeat, and the Three Ways Agents Send Messages
Get in touch or AI consulting Join the AI Community & Comprehensive Online Courses for All Levels

A reminder that says “go work out” every hour is easy. A reminder that also takes your agent’s files into account, notices you wrote “I’m at my grandmother’s, don’t bother me” twenty minutes ago, and stops nagging after you ignored it twice is a different animal. Ariel walks through OpenClaw’s automation tools, then its communication tools, and then shows three concrete builds where the trick is combining them in the right order.

The three goals

He sets the bar with three examples he promises to solve by the end:

  • A workout reminder with context: remind me every hour or every day, but take into account what’s in the agent’s files (say SOUL.md and MEMORY.md) and what I said in the chat. If I wrote “I’m at grandma’s, don’t disturb”, it should react to that.
  • A security alert that gets handled: not just “Ariel, there’s a security alert, do something”, but “go handle it, and when you’re done, tell me what happened, what you did, and whether I want a follow-up.”
  • Ariel’s own workout nag: an alert every hour, but if he missed two in a row without answering, stop nagging. If he reports in, start again. And always nag in a funny way.

Automation tool one: cron

OpenClaw is a platform for autonomous agents, and “autonomous” means that every so often, every half hour, every hour, every day, something wakes them up and says “go”. The first way is cron, a scheduler: it exists in Linux too. Set a cron for every hour and ten minutes, and every hour and ten minutes it wakes up on the server or computer. No AI involved yet, it’s just a reminder. One of the things it can do is send a message to your agent, or spin up a new session for it.

That’s where sessions come in. Say you define an agent called Roni, with its own folder, files and personality settings. Talking to Roni over WhatsApp is one session, Telegram is another, and the two conversations don’t know about each other. But if Roni’s files say “you always love blue”, Roni loves blue in both.

Automation tool two: heartbeat

A heartbeat is basically a cron that reads a file called HEARTBEAT.md to get its prompt. With cron you write a simple prompt, with heartbeat you can write a complex one.

Both have two modes, and this is the part to understand:

  • Main session mode. In cron it’s called a system event, in heartbeat it runs in the main session. The agent takes the instructions (the cron prompt or HEARTBEAT.md) as if you had typed them yourself in, say, your WhatsApp session, and starts working, with the whole conversation history sent along.
  • Isolated mode. A brand-new session that has nothing to do with yours. Here the two behave differently in Ariel’s testing: an isolated cron knows only your prompt, with no Roni to speak of, just the AI. An isolated heartbeat loads the agent’s memory, soul, identity and tools files, so it doesn’t have the conversation, but it does “know who Roni is and what he’s supposed to do in life”. There’s also a light-context isolated heartbeat that loads only HEARTBEAT.md, which is close to an isolated cron.

One detail that matters later: in main-session mode, the prompt and the answers get recorded in the conversation behind the scenes, even though you never see them in WhatsApp. Ariel shows it from his comparison repo: he asked the agent for its last ten messages, and it listed messages it had “written to itself”, system prompts and its own replies, that never appeared on his phone. An isolated run is a separate conversation, so asking “what were our last messages?” won’t show it. And if you ask an isolated run to deliver a result, it sends a message to your channel, but that message doesn’t get recorded in your conversation. Hold that thought.

The three communication tools

OpenClaw has three built-in ways for an agent to talk:

  1. The message tool: send a message to a channel. It does not trigger the agent.
  2. Session send (sessions_send): send a message into another session, which does trigger that agent.
  3. An OpenAI-style completions endpoint: off on a clean install, you have to enable it in the settings. It’s not the same code path, but it behaves roughly like session send.

The difference, with his guests example:

  • In a cron, tell the agent “use the message tool and send me: Hi Roni, how many guests are coming tonight?” You get that exact text on WhatsApp, and it’s recorded in your session history, so the agent will see it if you ask for recent messages. But nothing else happens. The agent doesn’t react to it.
  • Tell it instead “use session send: Roni, how many guests are coming tonight?” Now Roni answers, “three guests”. But who gets the answer? The cron does. The question and the answer are both in the history, and you see nothing on WhatsApp.
  • The secret is to use both: session send with the prompt “Roni, tell me how many guests are coming tonight, and send the answer to me with the message tool.” Now the history shows three messages (the question, Roni’s answer, and “Ariel, there are three guests tonight”), and WhatsApp shows you only the last one.

Solving example one: the workout reminder

The setup: the cron or heartbeat prompt says “remind me to work out”. The agent’s files say “with every message, you must think about laundry”. And in the chat, Ariel wrote “I’m at my grandmother’s right now, don’t bother me.”

  • Cron with only the message tool: you get “reminding you to work out.” That’s it. No cooperation from the agent at all.
  • Full heartbeat: since it knows the files, you get a workout reminder that mentions laundry.
  • Session send to the main session: it doesn’t matter anymore if it’s cron or heartbeat, isolated or not, because session send goes to the full session. The agent thinks: “the user needs to work out, with a thought about laundry, but he’s at his grandmother’s, so it’s probably not relevant, maybe I’ll remind him later.” And then nothing happens, because it answered the cron. A smart enough agent might set itself a reminder, but don’t count on it.
  • Session send that tells the agent to use the message tool: now it both thinks and sends: “you should work out, with laundry, but you’re at grandma’s, so maybe I’ll remind you later.”

To get all three things considered, you need session send and the message tool. And once you’re doing that, there’s a real advantage to running the trigger isolated: you don’t load the agent or the AI with the trigger itself, everything runs faster, and you avoid the occasional weirdness of piling everything on the main session.

Solving example two: the security alert

Each step gets its own tool:

  1. The daily security review runs as an isolated cron, unless it’s very multi-step. It can be told to read this file and that file and work quietly in the background without bothering anyone.
  2. If there’s an issue, Ariel wants his agent to handle it, the one he’s chatting with on WhatsApp, because that agent knows exactly what they talked about and did recently. In an organization you could arrange all of that in files, and maybe that’s the right way there, but at his own computer he wants the agent that’s up to date. So the cron sends the issue with session send: “if there’s a problem, handle it; either way, update me at the end.”
  3. The update goes out with the message tool. No issue, everything stays quiet in the background. A real issue wakes the agent, and only if the agent decides it really needed handling does it use the third tool and tell him.

Solving example three: Ariel’s workout nag

First attempt: an isolated cron every hour. The problem: a cron wakes up every hour no matter what, so when it decided “don’t nag right now” it sent him a message saying it’s not nagging right now. A bit annoying.

The fix was an intermediate step. The hourly cron uses session send to the main agent. The main agent checks a small state file Ariel jokingly calls his “database”, which records whether he reported in, or missed twice in a row. Missed twice: silence. Reported in: the nagging restarts. Otherwise: it nags, via the message tool.

The bonus he didn’t expect: because the nag goes through the main session, the agent knows what day it is, what happened yesterday, and what kind of mood he’s in today. If the cron just said “write something funny”, it would come out roughly the same every time. This way, every message is different and reacts to what he said before.

The full comparison between cron and heartbeat and between the three tools, with his research, is in his repository, in English, plus an Excel file you can download. His suggestion: hand the video or the Excel to your own OpenClaw, tell it “learn this, this is how I want my automations”, and let it build them.

🔥 Roast Corner

Let’s appreciate what was engineered here. A man built a three-stage pipeline (an isolated cron, a cross-session message, and a stateful “database”) to manage one thing: being reminded to exercise. And the headline feature of this system is that if he ignores it twice, it stops reminding him. That’s not a fitness tracker. That’s a very sophisticated permission slip to skip the gym, with cron-grade reliability.

The first version was even better: every hour, the cron woke up specifically to tell him it wasn’t going to bother him. Which is exactly what a gym membership does, except the gym sends that message once a month and charges for it.

And spare a thought for the test agent, whose files order it to “think about laundry with every message”. Somewhere in a data center, a frontier model with billions of parameters is weighing a workout, a load of whites, and a grandmother, and deciding the polite thing is to say nothing. That’s the most emotionally intelligent thing in this whole setup, and it’s not the guy on the couch.

🤖 AI for Humans

A good automation knows when to wake someone up. In Brazil, researchers at Cemaden, the national center for monitoring and early warning of natural disasters under the Ministry of Science, Technology and Innovation, built FloodcastingXAI, an AI platform that predicts rising river levels one to four hours ahead. It pulls data from equipment already in the monitoring networks, rain gauges and river-level sensors, updated every ten minutes, and AI models trained to recognize patterns estimate how the water will behave in the coming hours.

That extra time is what lets civil defense teams warn residents, organize evacuations of threatened areas and take protective steps before a flash flood hits. Two details stand out: the system explains how it reached each prediction, and it’s open source, so other teams can share and improve it. It doesn’t replace the professionals who issue the alerts, it gives them a forecast instead of only what’s already happening. It comes out of the iFast project, more than 60 researchers from 15 institutions, with partners including INPE and the São Paulo city government. Source: Government of Brazil (Secom).

Get in touch or AI consulting Join the AI Community & Comprehensive Online Courses for All Levels

💬 Comments