fix(whatsapp): wire up initWhatsApp on main bot startup#48
Open
bizapen wants to merge 1 commit into
Open
Conversation
The /wa command was always responding 'WhatsApp not connected' because src/index.ts never called initWhatsApp() — the in-process Client was imported and exported but never instantiated. Result: WHATSAPP_ENABLED in .env had no effect, and the entire WhatsApp bridge feature was silently broken in v1.1.0. Changes: - src/index.ts: import WHATSAPP_ENABLED, initWhatsApp, notifyWhatsAppIncoming. After dashboard starts on the main agent, if WHATSAPP_ENABLED is true, call initWhatsApp() with a callback that forwards incoming WhatsApp messages to Telegram via notifyWhatsAppIncoming. Errors are logged but never block bot startup, so a broken WhatsApp setup cannot bring the bot down. - package.json / package-lock.json: bump whatsapp-web.js 1.34.6 to 1.34.7 to fix 'waitForChatLoading' TypeError when opening a chat via fetchMessages (Meta updated WhatsApp Web internals). Verified working: /wa lists chats, opening by number reads history, 'r <text>' sends replies, incoming WhatsApp messages produce a Telegram notification ping.
robkloti
pushed a commit
to robkloti/claudeclaw
that referenced
this pull request
May 11, 2026
…opters#49) Document the two failure modes users hit when deploying ClaudeClaw to cloud platforms: missing Claude Code auth (set CLAUDE_CODE_OAUTH_TOKEN or ANTHROPIC_API_KEY) and ephemeral container storage (mount a persistent volume for store/). Added because community members keep debugging the generic "subprocess crashed" message for hours when the fix is one env var. Refs earlyaidopters#48. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
The
/wacommand always returns "WhatsApp not connected. Make sure WHATSAPP_ENABLED=true and the service is running." even whenWHATSAPP_ENABLED=trueis set in.envand the user has scanned the QR via the wa-daemon.Root cause:
src/index.tsnever callsinitWhatsApp(). The in-processwhatsapp-web.jsClient defined insrc/whatsapp.tsis imported and exported by the module but never instantiated by the main bot. As a result, when/waruns and reachesgetWaChats(), theclientreference is null and the function throwsWhatsApp not connected. SettingWHATSAPP_ENABLED=truein.envhas no effect because nothing reads it.The setup wizard offers WhatsApp as a feature and configures the daemon, but the main bot never wires the in-process client into its startup sequence.
Fix
src/index.ts:WHATSAPP_ENABLEDfrom config,initWhatsAppfrom whatsapp,notifyWhatsAppIncomingfrom botWHATSAPP_ENABLEDis true, callinitWhatsApp()with a callback that forwards incoming WhatsApp messages to Telegram vianotifyWhatsAppIncomingpackage.json/package-lock.json:whatsapp-web.js1.34.6 to 1.34.7 to fix the upstreamCannot read properties of undefined (reading 'waitForChatLoading')TypeError when callingfetchMessagesto open a chat. WhatsApp Web internals shifted recently and 1.34.7 catches up.Verified working end to end on macOS Apple Silicon
/walists chats with unread countsr <text>andr <num> <text>quick-reply both deliver to WhatsApp📱 Name — new messagepingWHATSAPP_ENABLEDis unset orfalse(logs "WhatsApp bridge disabled")/wareturns the existing not-connected message)