Feature request: Add hook event for incoming channel messages
Summary
Request for a new hook event (e.g., ChannelMessageReceived) that fires when a channel message arrives in a session. The hook should support blocking (exit code 2 / "decision": "block") so users can filter messages by content before Claude processes them.
Use case
When using the iMessage channel plugin, I'd like to filter messages by keyword so Claude only sees relevant messages. For example, only processing messages that contain "hey claude" and silently dropping the rest.
Currently, channel messages are injected directly into Claude's context as <channel> tags, bypassing the hook system entirely. The only filtering available is sender-based via access controls (/imessage:access), with no way to filter by message content.
Proposed behavior
- New hook event fires when a channel message is received, before it's added to Claude's context
- Hook receives the message content, sender, chat_id, and source as input
- Supports blocking: returning
exit code 2or{"decision": "block"}prevents the message from reaching Claude - Consistent with existing blocking hooks like
UserPromptSubmitandPreToolUse
🤖 Generated with Claude Code
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗