Sleep Snooze
You have a sleep notification snooze system available. When the user is in their sleep window, incoming messages should be silently queued rather than delivered immediately. At wake time, a morning digest is automatically sent summarising all queued messages.
Sleep Schedule
The user's sleep schedule is configured via environment variables:
- -
SLEEP_START — time to begin snoozing (24h format, e.g. 22:00) - INLINECODE2 — time to deliver the digest and resume normal notifications (e.g.
06:00) - INLINECODE4 — IANA timezone (e.g.
Asia/Kolkata, America/New_York, Europe/London)
Slash Commands
Users can invoke these slash commands directly in chat:
- -
/sleep — manually activate sleep mode immediately (overrides schedule) - INLINECODE9 — manually deactivate sleep mode and trigger the morning digest now
- INLINECODE10 — show whether sleep mode is active, how many messages are queued, and what time the digest will be sent
- INLINECODE11 — interactively configure sleep start time, wake time, and timezone
- INLINECODE12 — show the last 7 days of digest summaries
Behaviour During Sleep Hours
Before sending ANY message to the user — including proactive notifications, summaries, heartbeats, weekly recaps, stock alerts, backup confirmations, or any other automated report — first check sleep state:
CODEBLOCK0
If isSleeping is true, do NOT send. Queue it instead (see below). This applies to both incoming messages from others AND outgoing messages you are about to send proactively.
Incoming messages during sleep
When a message or notification arrives during the sleep window:
- 1. Do not deliver a push notification or respond immediately.
- Call
node ~/.openclaw/skills/sleep-snooze/scripts/queue-message.js with the message payload to store it in the local queue. - Acknowledge silently — do not send any reply to the sender during sleep hours unless the message is tagged as urgent (see Urgency Rules below).
Outgoing messages you generate during sleep
When you (or any agent) are about to send a proactive message — status updates, recaps, reports, heartbeats — use gate.js instead of sending directly. It handles the sleep check and queuing automatically:
CODEBLOCK1
Exit codes:
- - 0 — sleeping, message was queued — do NOT send
- 2 — sleeping but urgent — send with 🚨 prefix
- 3 — awake — send normally
Use gate.js for ALL outgoing messages. It checks the actual current time against the schedule, so it works even if the sleep-mode cron did not run.
Urgency Rules
Some messages bypass snooze and are delivered immediately regardless of sleep hours. A message is considered urgent if any of the following match:
- - The sender is on the user's VIP contacts list (stored in
~/.openclaw/skills/sleep-snooze/data/vip-contacts.json) - The message contains any of these keywords (case-insensitive):
urgent, emergency, critical, 911, INLINECODE23 - The message was explicitly marked priority by the sending system
For urgent messages: deliver normally, prepend 🚨 [URGENT - received during sleep] to the notification.
Morning Digest
At WAKE_TIME each day, automatically:
- 1. Call
node ~/.openclaw/skills/sleep-snooze/scripts/digest.js to generate and send the digest. - The digest groups messages by sender, shows count, and includes a brief summary of each conversation thread.
- After sending, the queue is cleared.
Digest format (send as a single message per provider):
CODEBLOCK2
Setup Instructions
When the user runs /snooze-setup for the first time:
- 1. Ask for their sleep start time (e.g. "What time do you usually go to bed?")
- Ask for their wake time (e.g. "What time do you usually wake up?")
- Ask for their timezone (offer to detect it automatically using
date +%Z) - Run
node ~/.openclaw/skills/sleep-snooze/scripts/sleep-init.js to write config and register cron jobs - Confirm the schedule back to the user: "Sleep snooze is set: 🌙 10:00 PM → ☀️ 6:00 AM (IST). I'll queue notifications overnight and send your digest at 6:00 AM."
State Management
Sleep mode state is stored in ~/.openclaw/skills/sleep-snooze/data/state.json:
CODEBLOCK3
The message queue is stored in SQLite at ~/.openclaw/skills/sleep-snooze/data/queue.db.
Important Notes
- - Sleep snooze works across all connected providers (Telegram, WhatsApp, Discord, Slack, Signal) simultaneously.
- If the user asks "did I miss anything?" or similar during sleep hours, check queue size and respond: "You have X messages queued. I'll send your digest at [WAKE_TIME]."
- If the user sends a message themselves during their sleep window, it means they are awake — temporarily suspend sleep mode for 30 minutes.
- Never discard messages. If delivery fails, retry at next digest cycle.
睡眠免打扰
你拥有一个睡眠通知免打扰系统。当用户处于睡眠时段时,收到的消息应被静默排队,而非立即送达。在唤醒时间,系统会自动发送一份晨间摘要,汇总所有排队消息。
睡眠时间表
用户的睡眠时间表通过环境变量配置:
- - SLEEPSTART — 开始免打扰的时间(24小时制,例如 22:00)
- WAKETIME — 发送摘要并恢复正常通知的时间(例如 06:00)
- TIMEZONE — IANA时区(例如 Asia/Kolkata、America/New_York、Europe/London)
斜杠命令
用户可以直接在聊天中调用以下斜杠命令:
- - /sleep — 立即手动激活睡眠模式(覆盖时间表)
- /wake — 立即手动停用睡眠模式并触发晨间摘要
- /snooze-status — 显示睡眠模式是否激活、有多少条消息在排队,以及摘要将在何时发送
- /snooze-setup — 交互式配置睡眠开始时间、唤醒时间和时区
- /snooze-history — 显示最近7天的摘要汇总
睡眠时段行为
在向用户发送任何消息之前——包括主动通知、摘要、心跳、周报、股票提醒、备份确认或任何其他自动报告——请先检查睡眠状态:
bash
node ~/.openclaw/skills/sleep-snooze/scripts/status.js
如果 isSleeping 为 true,则不要发送。改为将其排队(见下文)。这既适用于来自他人的传入消息,也适用于你即将主动发送的外发消息。
睡眠期间的传入消息
当睡眠时段内收到消息或通知时:
- 1. 不要发送推送通知或立即回复。
- 调用 node ~/.openclaw/skills/sleep-snooze/scripts/queue-message.js,将消息负载存储到本地队列中。
- 静默确认——在睡眠时段内不要向发送者发送任何回复,除非消息被标记为紧急(见下方紧急规则)。
睡眠期间你生成的外发消息
当你(或任何代理)即将发送主动消息——状态更新、摘要、报告、心跳——时,请使用 gate.js 而非直接发送。它会自动处理睡眠检查和排队:
bash
node ~/.openclaw/skills/sleep-snooze/scripts/gate.js \
--provider \
--sender-id \
--sender-name \
--message <完整消息文本>
退出码:
- - 0 — 正在睡眠,消息已排队——不要发送
- 2 — 正在睡眠但紧急——发送时添加 🚨 前缀
- 3 — 已唤醒——正常发送
对所有外发消息使用 gate.js。它会根据实际当前时间与时间表进行比对,因此即使睡眠模式的定时任务未运行也能正常工作。
紧急规则
某些消息会绕过免打扰,无论是否在睡眠时段都会立即送达。如果满足以下任一条件,消息将被视为紧急:
- - 发送者在用户的VIP联系人列表中(存储在 ~/.openclaw/skills/sleep-snooze/data/vip-contacts.json)
- 消息包含以下任一关键词(不区分大小写):urgent、emergency、critical、911、help me
- 消息被发送系统明确标记为优先级
对于紧急消息:正常送达,并在通知前添加 🚨 [紧急 - 睡眠期间收到]。
晨间摘要
每天在 WAKE_TIME 时间,自动执行:
- 1. 调用 node ~/.openclaw/skills/sleep-snooze/scripts/digest.js 生成并发送摘要。
- 摘要按发送者分组消息,显示数量,并包含每个对话线程的简要总结。
- 发送后,队列被清空。
摘要格式(每个提供商发送为一条消息):
🌅 早上好!以下是您睡觉时收到的消息:
📬 来自 Alex 的 3 条消息
• 嘿,你明天有空吗?
• 还想分享这篇文章...
• 算了,回头聊!
📬 来自 GitHub 通知的 1 条消息
• PR #42 已合并到主分支
📬 来自服务器监控机器人的 2 条消息
• 03:14 CPU 峰值——已解决
• 磁盘使用率 78%——有空时检查
回复任何发送者的姓名即可回复他们的消息。
设置说明
当用户首次运行 /snooze-setup 时:
- 1. 询问他们的睡眠开始时间(例如您通常几点睡觉?)
- 询问他们的唤醒时间(例如您通常几点起床?)
- 询问他们的时区(提供使用 date +%Z 自动检测的选项)
- 运行 node ~/.openclaw/skills/sleep-snooze/scripts/sleep-init.js 写入配置并注册定时任务
- 向用户确认时间表:睡眠免打扰已设置:🌙 晚上10:00 → ☀️ 早上6:00(IST)。我会在夜间排队通知,并在早上6:00发送您的摘要。
状态管理
睡眠模式状态存储在 ~/.openclaw/skills/sleep-snooze/data/state.json:
json
{
sleepStart: 22:00,
wakeTime: 06:00,
timezone: Asia/Kolkata,
manualOverride: false,
isSleeping: false,
lastDigestAt: 2025-01-15T06:00:00.000Z
}
消息队列存储在 SQLite 数据库中,路径为 ~/.openclaw/skills/sleep-snooze/data/queue.db。
重要说明
- - 睡眠免打扰同时适用于所有已连接的提供商(Telegram、WhatsApp、Discord、Slack、Signal)。
- 如果用户在睡眠时段询问我错过了什么吗?或类似问题,请检查队列大小并回复:您有X条消息在排队。我将在[唤醒时间]发送您的摘要。
- 如果用户自己在睡眠时段发送消息,表示他们已醒来——暂时暂停睡眠模式30分钟。
- 切勿丢弃消息。如果发送失败,请在下一个摘要周期重试。