Skip to content

fix(whatsapp): send unavailable presence on connect to preserve phone notifications - #30608

Closed
Ecarrion wants to merge 1 commit into
openclaw:mainfrom
Ecarrion:fix/whatsapp-presence-unavailable
Closed

Ecarrion wants to merge 1 commit into
openclaw:mainfrom
Ecarrion:fix/whatsapp-presence-unavailable

Conversation

@Ecarrion

@Ecarrion Ecarrion commented Mar 1, 2026

Copy link
Copy Markdown

Summary

Fixes #30286

Baileys explicitly called sendPresenceUpdate('available') in src/web/inbound/monitor.ts on connect, overriding markOnlineOnConnect: false in session.ts. This suppresses all push notifications on the phone for every chat while the gateway is running.

Root cause: The existing markOnlineOnConnect: false in session.ts is correct, but it was overridden by the explicit sendPresenceUpdate("available") call in inbound/monitor.ts.

Changes

  • src/web/inbound/monitor.ts: use "unavailable" presence by default; read from options.announcePresence
  • src/web/auto-reply/monitor.ts: thread announcePresence through
  • src/web/accounts.ts: resolve announcePresence (default false)
  • src/config/types.whatsapp.ts: add announcePresence field
  • src/config/zod-schema.providers-whatsapp.ts: add zod validation
  • src/web/monitor-inbox.streams-inbound-messages.test.ts: update assertions
  • src/web/monitor-inbox.captures-media-path-image-messages.test.ts: update assertions

Config

// To restore old behavior (announce online presence):
"channels": { "whatsapp": { "announcePresence": true } }

Comparison: Beeper (also Baileys-based) uses the same approach and does not suppress phone notifications.

… notifications

Fixes openclaw#30286

Baileys explicitly called `sendPresenceUpdate('available')` in
`src/web/inbound/monitor.ts` on connect, overriding `markOnlineOnConnect: false`
in `session.ts`. This suppresses all push notifications on the phone for every
chat while the gateway is running.

Changed to `sendPresenceUpdate('unavailable')` by default. Added optional
`channels.whatsapp.announcePresence` config flag (default: `false`) for users
who want to opt back into online presence.
@openclaw-barnacle openclaw-barnacle Bot added channel: whatsapp-web Channel integration: whatsapp-web size: XS labels Mar 1, 2026
@greptile-apps

greptile-apps Bot commented Mar 1, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a bug where WhatsApp phone notifications were being suppressed while the gateway is running. The root cause was an explicit sendPresenceUpdate("available") call in monitor.ts that overrode the existing markOnlineOnConnect: false setting in session.ts.

Key changes:

  • Added announcePresence configuration field (defaults to false) to control online presence behavior
  • Modified presence logic to send "unavailable" by default, which preserves phone push notifications
  • Properly threaded the configuration through all layers: config types → account resolution → monitors
  • Updated tests to reflect new default behavior
  • Maintains backward compatibility via config option channels.whatsapp.announcePresence: true

The implementation is clean, well-documented, and follows the existing codebase patterns. The default behavior now matches other Baileys-based implementations like Beeper.

Confidence Score: 5/5

  • This PR is safe to merge with no issues identified
  • The changes are focused, well-tested, and address a specific bug without introducing new risks. The implementation follows TypeScript best practices with proper typing, default values are consistently applied across all layers, tests are updated appropriately, and backward compatibility is maintained through configuration.
  • No files require special attention

Last reviewed commit: 1275a3f

@OmriBenShoham

Copy link
Copy Markdown

👍

1 similar comment
@GalDayan

GalDayan commented Mar 1, 2026

Copy link
Copy Markdown

👍

@yhyatt

yhyatt commented Mar 5, 2026

Copy link
Copy Markdown
Contributor

👍

@Ecarrion

Ecarrion commented Mar 5, 2026

Copy link
Copy Markdown
Author

@steipete 👋 can I help somehow to get this merged? Thanks!

@aliasgharchakera

Copy link
Copy Markdown

LGTM 👍

@mcaxtr

mcaxtr commented Apr 2, 2026

Copy link
Copy Markdown
Member

Thanks for the PR and for working on this — the root cause analysis in #30286 was spot-on and directly informed the fix that landed.

We checked the current main branch and implemented a targeted fix via #59410, which gates the connect-time presence on the existing selfChatMode flag: personal-phone setups (selfChatMode: true) now send "unavailable" to preserve phone notifications, while dedicated bot numbers keep "available" so the bot shows as online. This avoids both a new config field and a blanket behavior change for all users.

Because #59410 covers this, I'm closing this PR as superseded.

Thanks again for the work here @Ecarrion for the detailed issue writeup and Beeper comparison that confirmed the root cause. If you think this closure is mistaken and your PR still fixes something meaningfully different on current main, feel free to reopen or open a new PR with that explanation.

@mcaxtr mcaxtr closed this Apr 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: whatsapp-web Channel integration: whatsapp-web size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: WhatsApp personal number connection (Baileys) announces online presence on connect, suppressing all phone push notifications

6 participants