Fixes and updates: - README.md: Remove duplicate heartbeat troubleshooting section - docs/getting-started.md: Fix Node version (18→20), commands, repo URL - docs/commands.md: Rewrite with accurate command list (/start, /status, /heartbeat) - docs/README.md: New multi-channel architecture diagram - docs/whatsapp-setup.md: Add selfChatMode safety docs, media support section - docs/slack-setup.md: Fix broken links New documentation: - docs/configuration.md: Complete YAML config reference - docs/cron-setup.md: Scheduling guide (cron jobs + heartbeats) Written by Cameron ◯ Letta Code "Documentation is a love letter that you write to your future self." - Damian Conway
4.1 KiB
4.1 KiB
Scheduling Tasks (Cron & Heartbeat)
LettaBot supports two types of background tasks:
- Cron jobs: Send scheduled messages at specific times
- Heartbeats: Periodic agent check-ins
Enabling Background Tasks
Add to your lettabot.yaml:
features:
cron: true
heartbeat:
enabled: true
intervalMin: 60 # Every 60 minutes
Or via environment variables:
CRON_ENABLED=true
HEARTBEAT_ENABLED=true
HEARTBEAT_INTERVAL_MIN=60
Cron Jobs
Schedule tasks that send you messages at specific times.
Creating a Job
lettabot-cron create \
--name "Morning Briefing" \
--schedule "0 8 * * *" \
--message "Good morning! Review tasks for today." \
--deliver telegram:123456789
Options:
--name- Job name (required)--schedule- Cron expression (required)--message- Message sent when job runs (required)--deliver- Where to send:channel:chatId(defaults to last messaged chat)
Managing Jobs
lettabot-cron list # Show all jobs
lettabot-cron delete <id> # Delete a job
lettabot-cron enable <id> # Enable a job
lettabot-cron disable <id> # Disable a job
Cron Expression Syntax
┌───────── minute (0-59)
│ ┌─────── hour (0-23)
│ │ ┌───── day of month (1-31)
│ │ │ ┌─── month (1-12)
│ │ │ │ ┌─ day of week (0-6, Sun=0)
* * * * *
Examples:
| Expression | When |
|---|---|
0 8 * * * |
Daily at 8:00 AM |
0 9 * * 1-5 |
Weekdays at 9:00 AM |
0 */2 * * * |
Every 2 hours |
30 17 * * 5 |
Fridays at 5:30 PM |
0 0 1 * * |
First of month at midnight |
Example Jobs
Daily morning check-in:
lettabot-cron create \
-n "Morning" \
-s "0 8 * * *" \
-m "Good morning! What's on today's agenda?"
Weekly review:
lettabot-cron create \
-n "Weekly Review" \
-s "0 17 * * 5" \
-m "Friday wrap-up: What did we accomplish this week?"
Hourly reminder:
lettabot-cron create \
-n "Hydration" \
-s "0 * * * *" \
-m "Time to drink water!"
Heartbeats
Heartbeats are periodic check-ins where the agent can:
- Review pending tasks
- Check reminders
- Perform proactive actions
Configuration
features:
heartbeat:
enabled: true
intervalMin: 60 # Default: 60 minutes
Manual Trigger
You can trigger a heartbeat manually via the /heartbeat command in any channel.
How It Works
- At each interval (or when
/heartbeatis called), the agent receives a heartbeat message - The agent runs in Silent Mode - responses are not automatically delivered
- If the agent wants to message you, it must use
lettabot-message send
This prevents unwanted messages while allowing proactive behavior when needed.
Silent Mode
Both cron jobs and heartbeats run in Silent Mode:
- The agent's text output is NOT automatically sent to users
- The agent sees a
[SILENT MODE]banner with instructions - To send messages, the agent must explicitly run:
lettabot-message send --text "Your message here"
Requirements for background messaging:
- Bash tool must be enabled for the agent
- A user must have messaged the bot at least once (establishes delivery target)
Monitoring & Logs
Check Job Status
lettabot-cron list
Shows:
- Job ID, name, schedule
- Next run time
- Last run status
Log Files
cron-jobs.json- Job configurationscron-log.jsonl- Execution logs
Troubleshooting
Cron jobs not running
- Check
features.cron: truein config - Verify schedule expression is valid
- Check
lettabot-cron listfor next run time
Agent not sending messages during heartbeat
- Check if Bash tool is enabled (agent needs to run CLI)
- Verify a user has messaged the bot at least once
- Check the ADE to see agent activity
Jobs running but no messages received
The agent runs in Silent Mode - it must actively choose to send messages. Check the agent's behavior in the ADE to see what it's doing during background tasks.