2026-01-02 01:19:22 +01:00
---
2026-02-03 18:06:54 -08:00
summary: "Legacy iMessage support via imsg (JSON-RPC over stdio). New setups should use BlueBubbles."
2026-01-02 01:19:22 +01:00
read_when:
- Setting up iMessage support
- Debugging iMessage send/receive
2026-02-11 12:58:02 -05:00
title: "iMessage"
2026-01-02 01:19:22 +01:00
---
2026-02-03 18:06:54 -08:00
# iMessage (legacy: imsg)
2026-01-02 01:19:22 +01:00
2026-02-11 12:58:02 -05:00
< Warning >
For new iMessage deployments, use < a href = "/channels/bluebubbles" > BlueBubbles< / a > .
2026-02-03 18:06:54 -08:00
2026-02-11 12:58:02 -05:00
The `imsg` integration is legacy and may be removed in a future release.
< / Warning >
2026-01-02 01:19:22 +01:00
2026-02-11 12:58:02 -05:00
Status: legacy external CLI integration. Gateway spawns `imsg rpc` and communicates over JSON-RPC on stdio (no separate daemon/port).
2026-01-31 21:13:13 +09:00
2026-02-11 12:58:02 -05:00
< CardGroup cols = {3} >
< Card title = "BlueBubbles (recommended)" icon = "message-circle" href = "/channels/bluebubbles" >
Preferred iMessage path for new setups.
< / Card >
< Card title = "Pairing" icon = "link" href = "/channels/pairing" >
iMessage DMs default to pairing mode.
< / Card >
< Card title = "Configuration reference" icon = "settings" href = "/gateway/configuration-reference #imessage " >
Full iMessage field reference.
< / Card >
< / CardGroup >
2026-01-11 02:40:28 +01:00
2026-02-21 11:18:29 -05:00
## Quick setup
2026-02-11 12:58:02 -05:00
< Tabs >
< Tab title = "Local Mac (fast path)" >
< Steps >
< Step title = "Install and verify imsg" >
```bash
brew install steipete/tap/imsg
imsg rpc --help
```
< / Step >
< Step title = "Configure OpenClaw" >
2026-01-31 21:13:13 +09:00
2026-01-11 02:40:28 +01:00
```json5
{
2026-01-13 06:16:43 +00:00
channels: {
imessage: {
enabled: true,
cliPath: "/usr/local/bin/imsg",
2026-01-31 21:13:13 +09:00
dbPath: "/Users/< you > /Library/Messages/chat.db",
},
},
2026-01-11 02:40:28 +01:00
}
```
2026-02-11 12:58:02 -05:00
< / Step >
2026-01-31 21:13:13 +09:00
2026-02-11 12:58:02 -05:00
< Step title = "Start gateway" >
2026-01-06 18:25:52 +00:00
2026-02-11 12:58:02 -05:00
```bash
openclaw gateway
```
2026-01-31 21:13:13 +09:00
2026-02-11 12:58:02 -05:00
< / Step >
2026-01-15 01:41:11 +00:00
2026-02-11 12:58:02 -05:00
< Step title = "Approve first DM pairing (default dmPolicy)" >
2026-01-31 21:13:13 +09:00
2026-02-11 12:58:02 -05:00
```bash
openclaw pairing list imessage
openclaw pairing approve imessage < CODE >
2026-01-15 01:41:11 +00:00
```
2026-02-11 12:58:02 -05:00
Pairing requests expire after 1 hour.
< / Step >
< / Steps >
< / Tab >
2026-01-31 21:13:13 +09:00
2026-02-11 12:58:02 -05:00
< Tab title = "Remote Mac over SSH" >
OpenClaw only requires a stdio-compatible `cliPath` , so you can point `cliPath` at a wrapper script that SSHes to a remote Mac and runs `imsg` .
2026-01-02 01:19:22 +01:00
2026-02-11 12:58:02 -05:00
```bash
#!/usr/bin/env bash
exec ssh -T gateway-host imsg "$@"
```
Recommended config when attachments are enabled:
```json5
{
channels: {
imessage: {
enabled: true,
cliPath: "~/.openclaw/scripts/imsg-ssh",
remoteHost: "user@gateway -host", // used for SCP attachment fetches
includeAttachments: true,
2026-02-19 14:15:34 +01:00
// Optional: override allowed attachment roots.
// Defaults include /Users/*/Library/Messages/Attachments
attachmentRoots: ["/Users/*/Library/Messages/Attachments"],
remoteAttachmentRoots: ["/Users/*/Library/Messages/Attachments"],
2026-02-11 12:58:02 -05:00
},
},
}
```
2026-02-06 17:35:33 -06:00
2026-02-11 12:58:02 -05:00
If `remoteHost` is not set, OpenClaw attempts to auto-detect it by parsing the SSH wrapper script.
2026-02-19 11:07:56 +01:00
`remoteHost` must be `host` or `user@host` (no spaces or SSH options).
OpenClaw uses strict host-key checking for SCP, so the relay host key must already exist in `~/.ssh/known_hosts` .
2026-02-19 14:15:34 +01:00
Attachment paths are validated against allowed roots (`attachmentRoots` / `remoteAttachmentRoots` ).
2026-02-06 19:21:52 -05:00
2026-02-11 12:58:02 -05:00
< / Tab >
< / Tabs >
2026-02-06 17:35:33 -06:00
2026-02-11 12:58:02 -05:00
## Requirements and permissions (macOS)
2026-02-06 17:35:33 -06:00
2026-02-11 12:58:02 -05:00
- Messages must be signed in on the Mac running `imsg` .
- Full Disk Access is required for the process context running OpenClaw/`imsg` (Messages DB access).
- Automation permission is required to send messages through Messages.app.
2026-02-06 17:35:33 -06:00
2026-02-11 12:58:02 -05:00
< Tip >
Permissions are granted per process context. If gateway runs headless (LaunchAgent/SSH), run a one-time interactive command in that same context to trigger prompts:
2026-02-06 17:35:33 -06:00
```bash
imsg chats --limit 1
# or
imsg send < handle > "test"
```
2026-02-11 12:58:02 -05:00
< / Tip >
2026-02-06 17:35:33 -06:00
2026-02-11 12:58:02 -05:00
## Access control and routing
2026-01-31 21:13:13 +09:00
2026-02-11 12:58:02 -05:00
< Tabs >
< Tab title = "DM policy" >
`channels.imessage.dmPolicy` controls direct messages:
2026-01-02 01:19:22 +01:00
2026-02-11 12:58:02 -05:00
- `pairing` (default)
- `allowlist`
- `open` (requires `allowFrom` to include `"*"` )
- `disabled`
2026-01-31 21:13:13 +09:00
2026-02-11 12:58:02 -05:00
Allowlist field: `channels.imessage.allowFrom` .
2026-01-08 16:24:28 -06:00
2026-02-11 12:58:02 -05:00
Allowlist entries can be handles or chat targets (`chat_id:*` , `chat_guid:*` , `chat_identifier:*` ).
2026-01-08 01:18:37 +01:00
2026-02-11 12:58:02 -05:00
< / Tab >
2026-01-08 16:24:28 -06:00
2026-02-11 12:58:02 -05:00
< Tab title = "Group policy + mentions" >
`channels.imessage.groupPolicy` controls group handling:
2026-01-31 21:13:13 +09:00
2026-02-11 12:58:02 -05:00
- `allowlist` (default when configured)
- `open`
- `disabled`
2026-01-08 01:18:37 +01:00
2026-02-11 12:58:02 -05:00
Group sender allowlist: `channels.imessage.groupAllowFrom` .
2026-01-08 01:18:37 +01:00
2026-02-11 12:58:02 -05:00
Runtime fallback: if `groupAllowFrom` is unset, iMessage group sender checks fall back to `allowFrom` when available.
2026-02-22 12:17:44 +01:00
Runtime note: if `channels.imessage` is completely missing, runtime falls back to `groupPolicy="allowlist"` and logs a warning (even if `channels.defaults.groupPolicy` is set).
2026-01-31 21:13:13 +09:00
2026-02-11 12:58:02 -05:00
Mention gating for groups:
2026-01-02 01:19:22 +01:00
2026-02-11 12:58:02 -05:00
- iMessage has no native mention metadata
- mention detection uses regex patterns (`agents.list[].groupChat.mentionPatterns` , fallback `messages.groupChat.mentionPatterns` )
- with no configured patterns, mention gating cannot be enforced
2026-01-08 16:24:28 -06:00
2026-02-11 12:58:02 -05:00
Control commands from authorized senders can bypass mention gating in groups.
2026-01-31 21:13:13 +09:00
2026-02-11 12:58:02 -05:00
< / Tab >
2026-01-08 16:24:28 -06:00
2026-02-11 12:58:02 -05:00
< Tab title = "Sessions and deterministic replies" >
- DMs use direct routing; groups use group routing.
- With default `session.dmScope=main` , iMessage DMs collapse into the agent main session.
- Group sessions are isolated (`agent:<agentId>:imessage:group:<chat_id>` ).
- Replies route back to iMessage using originating channel/target metadata.
2026-01-31 21:13:13 +09:00
2026-02-11 12:58:02 -05:00
Group-ish thread behavior:
2026-01-08 16:24:28 -06:00
2026-02-11 12:58:02 -05:00
Some multi-participant iMessage threads can arrive with `is_group=false` .
If that `chat_id` is explicitly configured under `channels.imessage.groups` , OpenClaw treats it as group traffic (group gating + group session isolation).
2026-01-16 15:51:42 -08:00
2026-02-11 12:58:02 -05:00
< / Tab >
< / Tabs >
2026-01-16 15:51:42 -08:00
2026-02-11 12:58:02 -05:00
## Deployment patterns
< AccordionGroup >
< Accordion title = "Dedicated bot macOS user (separate iMessage identity)" >
Use a dedicated Apple ID and macOS user so bot traffic is isolated from your personal Messages profile.
Typical flow:
1. Create/sign in a dedicated macOS user.
2. Sign into Messages with the bot Apple ID in that user.
3. Install `imsg` in that user.
4. Create SSH wrapper so OpenClaw can run `imsg` in that user context.
5. Point `channels.imessage.accounts.<id>.cliPath` and `.dbPath` to that user profile.
First run may require GUI approvals (Automation + Full Disk Access) in that bot user session.
2026-01-17 00:39:48 +00:00
2026-02-11 12:58:02 -05:00
< / Accordion >
< Accordion title = "Remote Mac over Tailscale (example)" >
Common topology:
- gateway runs on Linux/VM
- iMessage + `imsg` runs on a Mac in your tailnet
- `cliPath` wrapper uses SSH to run `imsg`
- `remoteHost` enables SCP attachment fetches
Example:
2026-01-31 21:13:13 +09:00
2026-01-17 00:39:48 +00:00
```json5
{
channels: {
imessage: {
enabled: true,
2026-01-30 03:15:10 +01:00
cliPath: "~/.openclaw/scripts/imsg-ssh",
2026-01-17 00:39:48 +00:00
remoteHost: "bot@mac -mini.tailnet-1234.ts.net",
includeAttachments: true,
2026-01-31 21:13:13 +09:00
dbPath: "/Users/bot/Library/Messages/chat.db",
},
},
2026-01-17 00:39:48 +00:00
}
```
```bash
#!/usr/bin/env bash
exec ssh -T bot@mac -mini.tailnet-1234.ts.net imsg "$@"
```
2026-02-11 12:58:02 -05:00
Use SSH keys so both SSH and SCP are non-interactive.
2026-02-19 11:07:56 +01:00
Ensure the host key is trusted first (for example `ssh bot@mac-mini.tailnet-1234.ts.net` ) so `known_hosts` is populated.
2026-01-31 21:13:13 +09:00
2026-02-11 12:58:02 -05:00
< / Accordion >
2026-01-17 00:39:48 +00:00
2026-02-11 12:58:02 -05:00
< Accordion title = "Multi-account pattern" >
iMessage supports per-account config under `channels.imessage.accounts` .
2026-01-08 01:18:37 +01:00
2026-02-19 14:15:34 +01:00
Each account can override fields such as `cliPath` , `dbPath` , `allowFrom` , `groupPolicy` , `mediaMaxMb` , history settings, and attachment root allowlists.
2026-01-31 21:13:13 +09:00
2026-02-11 12:58:02 -05:00
< / Accordion >
< / AccordionGroup >
2026-01-31 21:13:13 +09:00
2026-02-11 12:58:02 -05:00
## Media, chunking, and delivery targets
2026-01-07 00:25:16 +01:00
2026-02-11 12:58:02 -05:00
< AccordionGroup >
< Accordion title = "Attachments and media" >
- inbound attachment ingestion is optional: `channels.imessage.includeAttachments`
- remote attachment paths can be fetched via SCP when `remoteHost` is set
2026-02-19 14:15:34 +01:00
- attachment paths must match allowed roots:
- `channels.imessage.attachmentRoots` (local)
- `channels.imessage.remoteAttachmentRoots` (remote SCP mode)
- default root pattern: `/Users/*/Library/Messages/Attachments`
2026-02-19 11:07:56 +01:00
- SCP uses strict host-key checking (`StrictHostKeyChecking=yes` )
2026-02-11 12:58:02 -05:00
- outbound media size uses `channels.imessage.mediaMaxMb` (default 16 MB)
< / Accordion >
2026-01-31 21:13:13 +09:00
2026-02-11 12:58:02 -05:00
< Accordion title = "Outbound chunking" >
- text chunk limit: `channels.imessage.textChunkLimit` (default 4000)
- chunk mode: `channels.imessage.chunkMode`
- `length` (default)
- `newline` (paragraph-first splitting)
< / Accordion >
2026-01-07 00:25:16 +01:00
2026-02-11 12:58:02 -05:00
< Accordion title = "Addressing formats" >
Preferred explicit targets:
2026-01-31 21:13:13 +09:00
2026-02-11 12:58:02 -05:00
- `chat_id:123` (recommended for stable routing)
- `chat_guid:...`
- `chat_identifier:...`
2026-01-07 00:25:16 +01:00
2026-02-11 12:58:02 -05:00
Handle targets are also supported:
2026-01-31 21:13:13 +09:00
2026-02-11 12:58:02 -05:00
- `imessage:+1555...`
- `sms:+1555...`
- `user@example.com`
2026-01-08 16:24:28 -06:00
2026-02-11 12:58:02 -05:00
```bash
imsg chats --limit 20
```
< / Accordion >
< / AccordionGroup >
2026-01-31 21:13:13 +09:00
2026-02-11 12:58:02 -05:00
## Config writes
iMessage allows channel-initiated config writes by default (for `/config set|unset` when `commands.config: true` ).
2026-01-08 16:24:28 -06:00
2026-02-11 12:58:02 -05:00
Disable:
2026-01-31 21:13:13 +09:00
2026-01-08 16:24:28 -06:00
```json5
{
2026-01-13 06:16:43 +00:00
channels: {
imessage: {
2026-02-11 12:58:02 -05:00
configWrites: false,
2026-01-31 21:13:13 +09:00
},
},
2026-01-08 16:24:28 -06:00
}
```
2026-01-31 21:13:13 +09:00
2026-02-11 12:58:02 -05:00
## Troubleshooting
2026-01-08 16:24:28 -06:00
2026-02-11 12:58:02 -05:00
< AccordionGroup >
< Accordion title = "imsg not found or RPC unsupported" >
Validate the binary and RPC support:
2026-01-31 21:13:13 +09:00
2026-02-11 12:58:02 -05:00
```bash
imsg rpc --help
openclaw channels status --probe
```
2026-01-07 00:25:16 +01:00
2026-02-11 12:58:02 -05:00
If probe reports RPC unsupported, update `imsg` .
2026-01-31 21:13:13 +09:00
2026-02-11 12:58:02 -05:00
< / Accordion >
2026-01-08 04:02:04 +01:00
2026-02-11 12:58:02 -05:00
< Accordion title = "DMs are ignored" >
Check:
2026-01-31 21:13:13 +09:00
2026-02-11 12:58:02 -05:00
- `channels.imessage.dmPolicy`
- `channels.imessage.allowFrom`
- pairing approvals (`openclaw pairing list imessage` )
2026-01-31 21:13:13 +09:00
2026-02-11 12:58:02 -05:00
< / Accordion >
2026-01-02 01:19:22 +01:00
2026-02-11 12:58:02 -05:00
< Accordion title = "Group messages are ignored" >
Check:
2026-01-31 21:13:13 +09:00
2026-02-11 12:58:02 -05:00
- `channels.imessage.groupPolicy`
- `channels.imessage.groupAllowFrom`
- `channels.imessage.groups` allowlist behavior
- mention pattern configuration (`agents.list[].groupChat.mentionPatterns` )
< / Accordion >
< Accordion title = "Remote attachments fail" >
Check:
- `channels.imessage.remoteHost`
2026-02-19 14:15:34 +01:00
- `channels.imessage.remoteAttachmentRoots`
2026-02-11 12:58:02 -05:00
- SSH/SCP key auth from the gateway host
2026-02-19 11:07:56 +01:00
- host key exists in `~/.ssh/known_hosts` on the gateway host
2026-02-11 12:58:02 -05:00
- remote path readability on the Mac running Messages
< / Accordion >
< Accordion title = "macOS permission prompts were missed" >
Re-run in an interactive GUI terminal in the same user/session context and approve prompts:
```bash
imsg chats --limit 1
imsg send < handle > "test"
2026-01-02 01:19:22 +01:00
```
2026-02-11 12:58:02 -05:00
Confirm Full Disk Access + Automation are granted for the process context that runs OpenClaw/`imsg` .
< / Accordion >
< / AccordionGroup >
2026-02-21 11:18:29 -05:00
## Configuration reference pointers
2026-02-11 12:58:02 -05:00
- [Configuration reference - iMessage ](/gateway/configuration-reference#imessage )
- [Gateway configuration ](/gateway/configuration )
- [Pairing ](/channels/pairing )
- [BlueBubbles ](/channels/bluebubbles )