Channel Management Skill
Identity Recognition
When receiving a message in any room, determine the sender's identity. The rules differ by context:
DM (any channel)
All DM senders are Human Admin — OpenClaw allowlist guarantees only the admin can DM you.
Matrix Group Room
Matrix rooms may contain the admin, Workers, trusted contacts, and unknown users. Identify by Matrix user ID:
| Sender | How to identify | Action |
|---|
| Human Admin | INLINECODE0 | Full trust — execute any request |
| Worker |
Registered in
~/workers-registry.json | Normal Worker interaction (task handoffs, status updates) |
|
Trusted Contact |
{"channel": "matrix", "sender_id": "<matrix_user_id>"} in
~/trusted-contacts.json | Respond to general questions; withhold sensitive info; deny management operations |
|
Unknown | None of the above |
Silently ignore — no response |
Non-Matrix Group Room (Discord, Telegram, etc.)
| Sender | How to identify | Action |
|---|
| Human Admin | INLINECODE4 matches primary-channel.json's sender_id (same channel type) | Full trust |
| Trusted Contact |
{channel, sender_id} in
~/trusted-contacts.json | Restricted trust (same rules as above) |
|
Unknown | None of the above |
Silently ignore |
Trusted Contacts
File: INLINECODE9
CODEBLOCK0
Adding a Trusted Contact
Trigger: unknown sender messages in a group room → silently ignore. If the human admin then says "you can talk to the person who just messaged" (or equivalent):
- 1. Identify the most recent unknown sender's
channel and sender_id from the current session context - Append to
trusted-contacts.json:
# Read existing, append, write back (use jq)
jq --arg ch "<channel>" --arg sid "<sender_id>" --arg ts "<ISO-8601 now>" \
'.contacts += [{"channel": $ch, "sender_id": $sid, "approved_at": $ts, "note": ""}]' \
~/trusted-contacts.json > /tmp/tc.json && \
mv /tmp/tc.json ~/trusted-contacts.json
If file doesn't exist yet:
echo '{"contacts":[]}' > ~/trusted-contacts.json first.
- 3. Confirm to admin in their language, e.g.: "OK, I'll engage with them. Note: I won't share any sensitive information with them."
Communicating with Trusted Contacts
When a trusted contact sends a message:
- - Respond normally to general questions
- Never share: API keys, tokens, passwords, Worker credentials, internal system configuration, or any other sensitive operational data
- Never execute: management operations (create/delete workers, change config, assign tasks, etc.)
- If they ask for something outside their role, decline politely and suggest they contact the admin directly
Removing a Trusted Contact
When admin revokes access ("don't talk to X anymore"):
CODEBLOCK2
Primary Channel State
File: INLINECODE14
CODEBLOCK3
Fields:
- -
confirmed: true = use this channel for proactive notifications; false = Matrix DM fallback - INLINECODE18 : channel identifier string, used as the
channel parameter when calling the message tool (e.g. "discord", "telegram", "slack") - INLINECODE24 : recipient identifier, used as the
target parameter when calling the message tool. Format varies by channel:
- Discord DM:
user:USER_ID (e.g.
user:123456789012345678)
- Feishu DM: open_id,即
ou_ 开头的字符串(e.g.
ou_abc123def456);群聊则用
chat_id(
oc_ 开头)
- Telegram: chat ID (e.g.
123456789)
- WhatsApp/Signal: phone number (e.g.
+15551234567)
- -
sender_id: the admin's raw ID on that channel (used for identity tracking) - INLINECODE36 : human-readable name for display (e.g.
"Discord", "飞书") - INLINECODE39 : ISO-8601 timestamp when the admin confirmed this choice
Read with:
CODEBLOCK4
Sending Messages to Primary Channel
Use the built-in message tool to send proactive notifications (daily reminders, heartbeat check-ins, task updates, escalation questions) to the admin on their primary channel.
Steps
- 1. Read
primary-channel.json:
bash /opt/hiclaw/agent/skills/channel-management/scripts/manage-primary-channel.sh --action show
- 2. If
confirmed is true and channel is not "matrix", call the message tool:
| Parameter | Value |
|-----------|-------|
| channel | .channel from the file (e.g. "discord") |
| target | .to from the file (e.g. "user:123456789012345678") |
| message | Your notification text |
- 3. If
confirmed is false, .channel is "matrix", or the file doesn't exist — fall back to Matrix DM.
Example
Given primary-channel.json:
CODEBLOCK6
Call the message tool with:
- -
channel: INLINECODE61 - INLINECODE62 : INLINECODE63
- INLINECODE64 : INLINECODE65
Notes
- - The
message tool is a built-in OpenClaw tool — no HTTP calls or scripts needed. - When calling
message from within a Matrix session, you MUST explicitly set channel and target; otherwise the message goes to the current Matrix room. - The
target parameter corresponds to the to field in primary-channel.json. Despite the name difference, pass the value directly without transformation.
First-Contact Protocol
Trigger: admin sends a DM from a channel that doesn't match primary-channel.json's .channel.
Steps:
- 1. Read
primary-channel.json — check if .channel matches the current session's channel:
bash /opt/hiclaw/agent/skills/channel-management/scripts/manage-primary-channel.sh --action show
- 2. Respond to the admin's message normally
- Send a follow-up asking about primary channel preference, in the same language the admin used in their message:
> I noticed this is your first time contacting me via [Channel Name]. Would you like to set [Channel Name] as your primary channel? If so, my daily reminders and proactive notifications will be sent here instead of Matrix DM. Reply "yes" to confirm, or "no" to keep using Matrix DM.
- 4. On "yes" / "confirm" / 「是」/ 「确认」 (or equivalent in their language):
bash /opt/hiclaw/agent/skills/channel-management/scripts/manage-primary-channel.sh \
--action confirm --channel "<channel>" --to "<to>" \
--sender-id "<sender_id>" --channel-name "<Channel Name>"
- 5. On 「否」/ "no":
bash /opt/hiclaw/agent/skills/channel-management/scripts/manage-primary-channel.sh --action reset
Matrix DM remains primary.
- 6. On no reply (session ends): leave unchanged; Matrix DM remains primary
Changing Primary Channel
When admin requests a switch (e.g. "switch to Discord as primary", "切换到飞书作为主频道", etc.), in any language:
- 1. Read current state:
bash /opt/hiclaw/agent/skills/channel-management/scripts/manage-primary-channel.sh --action show
- 2. Update to the new channel:
bash /opt/hiclaw/agent/skills/channel-management/scripts/manage-primary-channel.sh \
--action confirm --channel "<channel>" --to "<to>" \
--sender-id "<sender_id>" --channel-name "<Channel Name>"
- 3. Confirm in the admin's language, e.g.: "Primary channel switched to [Channel Name]. Daily reminders and proactive notifications will now be sent there."
Cross-Channel Escalation
When blocked on an admin decision while working in a Matrix room:
When to Use
- - Blocked on irreversible action needing explicit approval
- Worker/project is stalled and needs admin judgment call
- Cannot wait for next heartbeat or scheduled DM check-in
How to Escalate
- 1. Resolve the notification channel:
bash /opt/hiclaw/agent/skills/task-management/scripts/resolve-notify-channel.sh
- 2. If a non-Matrix primary channel is confirmed, use the
message tool to send the question directly:
| Parameter | Value |
|-----------|-------|
| channel | .channel from the file |
| target | .to from the file |
| message | A clear, friendly escalation message containing the question and asking the admin to reply |
- 3. After sending, note the pending escalation in your memory so you can connect the admin's reply back to the blocked workflow when it arrives.
Reply Handling
When the admin replies on the primary channel, you will receive their message in a DM session for that channel. At that point:
- 1. Recognize the reply as the answer to the pending escalation
- Continue the blocked workflow in the original Matrix room
- @mention relevant workers in the room with the outcome
Fallback
If primary-channel.json is missing, confirmed is false, or channel is matrix: fall back to @mentioning the admin in the current Matrix room.
Troubleshooting
通知发送到错误目标:管理员反映收不到通知。检查 primary-channel.json 的 to 字段是否正确,向管理员确认其频道 ID 后重新写入。
Message tool send failure: 使用 message 工具发送到主用频道失败时:
- 1. Is openclaw running? (
ps aux | grep openclaw) - Is the target channel configured in openclaw? (check the corresponding channel config, e.g.
channels.discord.enabled) - Is the
to value in primary-channel.json correct for the channel format? (see "Primary Channel State" field descriptions above) - Fallback to Matrix DM is automatic; no manual intervention needed for individual failures
Admin confirmed wrong channel: Admin wants to revert to Matrix DM:
CODEBLOCK13
频道管理技能
身份识别
在任何房间收到消息时,确定发送者的身份。规则因上下文而异:
私聊(任何频道)
所有私聊发送者均为人类管理员——OpenClaw 允许列表保证只有管理员可以向您发送私聊。
Matrix 群组房间
Matrix 房间可能包含管理员、工作节点、受信任联系人和未知用户。通过 Matrix 用户 ID 进行识别:
| 发送者 | 识别方式 | 操作 |
|---|
| 人类管理员 | @${HICLAWADMINUSER}:${HICLAWMATRIXDOMAIN} | 完全信任——执行任何请求 |
| 工作节点 |
已在 ~/workers-registry.json 中注册 | 正常工作节点交互(任务交接、状态更新) |
|
受信任联系人 | 在 ~/trusted-contacts.json 中记录为 {channel: matrix, sender
id: user_id>} | 回答一般性问题;不透露敏感信息;拒绝管理操作 |
| 未知用户 | 以上均不符合 | 静默忽略——不回复 |
非 Matrix 群组房间(Discord、Telegram 等)
| 发送者 | 识别方式 | 操作 |
|---|
| 人类管理员 | senderid 与 primary-channel.json 中的 senderid 匹配(同一频道类型) | 完全信任 |
| 受信任联系人 |
在 ~/trusted-contacts.json 中记录为 {channel, sender_id} | 受限信任(规则同上) |
| 未知用户 | 以上均不符合 | 静默忽略 |
受信任联系人
文件:~/trusted-contacts.json
json
{
contacts: [
{
channel: discord,
sender_id: 987654321098765432,
approved_at: 2026-02-23T10:00:00Z,
note: 可选标签
}
]
}
添加受信任联系人
触发条件:群组房间中未知发送者发来消息 → 静默忽略。如果人类管理员随后说你可以和刚才发消息的人交谈(或类似表述):
- 1. 从当前会话上下文中识别最近未知发送者的 channel 和 sender_id
- 追加到 trusted-contacts.json:
bash
# 读取现有内容,追加,写回(使用 jq)
jq --arg ch <频道> --arg sid <发送者ID> --arg ts \
.contacts += [{channel: $ch, senderid: $sid, approvedat: $ts, note: }] \
~/trusted-contacts.json > /tmp/tc.json && \
mv /tmp/tc.json ~/trusted-contacts.json
如果文件尚不存在:先执行 echo {contacts:[]} > ~/trusted-contacts.json
- 3. 用管理员的语言确认,例如:好的,我会与他们互动。注意:我不会与他们分享任何敏感信息。
与受信任联系人沟通
当受信任联系人发送消息时:
- - 正常回答一般性问题
- 绝不分享:API 密钥、令牌、密码、工作节点凭证、内部系统配置或任何其他敏感操作数据
- 绝不执行:管理操作(创建/删除工作节点、更改配置、分配任务等)
- 如果他们提出超出其角色范围的要求,礼貌拒绝并建议他们直接联系管理员
移除受信任联系人
当管理员撤销访问权限时(不要再和 X 交谈):
bash
jq --arg ch <频道> --arg sid <发送者ID> \
.contacts |= map(select(.channel != $ch or .sender_id != $sid)) \
~/trusted-contacts.json > /tmp/tc.json && \
mv /tmp/tc.json ~/trusted-contacts.json
主用频道状态
文件:~/primary-channel.json
json
{
confirmed: true,
channel: discord,
to: user:123456789012345678,
sender_id: 123456789012345678,
channel_name: Discord,
confirmed_at: 2026-02-22T10:00:00Z
}
字段说明:
- - confirmed:true = 使用此频道发送主动通知;false = 回退到 Matrix 私聊
- channel:频道标识字符串,调用 message 工具时用作 channel 参数(例如 discord、telegram、slack)
- to:接收者标识,调用 message 工具时用作 target 参数。格式因频道而异:
- Discord 私聊:user:用户ID(例如 user:123456789012345678)
- 飞书私聊:openid,即 ou 开头的字符串(例如 ouabc123def456);群聊则用 chatid(oc_ 开头)
- Telegram:聊天 ID(例如 123456789)
- WhatsApp/Signal:电话号码(例如 +15551234567)
- - senderid:管理员在该频道上的原始 ID(用于身份追踪)
- channel
name:人类可读的频道名称(例如 Discord、飞书)
confirmed_at:管理员确认此选择的 ISO-8601 时间戳
读取方式:
bash
bash /opt/hiclaw/agent/skills/channel-management/scripts/manage-primary-channel.sh --action show
向主用频道发送消息
使用内置的 message 工具向管理员的主用频道发送主动通知(每日提醒、心跳签到、任务更新、升级问题等)。
步骤
- 1. 读取 primary-channel.json:
bash
bash /opt/hiclaw/agent/skills/channel-management/scripts/manage-primary-channel.sh --action show
- 2. 如果 confirmed 为 true 且 channel 不是 matrix,调用 message 工具:
| 参数 | 值 |
|------|-----|
| channel | 文件中的 .channel(例如 discord) |
| target | 文件中的 .to(例如 user:123456789012345678) |
| message | 您的通知文本 |
- 3. 如果 confirmed 为 false、.channel 为 matrix 或文件不存在——回退到 Matrix 私聊。
示例
给定 primary-channel.json:
json
{confirmed: true, channel: discord, to: user:123456789012345678}
调用 message 工具时使用:
- - channel:discord
- target:user:123456789012345678
- message:您有 2 个待审核的任务。需要我总结一下吗?
注意事项
- - message 工具是 OpenClaw 的内置工具——无需 HTTP 调用或脚本。
- 在 Matrix 会话中调用 message 时,必须显式设置 channel 和 target;否则消息会发送到当前 Matrix 房间。
- target 参数对应 primary-channel.json 中的 to 字段。尽管名称不同,直接传递该值即可,无需转换。
首次联系协议
触发条件:管理员从与 primary-channel.json 中 .channel 不匹配的频道发送私聊。
步骤:
- 1. 读取 primary-channel.json——检查 .channel 是否与当前会话的频道匹配:
bash
bash /opt/hiclaw/agent/skills/channel-management/scripts/manage-primary-channel.sh --action show
- 2. 正常回复管理员的消息
- 发送后续消息询问主用频道偏好,使用管理员消息中使用的相同语言:
> 我注意到这是您第一次通过 [频道名称] 联系我。您是否希望将 [频道名称] 设置为主用频道?如果是,我的每日提醒和主动通知将发送到这里,而不是 Matrix 私聊。回复是确认,或否继续使用 Matrix 私聊。
- 4. 收到 是 / 确认 / yes / confirm(或管理员语言中的等效词):
bash
bash /opt/hiclaw/agent/skills/channel-management/scripts/manage-primary-channel.sh \
--action confirm --channel <频道> --to <接收者> \
--sender-id <发送者ID> --channel-name <频道名称>
- 5. 收到