#22431: feat(hooks): add channel:connected hook event
## Summary
Adds a `channel:connected` hook event that fires when a WhatsApp channel successfully connects.
This enables custom automation on reconnect — for example, sending a "bot is back online" notification to the user.
## Changes
- `src/hooks/internal-hooks.ts`: Add `ChannelConnectedHookContext`, `ChannelConnectedHookEvent` types and `isChannelConnectedEvent` guard
- `src/web/auto-reply/monitor.ts`: Fire `channel:connected` hook on successful WhatsApp connect
## Usage
```ts
// In a hook handler:
if (isChannelConnectedEvent(event)) {
// event.context.channel === "whatsapp"
// event.context.accountId === the account that connected
await sendMessage({ message: "Bot reconnected! 🤖" });
}
```
Fixes the motivation from #7405 — allows agents to react to channel reconnects proactively.
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Adds a new `channel:connected` hook event that fires when a WhatsApp channel successfully connects, enabling custom automation on reconnect (e.g., sending "bot is back online" notifications).
- Added type definitions for `ChannelConnectedHookContext` and `ChannelConnectedHookEvent` with proper JSDoc documentation
- Implemented `isChannelConnectedEvent` guard function following existing validation patterns
- Integrated hook trigger in `monitor.ts` after successful WhatsApp connection, consistent with other event patterns
- All types are properly exported and match the documented API in the PR description
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk
- The implementation follows established patterns precisely, adds well-documented types, and integrates cleanly at the appropriate location. The changes are focused, non-breaking, and purely additive.
- No files require special attention
<sub>Last reviewed commit: cc9db95</sub>
<!-- greptile_other_comments_section -->
<sub>(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#7545: feat(hooks): add message:received hook for pre-turn automation
by wangtian24 · 2026-02-02
81.8%
#10109: feat(plugins): invoke message_received and message_sent hooks
by nezovskii · 2026-02-06
77.3%
#19922: feat(hooks): add message:received and message:sent hook events
by NOVA-Openclaw · 2026-02-18
75.7%
#10706: feat(hooks): add message:received internal hook for Telegram
by thebtf · 2026-02-06
74.9%
#11597: feat(hooks): implement message:received hook
by gnufoo · 2026-02-08
74.7%
#20859: fix(hooks): wire message_sent hook into reply dispatcher for all ch...
by davidrudduck · 2026-02-19
74.3%
#20399: feat(whatsapp): surface inbound reaction events to agent session
by andrewchen · 2026-02-18
72.1%
#13641: feat(whatsapp): surface incoming reaction events to agent
by asklee-klawd · 2026-02-10
71.5%
#7580: feat: add message:received internal hook with prompt injection
by rodrigoschott · 2026-02-03
71.4%
#12894: feat(whatsapp): add reaction notifications support
by ekson73 · 2026-02-09
71.2%