Skip to content

BlueBubbles (macOS REST)

状态:通过 HTTP 与 BlueBubbles macOS 服务器通信的捆绑插件。推荐用于 iMessage 集成,因为与传统的 imsg 通道相比,它具有更丰富的 API 和更简单的设置。

概述

  • 通过 BlueBubbles 助手应用在 macOS 上运行 (bluebubbles.app)。
  • 推荐/测试:macOS Sequoia (15)。macOS Tahoe (26) 可用;编辑功能目前在 Tahoe 上损坏,群组图标更新可能报告成功但不同步。
  • openclaw 通过其 REST API 与其通信(GET /api/v1/pingPOST /message/textPOST /chat/:id/*)。
  • 传入消息通过 webhook 到达;传出回复、输入指示器、已读回执和轻点反馈是 REST 调用。
  • 附件和贴纸作为入站媒体摄取(并在可能时呈现给代理)。
  • 配对/允许列表的工作方式与其他通道相同(/start/pairing 等),使用 channels.bluebubbles.allowFrom + 配对码。
  • 反应作为系统事件呈现,就像 Slack/Telegram 一样,因此代理可以在回复前"提及"它们。
  • 高级功能:编辑、撤回、回复线程、消息效果、群组管理。

快速开始

  1. 在您的 Mac 上安装 BlueBubbles 服务器(按照 bluebubbles.app/install 的说明操作)。
  2. 在 BlueBubbles 配置中,启用 web API 并设置密码。
  3. 运行 openclaw onboard 并选择 BlueBubbles,或手动配置:
    json5
    {
      channels: {
        bluebubbles: {
          enabled: true,
          serverUrl: "http://192.168.1.100:1234",
          password: "example-password",
          webhookPath: "/bluebubbles-webhook"
        }
      }
    }
  4. 将 BlueBubbles webhook 指向您的网关(示例:https://your-gateway-host:3000/bluebubbles-webhook?password=<password>)。
  5. 启动网关;它将注册 webhook 处理程序并开始配对。

入门引导

BlueBubbles 在交互式设置向导中可用:

openclaw onboard

向导提示:

  • 服务器 URL(必需):BlueBubbles 服务器地址(例如:http://192.168.1.100:1234
  • 密码(必需):来自 BlueBubbles 服务器设置的 API 密码
  • Webhook 路径(可选):默认为 /bluebubbles-webhook
  • 私信策略:配对、允许列表、开放或禁用
  • 允许列表:电话号码、电子邮件或聊天目标

您也可以通过 CLI 添加 BlueBubbles:

openclaw channels add bluebubbles --http-url http://192.168.1.100:1234 --password <password>

访问控制(私信 + 群组)

私信:

  • 默认:channels.bluebubbles.dmPolicy = "pairing"
  • 未知发件人收到配对码;消息在批准前被忽略(码在 1 小时后过期)。
  • 通过以下方式批准:
    • openclaw pairing list bluebubbles
    • openclaw pairing approve bluebubbles <CODE>
  • 配对是默认的令牌交换。详情:配对

群组:

  • channels.bluebubbles.groupPolicy = open | allowlist | disabled(默认:allowlist)。
  • channels.bluebubbles.groupAllowFrom 控制当 allowlist 设置时谁可以在群组中触发。

提及门控(群组)

BlueBubbles 支持群组聊天的提及门控,匹配 iMessage/WhatsApp 行为:

  • 使用 agents.list[].groupChat.mentionPatterns(或 messages.groupChat.mentionPatterns)检测提及。
  • 当为群组启用 requireMention 时,代理仅在提及时才响应。
  • 来自授权发件人的控制命令绕过提及门控。

每群组配置:

json5
{
  channels: {
    bluebubbles: {
      groupPolicy: "allowlist",
      groupAllowFrom: ["+15555550123"],
      groups: {
        "*": { requireMention: true },  // 所有群组的默认值
        "iMessage;-;chat123": { requireMention: false }  // 特定群组的覆盖
      }
    }
  }
}

命令门控

  • 控制命令(例如:/config/model)需要授权。
  • 使用 allowFromgroupAllowFrom 确定命令授权。
  • 授权发件人可以在群组中运行控制命令,即使没有提及。

输入状态 + 已读回执

  • 输入指示器:在响应生成之前和期间自动发送。
  • 已读回执:由 channels.bluebubbles.sendReadReceipts 控制(默认:true)。
  • 输入指示器:openclaw 发送输入开始事件;BlueBubbles 在发送或超时时自动清除输入(通过 DELETE 手动停止不可靠)。
json5
{
  channels: {
    bluebubbles: {
      sendReadReceipts: false  // 禁用已读回执
    }
  }
}

高级操作

在配置中启用时,BlueBubbles 支持高级消息操作:

json5
{
  channels: {
    bluebubbles: {
      actions: {
        reactions: true,       // 轻点反馈(默认:true)
        edit: true,            // 编辑已发送的消息(macOS 13+,在 macOS 26 Tahoe 上损坏)
        unsend: true,          // 撤回消息(macOS 13+)
        reply: true,           // 通过消息 GUID 进行回复线程
        sendWithEffect: true,  // 消息效果(猛击、大声等)
        renameGroup: true,     // 重命名群组聊天
        setGroupIcon: true,    // 设置群组聊天图标/照片(在 macOS 26 Tahoe 上不稳定)
        addParticipant: true,  // 向群组添加参与者
        removeParticipant: true, // 从群组中移除参与者
        leaveGroup: true,      // 离开群组聊天
        sendAttachment: true   // 发送附件/媒体
      }
    }
  }
}

可用操作:

  • react:添加/移除轻点反馈反应(messageIdemojiremove
  • edit:编辑已发送的消息(messageIdtext
  • unsend:撤回消息(messageId
  • reply:回复特定消息(messageIdtextto
  • sendWithEffect:使用 iMessage 效果发送(texttoeffectId
  • renameGroup:重命名群组聊天(chatGuiddisplayName
  • setGroupIcon:设置群组聊天的图标/照片(chatGuidmedia)— 在 macOS 26 Tahoe 上不稳定(API 可能返回成功但图标不同步)。
  • addParticipant:向群组添加某人(chatGuidaddress
  • removeParticipant:从群组中移除某人(chatGuidaddress
  • leaveGroup:离开群组聊天(chatGuid
  • sendAttachment:发送媒体/文件(tobufferfilenameasVoice
    • 语音备忘录:使用 MP3CAF 音频设置 asVoice: true 以作为 iMessage 语音消息发送。BlueBubbles 在发送语音备忘录时将 MP3 → CAF 转换。

消息 ID(短 vs 完整)

openclaw 可能呈现消息 ID(例如:12)以节省令牌。

  • MessageSid / ReplyToId 可以是短 ID。
  • MessageSidFull / ReplyToIdFull 包含提供者的完整 ID。
  • 短 ID 是内存中的;它们可能在重启或缓存驱逐时过期。
  • 操作接受短或完整 messageId,但如果不再可用,短 ID 将出错。

为持久自动化和存储使用完整 ID:

  • 模板:
  • 上下文:入站有效负载中的 MessageSidFull / ReplyToIdFull

有关模板变量,请参见配置

块流式传输

控制响应是作为单个消息发送还是以块流式传输:

json5
{
  channels: {
    bluebubbles: {
      blockStreaming: true  // 启用块流式传输(默认行为)
    }
  }
}

媒体 + 限制

  • 入站附件被下载并存储在媒体缓存中。
  • 通过 channels.bluebubbles.mediaMaxMb 的媒体上限(默认:8 MB)。
  • 出站文本被分块到 channels.bluebubbles.textChunkLimit(默认:4000 字符)。

配置参考

完整配置:配置

提供者选项:

  • channels.bluebubbles.enabled:启用/禁用通道。
  • channels.bluebubbles.serverUrl:BlueBubbles REST API 基础 URL。
  • channels.bluebubbles.password:API 密码。
  • channels.bluebubbles.webhookPath:Webhook 端点路径(默认:/bluebubbles-webhook)。
  • channels.bluebubbles.dmPolicypairing | allowlist | open | disabled(默认:pairing)。
  • channels.bluebubbles.allowFrom:私信允许列表(句柄、电子邮件、E.164 号码、chat_id:*chat_guid:*)。
  • channels.bluebubbles.groupPolicyopen | allowlist | disabled(默认:allowlist)。
  • channels.bluebubbles.groupAllowFrom:群组发件人允许列表。
  • channels.bluebubbles.groups:每群组配置(requireMention 等)。
  • channels.bluebubbles.sendReadReceipts:发送已读回执(默认:true)。
  • channels.bluebubbles.blockStreaming:启用块流式传输(默认:true)。
  • channels.bluebubbles.textChunkLimit:出站块大小(字符)(默认:4000)。
  • channels.bluebubbles.chunkModelength(默认)仅在超过 textChunkLimit 时拆分;newline 在长度分块之前在空行(段落边界)上拆分。
  • channels.bluebubbles.mediaMaxMb:入站媒体上限(MB)(默认:8)。
  • channels.bluebubbles.historyLimit:群组上下文的最大消息数(0 禁用)。
  • channels.bluebubbles.dmHistoryLimit:私信历史记录限制。
  • channels.bluebubbles.actions:启用/禁用特定操作。
  • channels.bluebubbles.accounts:多账户配置。

相关全局选项:

  • agents.list[].groupChat.mentionPatterns(或 messages.groupChat.mentionPatterns)。
  • messages.responsePrefix.

寻址/投递目标

优先使用 chat_guid 进行稳定路由:

  • chat_guid:iMessage;-;+15555550123(群组首选)
  • chat_id:123
  • chat_identifier:...
  • 直接句柄:+15555550123, user@example.com
    • 如果直接句柄没有现有的 DM 聊天,openclaw 将通过 POST /api/v1/chat/new 创建一个。这需要启用 BlueBubbles 私有 API。

安全

  • Webhook 请求通过比较 guid/password 查询参数或请求头与 channels.bluebubbles.password 进行身份验证。来自 localhost 的请求也被接受。
  • 将 API 密码和 webhook 端点保密(像对待凭据一样对待它们)。
  • Localhost 信任意味着同一主机的反向代理可能会无意中绕过密码。如果你代理网关,请在代理处要求身份验证并配置 gateway.trustedProxies。参见 网关安全
  • 如果在 LAN 外部暴露 BlueBubbles 服务器,请启用 HTTPS + 防火墙规则。

故障排除

  • 如果打字/已读事件停止工作,请检查 BlueBubbles webhook 日志并验证网关路径是否匹配 channels.bluebubbles.webhookPath
  • 配对代码在一小时后过期;使用 openclaw pairing list bluebubblesopenclaw pairing approve bluebubbles <code>
  • 反应需要 BlueBubbles 私有 API(POST /api/v1/message/react);确保服务器版本暴露了它。
  • 编辑/撤回需要 macOS 13+ 和兼容的 BlueBubbles 服务器版本。在 macOS 26 (Tahoe) 上,由于私有 API 更改,编辑功能当前已损坏。
  • 群组图标更新在 macOS 26 (Tahoe) 上可能不稳定:API 可能返回成功但新图标不同步。
  • openclaw 根据 BlueBubbles 服务器的 macOS 版本自动隐藏已知损坏的操作。如果编辑功能仍然出现在 macOS 26 (Tahoe) 上,请使用 channels.bluebubbles.actions.edit=false 手动禁用它。
  • 对于状态/健康信息:openclaw status --allopenclaw status --deep

有关通用频道工作流程参考,请参见 频道插件 指南。