Skip to content

fix(imessage): use phone number for DM replies instead of chat_id#372

Closed
mshuffett wants to merge 1 commit intoopenclaw:mainfrom
mshuffett:fix/imessage-dm-reply-target
Closed

fix(imessage): use phone number for DM replies instead of chat_id#372
mshuffett wants to merge 1 commit intoopenclaw:mainfrom
mshuffett:fix/imessage-dm-reply-target

Conversation

@mshuffett
Copy link
Copy Markdown

@mshuffett mshuffett commented Jan 7, 2026

Summary

Fix iMessage DM replies failing with "Internal error" when using chat_id parameter.

Problem

When replying to iMessage DMs, clawdbot uses chat_id (e.g., chat_id:18) as the reply target. The imsg CLI then fails with:

{"error":{"code":-32603,"data":"AppleScript failed: execution error: Messages got an error: Can't get chat id \"+1XXXXXXXXXX\". (-1728)","message":"Internal error"}}

The imsg CLI appears to be looking up the chat by numeric ID, then incorrectly passing the chat's identifier (phone number) to AppleScript as chat id "+1XXXXXXXXXX" instead of using the numeric ID or a different AppleScript syntax.

Solution

For DMs, use the sender's phone number directly (e.g., to: "+1XXXXXXXXXX") which works reliably with AppleScript. Groups continue to use chat_id as it's necessary for targeting group chats.

Test results

  • imsg send --to "+1XXXXXXXXXX" --text "test" → ✅ works
  • imsg rpc with {"to":"+1XXXXXXXXXX",...} → ✅ works
  • imsg rpc with {"chat_id":18,...} → ❌ fails with AppleScript error above

Note

This may be a bug in the imsg CLI itself (incorrect AppleScript generation for chat_id on 1:1 chats), but this workaround resolves the issue for clawdbot users.

The imsg CLI's AppleScript doesn't handle chat_id correctly for 1:1 DM
chats - it converts the numeric chat_id to the identifier and uses wrong
syntax. This causes "Internal error" when trying to send replies.

For DMs, use the sender's phone number directly which works reliably.
Groups still use chat_id as it's needed for targeting group chats.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@steipete
Copy link
Copy Markdown
Contributor

steipete commented Jan 7, 2026

Thanks Michael, iMessage was still a bit unfinished, good to have you helping here! Luckily they go together so I'll see where to best land the fix.

@steipete steipete self-assigned this Jan 7, 2026
@steipete
Copy link
Copy Markdown
Contributor

steipete commented Jan 7, 2026

Fixed upstream in imsg (v0.3.2): steipete/imsg@aafe3f3

@steipete
Copy link
Copy Markdown
Contributor

steipete commented Jan 7, 2026

Closing; fixed upstream in imsg 0.3.2.

@steipete steipete closed this Jan 7, 2026
@steipete
Copy link
Copy Markdown
Contributor

steipete commented Jan 7, 2026

Updated upstream fix (amended): steipete/imsg@99d03c8

@mshuffett
Copy link
Copy Markdown
Author

Ok great yeah that is the better fix I just didn't want to mess with imsg at the time tbh. @steipete

dgarson added a commit to dgarson/clawdbot that referenced this pull request Feb 9, 2026
* Slack: add reaction escalation support

* Slack: handle thread reactions for escalation

* fix: minor bug fix from PR review

* bug fix

* fix: resolve linting errors across codebase

- Fixed 696 linting errors down to 0 errors (257 warnings remain)
- Changed no-explicit-any from error to warn (222 instances)
- Fixed no-unused-vars errors by removing unused imports/variables
- Fixed no-base-to-string errors with proper type checking
- Fixed restrict-template-expressions by using String()
- Fixed require-array-sort-compare with compare functions
- Fixed await-thenable by removing unnecessary await
- Fixed no-unnecessary-template-expression
- Added eslint-disable for intentional control character regex
- Changed no-unused-vars to warn for test files

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>

---------

Co-authored-by: Claude Sonnet 4.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants