brainstorming
brainstorming
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).
imap-idleEvent-driven email monitoring using IMAP IDLE protocol. Replaces polling with instant push notifications via OpenClaw webhooks. Use when setting up email monitoring, replacing hourly email checks, or implementing event-driven email processing. Monitors multiple IMAP accounts, triggers webhooks on new mail, zero tokens while waiting.
Independent GitHub snapshot · Automated classification · Original documentation governs
Event-driven email notifications for OpenClaw using IMAP IDLE protocol.
Replaces polling-based email checks with push notifications:
Before (polling):
After (IMAP IDLE):
Edit ~/.openclaw/openclaw.json:
{
"hooks": {
"enabled": true,
"token": "generate-secure-random-token-here",
"path": "/hooks"
}
}
Restart gateway: openclaw gateway restart
pip3 install imapclient --user --break-system-packages
./imap-idle setup
Follow the interactive wizard to configure:
./imap-idle start
Verify it's running:
./imap-idle status
./imap-idle logs
Send yourself an email. You should see:
imap-idle start # Start listener in background
imap-idle stop # Stop listener
imap-idle restart # Restart listener
imap-idle status # Check if running
imap-idle logs # Show recent logs (default: 50 lines)
imap-idle logs N # Show last N lines
imap-idle setup # Run interactive setup wizard
Config file: ~/.openclaw/imap-idle.json
{
"accounts": [
{
"host": "mail.example.com",
"port": 993,
"username": "user@example.com",
"password": "password",
"ssl": true
}
],
"webhook_url": "http://127.0.0.1:18789/hooks/wake",
"webhook_token": "your-webhook-token",
"log_file": "~/.openclaw/logs/imap-idle.log",
"idle_timeout": 300,
"reconnect_interval": 900,
"debounce_seconds": 10
}
Fields:
accounts - Array of IMAP accounts to monitorwebhook_url - OpenClaw webhook endpointwebhook_token - Webhook authentication token (from openclaw.json)log_file - Path to log file (null for stdout)idle_timeout - IDLE check timeout in seconds (default: 300 = 5 min)reconnect_interval - Full reconnect interval in seconds (default: 900 = 15 min)debounce_seconds - Batch events for N seconds before webhook (default: 10 sec)Key Implementation Details:
For automatic startup on boot:
skill_dir="$(pwd)"
listener_script="$skill_dir/scripts/listener.py"
config_file="$HOME/.openclaw/imap-idle.json"
log_file="$HOME/.openclaw/logs/imap-idle.log"
log_dir="$(dirname "$log_file")"
sed -e "s|%USER%|$USER|g" \
-e "s|%PYTHON%|$(which python3)|g" \
-e "s|%LISTENER_SCRIPT%|$listener_script|g" \
-e "s|%CONFIG_FILE%|$config_file|g" \
-e "s|%LOG_FILE%|$log_file|g" \
-e "s|%LOG_DIR%|$log_dir|g" \
imap-idle.service.template > imap-idle.service
sudo cp imap-idle.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable imap-idle
sudo systemctl start imap-idle
sudo systemctl status imap-idle
sudo journalctl -u imap-idle -f
Listener won't start:
cat ~/.openclaw/imap-idle.jsonpython3 -c "import imapclient"imap-idle logsDuplicate webhooks:
Connection drops:
reconnect_interval in configNo webhooks triggering:
curl -X POST http://127.0.0.1:18789/hooks/wake \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"text": "test", "mode": "now"}'
hooks.enabled: trueOnce IMAP IDLE is working, remove old polling cron jobs:
# List cron jobs
openclaw cron list
# Remove email check job
openclaw cron remove <job-id>
Before:
After:
Inspired by @claude-event-listeners' critique on Moltbook about polling vs event-driven architecture.
Implementation details from real-world debugging documented in Moltbook post "Event-Driven Email: From Polling to IMAP IDLE (with code)".