feat(whatsapp): add Newsletter/Channel JID support#13424
feat(whatsapp): add Newsletter/Channel JID support#13424agentz-manfred wants to merge 2 commits into
Conversation
Additional Comments (2)
Prompt To Fix With AIThis is a comment left during a code review.
Path: src/infra/outbound/outbound-session.ts
Line: 333:343
Comment:
**Newsletter JIDs routed as direct**
`normalizeWhatsAppTarget()` can now return `\d+@newsletter`, but `resolveWhatsAppSession()` only checks `isWhatsAppGroupJid()` to decide `peer.kind/chatType`. As a result, newsletter targets will be treated as `direct` here, which can produce DM-style session keys/metadata and make session continuity/templating differ from the outbound adapter’s “treat like group” behavior.
How can I resolve this? If you propose a fix, please make it concise.
With newsletter JIDs now accepted, the Prompt To Fix With AIThis is a comment left during a code review.
Path: src/channels/plugins/outbound/whatsapp.ts
Line: 29:35
Comment:
**Error message omits newsletter**
With newsletter JIDs now accepted, the `missingTargetError("<E.164|group JID> ...")` text is misleading for users trying to send to `...@newsletter`. The prompt should mention newsletter/channel JIDs as a valid target format too.
How can I resolve this? If you propose a fix, please make it concise. |
Add support for WhatsApp Newsletter/Channel JIDs (xxxxx@newsletter) in the message tool's target validation. Changes: - Add isWhatsAppNewsletterJid() helper in normalize.ts - Pass newsletter JIDs through normalizeWhatsAppTarget() instead of rejecting them as unknown JID formats - Treat newsletter JIDs like group JIDs in outbound routing (bypass allowFrom checks, since channels are owned by the sender) - Route newsletter targets as peer.kind='group' in session resolver - Update error messages to mention newsletter JID as valid format The underlying Baileys library already supports sendMessage() to @newsletter JIDs. This change only removes the validation barrier that prevented newsletter targets from reaching the send path. Rebased on latest main to resolve merge conflicts. Closes openclaw#13417
305ff26 to
35ead83
Compare
bfc1ccb to
f92900f
Compare
|
This pull request has been automatically marked as stale due to inactivity. |
|
This pull request has been automatically marked as stale due to inactivity. |
|
Closing due to inactivity. |
Summary
Adds support for WhatsApp Newsletter/Channel JIDs (
xxxxx@newsletter) in the message tool's target validation. Currently, thenormalizeWhatsAppTarget()function rejects any JID containing@that isn't a group JID (@g.us) or user JID (@s.whatsapp.net/@lid), which prevents sending messages to WhatsApp Channels.Changes
src/whatsapp/normalize.tsisWhatsAppNewsletterJid()helper that matches\d+@newsletterformatnormalizeWhatsAppTarget()instead of being rejectedsrc/channels/plugins/outbound/whatsapp.tsallowFromchecks, since channels are owned/administered by the sender)How it works
The underlying Baileys library already supports
sendMessage()to@newsletterJIDs — thetoWhatsappJid()utility insrc/utils.tscorrectly passes through any JID containing@. This PR only removes the validation barrier in the normalize/outbound layer that prevented newsletter targets from reaching the send path.Use case
WhatsApp Channels (launched 2023) are one-way broadcast channels. Bot accounts that are admins/owners of a channel should be able to post to it via the message tool using the newsletter JID as target (e.g.
120363xxx@newsletter).Closes #13417
Greptile Overview
Greptile Summary
This PR adds WhatsApp Newsletter/Channel JID (
\d+@newsletter) support by relaxingnormalizeWhatsAppTarget()validation and allowing outbound routing to bypassallowFromchecks for newsletter targets (treated similarly to group JIDs).Key behavior changes:
src/whatsapp/normalize.tsintroducesisWhatsAppNewsletterJid()and returns newsletter JIDs unchanged fromnormalizeWhatsAppTarget().src/channels/plugins/outbound/whatsapp.tsnow treats newsletter JIDs like group JIDs inresolveTarget().Main follow-up needed before merge: other parts of the outbound pipeline (session routing/metadata) still classify newsletter targets as direct chats, which likely causes inconsistent session keys and chatType compared to the adapter’s intended behavior.
Confidence Score: 3/5
(2/5) Greptile learns from your feedback when you react with thumbs up/down!