Skip to content

fix: This custom route implements a solution to the bug, allowing messages and images to be sent to WhatsApp Channels.#2488

Open
luisdalmasso wants to merge 1 commit intowppconnect-team:mainfrom
luisdalmasso:fix/newsletter-chatstore-injection
Open

fix: This custom route implements a solution to the bug, allowing messages and images to be sent to WhatsApp Channels.#2488
luisdalmasso wants to merge 1 commit intowppconnect-team:mainfrom
luisdalmasso:fix/newsletter-chatstore-injection

Conversation

@luisdalmasso
Copy link
Copy Markdown

Symptom: When trying to send messages to a WhatsApp channel/newsletter (in the format xxxx@newsletter) via wppconnect-server, the following error was encountered:

Chat not found in ChatStore for xxxx@newsletter
Root Cause: In wa-js v3.23.1, newsletters/channels are stored in a separate store called NewsletterStore, but are NOT registered in the ChatStore. When wpp.chat.sendTextMessage() is called, it internally executes assertFindChat(), which searches exclusively in the ChatStore. Since the newsletter is not found there, it throws the "Chat not found" error. The Solution
The custom-routes.ts file was created with custom endpoints that inject the newsletter into the ChatStore before sending the message, using Puppeteer's page.evaluate() to execute code directly in the WhatsApp Web browser context: Endpoint Method Description
/custom/:session/send-message-newsletter POST Send text to newsletter
/custom/:session/send-image-newsletter POST Send image/file to newsletter
/custom/:session/debug-wpp-newsletter GET Newsletter API diagnostics

…sages and images to be sent to WhatsApp Channels.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant