BlueBubbles (macOS REST)
状态:内置 Plugin,通过 HTTP 与 BlueBubbles macOS 服务器通信。推荐用于 iMessage 集成,相比旧版 imsg Channel,它的 API 更丰富,设置也更简单。
概述
- 通过 BlueBubbles 辅助应用在 macOS 上运行(bluebubbles.app)。
- 推荐/测试版本:macOS Sequoia (15)。macOS Tahoe (26) 可以运行,但编辑功能目前在 Tahoe 上有问题,群组图标更新可能显示成功但实际不同步。
- OpenClaw 通过 REST API 与它通信(
GET /api/v1/ping、POST /message/text、POST /chat/:id/*)。 - 接收消息通过 Webhook 到达;发送回复、输入状态、已读回执和表情回应都是 REST 调用。
- 附件和贴纸会作为入站媒体接收(并在可能的情况下提供给 Agent)。
- Pairing/白名单的工作方式与其他 Channel 相同(
/start/pairing等),使用channels.bluebubbles.allowFrom+ 配对码。 - 表情回应会作为系统事件呈现,就像 Slack/Telegram 一样,Agent 可以在回复前”提及”它们。
- 高级功能:编辑、撤回、回复线程、消息效果、群组管理。
快速开始
- 在你的 Mac 上安装 BlueBubbles 服务器(按照 bluebubbles.app/install 的说明操作)。
- 在 BlueBubbles 配置中,启用 web API 并设置密码。
- 运行
openclaw onboard并选择 BlueBubbles,或手动配置:{ channels: { bluebubbles: { enabled: true, serverUrl: "http://192.168.1.100:1234", password: "example-password", webhookPath: "/bluebubbles-webhook", }, }, } - 将 BlueBubbles Webhook 指向你的 Gateway(示例:
https://your-gateway-host:3000/bluebubbles-webhook?password=<password>)。 - 启动 Gateway;它会注册 Webhook 处理器并开始配对。
引导设置
BlueBubbles 可以在交互式设置向导中使用:
openclaw onboard
向导会提示输入:
- Server URL(必填):BlueBubbles 服务器地址(例如
http://192.168.1.100:1234) - Password(必填):BlueBubbles Server 设置中的 API 密码
- Webhook path(可选):默认为
/bluebubbles-webhook - DM policy:pairing、allowlist、open 或 disabled
- Allow list:电话号码、邮箱或聊天目标
你也可以通过 CLI 添加 BlueBubbles:
openclaw channels add bluebubbles --http-url http://192.168.1.100:1234 --password <password>
访问控制(DM + 群组)
DM:
- 默认:
channels.bluebubbles.dmPolicy = "pairing"。 - 未知发送者会收到配对码;消息会被忽略直到批准(配对码 1 小时后过期)。
- 批准方式:
openclaw pairing list bluebubblesopenclaw pairing approve bluebubbles <CODE>
- Pairing 是默认的令牌交换方式。详情:Pairing
群组:
channels.bluebubbles.groupPolicy = open | allowlist | disabled(默认:allowlist)。channels.bluebubbles.groupAllowFrom控制当设置为allowlist时谁可以在群组中触发。
提及门控(群组)
BlueBubbles 支持群聊的提及门控,匹配 iMessage/WhatsApp 的行为:
- 使用
agents.list[].groupChat.mentionPatterns(或messages.groupChat.mentionPatterns)来检测提及。 - 当为群组启用
requireMention时,Agent 只在被提及时才会响应。 - 来自授权发送者的控制命令会绕过提及门控。
按群组配置:
{
channels: {
bluebubbles: {
groupPolicy: "allowlist",
groupAllowFrom: ["+15555550123"],
groups: {
"*": { requireMention: true }, // 所有群组的默认设置
"iMessage;-;chat123": { requireMention: false }, // 特定群组的覆盖设置
},
},
},
}
命令门控
- 控制命令(例如
/config、/model)需要授权。 - 使用
allowFrom和groupAllowFrom来确定命令授权。 - 授权发送者可以在群组中运行控制命令,即使没有提及。
输入状态 + 已读回执
- 输入指示器:在响应生成之前和期间自动发送。
- 已读回执:由
channels.bluebubbles.sendReadReceipts控制(默认:true)。 - 输入指示器:OpenClaw 发送输入开始事件;BlueBubbles 在发送或超时时自动清除输入状态(通过 DELETE 手动停止不可靠)。
{
channels: {
bluebubbles: {
sendReadReceipts: false, // 禁用已读回执
},
},
}
高级操作
BlueBubbles 在配置中启用时支持高级消息操作:
{
channels: {
bluebubbles: {
actions: {
reactions: true, // 表情回应(默认:true)
edit: true, // 编辑已发送消息(macOS 13+,在 macOS 26 Tahoe 上有问题)
unsend: true, // 撤回消息(macOS 13+)
reply: true, // 通过消息 GUID 回复线程
sendWithEffect: true, // 消息效果(slam、loud 等)
renameGroup: true, // 重命名群聊
setGroupIcon: true, // 设置群聊图标/照片(在 macOS 26 Tahoe 上不稳定)
addParticipant: true, // 向群组添加参与者
removeParticipant: true, // 从群组移除参与者
leaveGroup: true, // 离开群聊
sendAttachment: true, // 发送附件/媒体
},
},
},
}
可用操作:
- react:添加/移除表情回应(
messageId、emoji、remove) - edit:编辑已发送的消息(
messageId、text) - unsend:撤回消息(
messageId) - reply:回复特定消息(
messageId、text、to) - sendWithEffect:使用 iMessage 效果发送(
text、to、effectId) - renameGroup:重命名群聊(
chatGuid、displayName) - setGroupIcon:设置群聊的图标/照片(
chatGuid、media)— 在 macOS 26 Tahoe 上不稳定(API 可能返回成功但图标不同步)。 - addParticipant:将某人添加到群组(
chatGuid、address) - removeParticipant:从群组移除某人(
chatGuid、address) - leaveGroup:离开群聊(
chatGuid) - sendAttachment:发送媒体/文件(
to、buffer、filename、asVoice)- 语音备忘录:使用 MP3 或 CAF 音频设置
asVoice: true以作为 iMessage 语音消息发送。BlueBubbles 在发送语音备忘录时会将 MP3 转换为 CAF。
- 语音备忘录:使用 MP3 或 CAF 音频设置
消息 ID(短 ID vs 完整 ID)
OpenClaw 可能会显示 短 消息 ID(例如 1、2)以节省 Token。
MessageSid/ReplyToId可以是短 ID。MessageSidFull/ReplyToIdFull包含提供商的完整 ID。- 短 ID 存储在内存中;它们可能在重启或缓存清除时过期。
- 操作接受短 ID 或完整
messageId,但如果短 ID 不再可用会报错。
对于持久化自动化和存储,使用完整 ID:
- 模板:
{{MessageSidFull}}、{{ReplyToIdFull}} - Context:入站负载中的
MessageSidFull/ReplyToIdFull
查看 配置 了解模板变量。
块流式传输
控制响应是作为单条消息发送还是以块流式传输:
{
channels: {
bluebubbles: {
blockStreaming: true, // 启用块流式传输(默认行为)
},
},
}
媒体 + 限制
- 入站附件会被下载并存储在媒体缓存中。
- 媒体上限通过
channels.bluebubbles.mediaMaxMb设置(默认:8 MB)。 - 出站文本会分块到
channels.bluebubbles.textChunkLimit(默认:4000 字符)。
配置参考
完整配置:配置
Provider 选项:
channels.bluebubbles.enabled:启用/禁用 Channel。channels.bluebubbles.serverUrl:BlueBubbles REST API 基础 URL。channels.bluebubbles.password:API 密码。channels.bluebubbles.webhookPath:Webhook 端点路径(默认:/bluebubbles-webhook)。channels.bluebubbles.dmPolicy:pairing | allowlist | open | disabled(默认:pairing)。channels.bluebubbles.allowFrom:DM 白名单(句柄、邮箱、E.164 号码、chat_id:*、chat_guid:*)。channels.bluebubbles.groupPolicy:open | allowlist | disabled(默认:allowlist)。channels.bluebubbles.groupAllowFrom:群组发送者白名单。channels.bluebubbles.groups:按群组配置(requireMention等)。channels.bluebubbles.sendReadReceipts:发送已读回执(默认:true)。channels.bluebubbles.blockStreaming:启用块流式传输(默认:true)。channels.bluebubbles.textChunkLimit:出站分块大小(字符)(默认:4000)。channels.bluebubbles.chunkMode:length(默认)仅在超过textChunkLimit时分割;newline在长度分块之前在空行(段落边界)处分割。channels.bluebubbles.mediaMaxMb:入站媒体上限(MB)(默认:8)。channels.bluebubbles.historyLimit:用于 Context 的最大群组消息数(0 禁用)。channels.bluebubbles.dmHistoryLimit:DM 历史记录限制。channels.bluebubbles.actions:启用/禁用特定操作。channels.bluebubbles.accounts:多账户配置。
相关全局选项:
agents.list[].groupChat.mentionPatterns(或messages.groupChat.mentionPatterns)。messages.responsePrefix。
寻址 / 投递目标
优先使用 chat_guid 以实现稳定路由:
chat_guid:iMessage;-;+15555550123(群组首选)chat_id:123chat_identifier:...- 直接句柄:
+15555550123、[email protected]- 如果直接句柄没有现有的 DM 聊天,OpenClaw 会通过
POST /api/v1/chat/new创建一个。这需要启用 BlueBubbles Private API。
- 如果直接句柄没有现有的 DM 聊天,OpenClaw 会通过
安全
- Webhook 请求通过比较
guid/password查询参数或标头与channels.bluebubbles.password来进行身份验证。来自localhost的请求也会被接受。 - 保持 API 密码和 Webhook 端点的机密性(像凭据一样对待它们)。
- Localhost 信任意味着同主机反向代理可能会无意中绕过密码。如果你代理 Gateway,请在代理处要求身份验证并配置
gateway.trustedProxies。查看 Gateway 安全。 - 如果在局域网外暴露 BlueBubbles 服务器,请启用 HTTPS + 防火墙规则。
故障排除
- 如果输入/已读事件停止工作,检查 BlueBubbles Webhook 日志并验证 Gateway 路径是否匹配
channels.bluebubbles.webhookPath。 - 配对码 1 小时后过期;使用
openclaw pairing list bluebubbles和openclaw pairing approve bluebubbles <code>。 - 表情回应需要 BlueBubbles private API(
POST /api/v1/message/react);确保服务器版本公开了它。 - 编辑/撤回需要 macOS 13+ 和兼容的 BlueBubbles 服务器版本。在 macOS 26 (Tahoe) 上,由于 private API 更改,编辑功能目前有问题。
- 群组图标更新在 macOS 26 (Tahoe) 上可能不稳定:API 可能返回成功但新图标不同步。
- OpenClaw 会根据 BlueBubbles 服务器的 macOS 版本自动隐藏已知有问题的操作。如果编辑功能仍然出现在 macOS 26 (Tahoe) 上,请使用
channels.bluebubbles.actions.edit=false手动禁用它。 - 查看状态/健康信息:
openclaw status --all或openclaw status --deep。