iMessage & SMS Integration Guide
Complete guide to setting up iMessage integration with OpenClaw, including Full Disk Access permissions, fixing duplicate messages, and troubleshooting common issues.
⚠️ The Problem
Users encounter multiple issues when setting up iMessage integration with OpenClaw: (1) Full Disk Access permissions not working or unclear which apps need FDA, (2) Duplicate messages appearing when the bot replies — the reply shows up twice in the chat, (3) Messages being processed as inbound when they should be outbound, and (4) General confusion about how to read or summarize iMessage conversations.
🔍 Why This Happens
Full Disk Access Issues: The iMessage integration uses the imsg CLI tool which directly accesses the macOS Messages database (~/Library/Messages/chat.db). This database is protected by System Integrity Protection and requires explicit Full Disk Access permission. Simply adding Terminal.app to FDA is NOT sufficient — you must add the actual binaries that access the database: both imsg AND the OpenClaw gateway binary. Additionally, npm-installed binaries are often wrapper scripts that macOS FDA doesn't accept.
Duplicate Messages: When OpenClaw sends a message via AppleScript, there's a race condition in the iMessage monitor. The chat.db filesystem watch event can fire before the is_from_me flag is properly set in the database. The monitor at src/imessage/monitor.ts:184 filters with if (message.is_from_me) return; but this check fails when the flag isn't populated yet. This affects both the native imsg backend and BlueBubbles.
Outbound as Inbound: Similar race condition — the database sync hasn't completed when the watch event triggers, so the message appears as an incoming message rather than outgoing.
✅ The Fix
Part 1: Setting Up Full Disk Access Correctly
Step 1: Find the imsg binary location
The location depends on how you installed it:
# Check if imsg is installed and find its pathwhich imsgCommon locations:
- Apple Silicon Macs:
/opt/homebrew/bin/imsg - Intel Macs:
/usr/local/bin/imsg
Step 2: Find the OpenClaw gateway binary
# Find the openclaw/clawdbot binarywhich openclaw# orwhich clawdbotIf installed via npm globally:
# The path might be something like:# ~/.npm-global/bin/clawdbot# Check what the wrapper points to:file ~/.npm-global/bin/clawdbotreadlink -f ~/.npm-global/bin/clawdbotIf using Homebrew (recommended for FDA):
brew install openclaw/tap/openclaw# This puts the binary at /usr/local/bin/openclaw or /opt/homebrew/bin/openclawStep 3: Add both binaries to Full Disk Access
- Open System Settings → Privacy & Security → Full Disk Access
- Click the + button
- Press Cmd+Shift+G to open 'Go to folder'
- Paste the path to
imsg(e.g.,/opt/homebrew/bin/imsg) - Click Open to add it
- Repeat for the OpenClaw gateway binary
If the binary disappears when you try to add it: This happens with npm wrapper scripts. Solutions:
- Install via Homebrew instead (creates proper binaries)
- Try adding the parent directory
- Check if it's a symlink with
readlink -fand add the actual target
Step 4: Restart and verify
# Restart the gatewayopenclaw gateway restart# Test iMessage accessimsg list --limit 5Part 2: Fixing Duplicate Messages
Quick Diagnostic Steps
# Check for multiple gateway processesps aux | grep -i openclaw | grep -v grep# Check logs for duplicate indicatorsopenclaw logs --tail 100 | grep -i "imsg\|duplicate\|is_from_me"# Verify imsg versionimsg --versionFix 1: Restart Everything Cleanly
# Stop the gatewayopenclaw gateway stop# Kill any orphaned imsg processespkill -f imsg# Quit Messages.app completelyosascript -e 'tell application "Messages" to quit'# Wait a moment, then restartsleep 2openclaw gateway startFix 2: Add Sender ID Filtering (Code Patch)
If duplicates persist, add an additional sender check in src/imessage/monitor.ts around line 175:
// Get the current account's sender IDconst accountSenderId = accountInfo.config.senderId ?? accountInfo.accountId;const handleMessage = async (raw: unknown) => { const params = raw as { message?: IMessagePayload | null }; const message = params?.message ?? null; if (!message) return; // Existing check if (message.is_from_me) return; // NEW: Additional check - skip if sender matches our account const normalizedSender = normalizeIMessageHandle(sender); const normalizedAccountSender = normalizeIMessageHandle(accountSenderId); if (normalizedSender === normalizedAccountSender) { logVerbose(`imessage: skipped own message from ${sender}`); return; } // ... rest of handler};This filters by matching the bot's own sender ID, which is more reliable than the is_from_me database flag.
Part 3: Working with Group Chats
Finding Group Chat IDs
# List recent chats including groupsimsg chats --limit 20# The chat_id for groups looks like: chat123456789# Individual chats use phone/email: +1234567890 or user@icloud.comTargeting Specific Chats
In your OpenClaw config, you can allowlist specific chat IDs to prevent the bot from responding everywhere.
Part 4: Reading & Summarizing Messages
To have OpenClaw summarize your texts:
# List today's messagesimsg list --since today# Get messages from a specific contactimsg list --from "+1234567890" --limit 50Then ask OpenClaw: "Summarize my recent iMessages" and it can use the imsg tool to fetch and summarize them.
🔥 Your AI should run your business, not just answer questions.
We'll show you how.Free to join.
📋 Quick Commands
| Command | Description |
|---|---|
| which imsg | Find the location of the imsg binary for FDA permissions |
| which openclaw | Find the OpenClaw gateway binary location |
| readlink -f /path/to/binary | Resolve symlinks to find the actual binary path |
| imsg list --limit 5 | Test that iMessage access is working after FDA setup |
| openclaw gateway restart | Restart the gateway after permission changes |
| ps aux | grep -i openclaw | Check for duplicate gateway processes causing duplicates |
| pkill -f imsg | Kill orphaned imsg processes |
| openclaw logs --tail 100 | View recent logs to diagnose message handling issues |
| imsg chats --limit 20 | List recent chats including group chat IDs |
| openclaw doctor | Run diagnostics to check for common issues |
Related Issues
📚 You Might Also Like
iMessage
Use iMessage and SMS to chat with OpenClaw from your iPhone, iPad, or Mac. Native Messages.app integration — no extra apps needed.
OpenClaw Self-Audit: The Prompt That Checks Your Own Security Setup
Most people set up OpenClaw, lock things down as best they can, and never check again. Meanwhile, configs drift, updates change settings, and new integration...
How to Connect Gmail to Your AI Assistant (Complete Integration Guide)
Turn Gmail into an AI-powered inbox. Summarize threads, draft replies, auto-categorize messages, and search your email with natural language.
Tabnine vs GitHub Copilot
Privacy-first AI coding vs ecosystem integration
🐙 Your AI should run your business.
Weekly live builds + template vault. We'll show you how to make AI actually work.Free to join.
Join Vibe Combinator →