OpenClaw 支持 iMessage 作为消息频道,让你可以通过 iPhone 的默认消息应用与 AI 助手对话。注意:新部署推荐使用 BlueBubbles,imsg 集成为遗留方案。
前置条件
- macOS 设备(iMessage 仅在 Apple 设备上可用)
- 已登录 iMessage 的 Apple ID
- Homebrew(用于安装 imsg)
快速配置(4 步)
第 1 步:安装 imsg
brew install steipete/tap/imsg
imsg rpc --help # 验证安装第 2 步:配置 OpenClaw
{
"channels": {
"imessage": {
"enabled": true,
"cliPath": "/usr/local/bin/imsg",
"dbPath": "/Users/<你的用户名>/Library/Messages/chat.db"
}
}
}第 3 步:启动 Gateway
openclaw gateway第 4 步:批准首次 DM 配对
openclaw pairing list imessage
openclaw pairing approve imessage CODE配对请求 1 小时内有效。
macOS 权限配置
imsg 需要以下 macOS 权限:
完整磁盘访问权限(必须): 系统设置 → 隐私与安全性 → 完整磁盘访问权限 → 添加 Terminal(或 imsg 所在应用)
自动化权限(如需发送消息): 首次使用时系统会自动弹出权限请求,允许即可。
辅助功能(部分功能需要): 系统设置 → 隐私与安全性 → 辅助功能 → 添加相关应用
访问控制
DM 访问策略
{
"channels": {
"imessage": {
"dmPolicy": "pairing",
"allowFrom": ["+8613800138000"]
}
}
}dmPolicy 选项:
pairing(默认):未知发件人收到配对码allowlist:只允许allowFrom列表中的号码open:允许所有人disabled:禁用私信
allowFrom 接受手机号码(E.164 格式)或 Apple ID 邮箱。
群组访问
{
"channels": {
"imessage": {
"groupPolicy": "allowlist",
"groupAllowFrom": ["+8613800138000"]
}
}
}远程 Mac 部署
iMessage 只能在 Mac 本地运行,但 OpenClaw Gateway 可以部署在任意服务器上,通过 SSH 远程调用 imsg:
# 创建 SSH 包装脚本
cat > ~/.openclaw/scripts/imsg-ssh << 'EOF'
#!/usr/bin/env bash
exec ssh -T your-mac-hostname imsg "$@"
EOF
chmod +x ~/.openclaw/scripts/imsg-ssh{
"channels": {
"imessage": {
"enabled": true,
"cliPath": "~/.openclaw/scripts/imsg-ssh",
"remoteHost": "user@your-mac-hostname",
"includeAttachments": true,
"attachmentRoots": ["/Users/*/Library/Messages/Attachments"],
"remoteAttachmentRoots": ["/Users/*/Library/Messages/Attachments"]
}
}
}注意:remoteHost 格式为 host 或 user@host(不含 SSH 选项)。远程主机密钥必须已在 ~/.ssh/known_hosts 中。
媒体和附件
{
"channels": {
"imessage": {
"includeAttachments": true,
"maxAttachmentBytes": 10485760
}
}
}支持的媒体类型:图片、音频(自动转录)、文件。
为什么推荐 BlueBubbles?
对于新的 iMessage 部署,OpenClaw 官方推荐使用 BlueBubbles 而不是 imsg:
- BlueBubbles 是开源项目,活跃维护
- 支持更多功能(已读回执、打字指示、Tapback 反应)
- 更稳定的远程部署支持
- imsg 为遗留集成,未来可能移除
如果你已经在用 imsg,当前版本继续可用;新部署建议直接使用 BlueBubbles。
常见问题
imsg 无法访问 Messages 数据库? 确认已授予「完整磁盘访问权限」。在 macOS 14+ 上,权限更加严格,需要明确授权。
远程部署附件不显示?
检查 remoteHost 配置正确,且远程主机密钥在 known_hosts 中。
配对后仍无法收到消息?
运行 openclaw logs --follow 查看实时日志,检查 imsg 进程是否正常启动。
原文:iMessage - OpenClaw | 来源:OpenClaw 官方文档