Skip to content

feat(whatsapp): add Newsletter/Channel JID support#13424

Closed
agentz-manfred wants to merge 2 commits into
openclaw:mainfrom
agentz-manfred:feat/whatsapp-newsletter-support
Closed

feat(whatsapp): add Newsletter/Channel JID support#13424
agentz-manfred wants to merge 2 commits into
openclaw:mainfrom
agentz-manfred:feat/whatsapp-newsletter-support

Conversation

@agentz-manfred

@agentz-manfred agentz-manfred commented Feb 10, 2026

Copy link
Copy Markdown

Summary

Adds support for WhatsApp Newsletter/Channel JIDs (xxxxx@newsletter) in the message tool's target validation. Currently, the normalizeWhatsAppTarget() 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.ts

  • Added isWhatsAppNewsletterJid() helper that matches \d+@newsletter format
  • Newsletter JIDs are now passed through normalizeWhatsAppTarget() instead of being rejected

src/channels/plugins/outbound/whatsapp.ts

  • Newsletter JIDs are treated like group JIDs in outbound routing (bypass allowFrom checks, since channels are owned/administered by the sender)

How it works

The underlying Baileys library already supports sendMessage() to @newsletter JIDs — the toWhatsappJid() utility in src/utils.ts correctly 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 relaxing normalizeWhatsAppTarget() validation and allowing outbound routing to bypass allowFrom checks for newsletter targets (treated similarly to group JIDs).

Key behavior changes:

  • src/whatsapp/normalize.ts introduces isWhatsAppNewsletterJid() and returns newsletter JIDs unchanged from normalizeWhatsAppTarget().
  • src/channels/plugins/outbound/whatsapp.ts now treats newsletter JIDs like group JIDs in resolveTarget().

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

  • This PR is close but has a routing inconsistency that should be fixed before merge.
  • Normalization and outbound adapter logic accept newsletter JIDs, but outbound session routing still treats them as direct chats, which can change session keys/metadata and lead to inconsistent behavior across the pipeline.
  • src/infra/outbound/outbound-session.ts

(2/5) Greptile learns from your feedback when you react with thumbs up/down!

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

@greptile-apps

greptile-apps Bot commented Feb 10, 2026

Copy link
Copy Markdown
Contributor
Additional Comments (2)

src/infra/outbound/outbound-session.ts
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.

Prompt To Fix With AI
This 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.

src/channels/plugins/outbound/whatsapp.ts
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.

Prompt To Fix With AI
This 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
@agentz-manfred
agentz-manfred force-pushed the feat/whatsapp-newsletter-support branch from 305ff26 to 35ead83 Compare February 14, 2026 19:35
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added stale Marked as stale due to inactivity and removed stale Marked as stale due to inactivity labels Feb 21, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Mar 10, 2026
@openclaw-barnacle

Copy link
Copy Markdown

Closing due to inactivity.
If you believe this PR should be revived, post in #pr-thunderdome-dangerzone on Discord to talk to a maintainer.
That channel is the escape hatch for high-quality PRs that get auto-closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: XS stale Marked as stale due to inactivity

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WhatsApp Newsletter/Channel support in message tool

1 participant