🦞OpenClaw Guide
iMessage

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:

bash
# Check if imsg is installed and find its pathwhich imsg

Common locations: - Apple Silicon Macs: /opt/homebrew/bin/imsg - Intel Macs: /usr/local/bin/imsg

### Step 2: Find the OpenClaw gateway binary

bash
# Find the openclaw/clawdbot binarywhich openclaw# orwhich clawdbot

If installed via npm globally: ``bash # The path might be something like: # ~/.npm-global/bin/clawdbot # Check what the wrapper points to: file ~/.npm-global/bin/clawdbot readlink -f ~/.npm-global/bin/clawdbot

If using Homebrew (recommended for FDA): ``bash brew install openclaw/tap/openclaw # This puts the binary at /usr/local/bin/openclaw or /opt/homebrew/bin/openclaw

### Step 3: Add both binaries to Full Disk Access

1. Open System SettingsPrivacy & SecurityFull Disk Access 2. Click the + button 3. Press Cmd+Shift+G to open 'Go to folder' 4. Paste the path to imsg (e.g., /opt/homebrew/bin/imsg) 5. Click Open to add it 6. 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 -f and add the actual target

### Step 4: Restart and verify

bash
# Restart the gatewayopenclaw gateway restart# Test iMessage accessimsg list --limit 5

---

## Part 2: Fixing Duplicate Messages

### Quick Diagnostic Steps

bash
# 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 --version

### Fix 1: Restart Everything Cleanly

bash
# 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 start

### Fix 2: Add Sender ID Filtering (Code Patch)

If duplicates persist, add an additional sender check in src/imessage/monitor.ts around line 175:

typescript
// 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

bash
# 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.com

### Targeting 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:

bash
# List today's messagesimsg list --since today# Get messages from a specific contactimsg list --from "+1234567890" --limit 50

Then 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.$97/mo (going to $197 soon)

Join Vibe Combinator →

📋 Quick Commands

CommandDescription
which imsgFind the location of the imsg binary for FDA permissions
which openclawFind the OpenClaw gateway binary location
readlink -f /path/to/binaryResolve symlinks to find the actual binary path
imsg list --limit 5Test that iMessage access is working after FDA setup
openclaw gateway restartRestart the gateway after permission changes
ps aux | grep -i openclawCheck for duplicate gateway processes causing duplicates
pkill -f imsgKill orphaned imsg processes
openclaw logs --tail 100View recent logs to diagnose message handling issues
imsg chats --limit 20List recent chats including group chat IDs
openclaw doctorRun diagnostics to check for common issues

Related Issues

    🐙 Your AI should run your business.

    Weekly live builds + template vault. We'll show you how to make AI actually work.$97/mo (going to $197 soon)

    Join Vibe Combinator →

    Still stuck?

    Join our Discord community for real-time help.

    Join Discord