-
-
Notifications
You must be signed in to change notification settings - Fork 725
Description
Description
The onPollResponse event is not triggering when a user votes on a poll. Although the logs show that the event is successfully registered (debug: [client] Registering onPollResponse event), the callback function is never executed when an actual vote happens.
Environment
Wppconnect version(s): 1.38.0
WA-JS version: 3.18.4
Browser: Chromium (via Puppeteer 24.16.2)
OS: Windows / Linux (mention your OS here)
Node version: (Check using node -v, likely 20.x or 22.x)
WhatsApp version: Latest Web Version (Decrypted via WA-JS 3.18.4)
MultiDevice: Yes
Steps to Reproduce
Initialize a session with onPollResponse: true in the create config.
Register the listener using session.onPollResponse.
Send a poll using client.sendPollMessage.
Vote on the poll from a different WhatsApp account.
Observe that no logs appear and the event does not fire.
Log Output
debug: [hello123:client] Exposing onPollResponse function
debug: [hello123:client] Emitting onInterfaceChange event (1 registered)
http: [hello123:client] Checking phone is connected...
debug: [hello123:client] Registering onAnyMessage event
debug: [hello123:client] Registering onMessage event
debug: [hello123:client] Registering onPollResponse event
debug: [hello123:client] Registering onAck event
✅ Inside Session Block
// NO LOGS PRODUCED AFTER VOTING
Your Code
import * as wppconnect from '@wppconnect-team/wppconnect';
/**
- BUG REPORT: onPollResponse Event Listener Not Triggering
- Library: @wppconnect-team/wppconnect v1.38.0
*/
wppconnect.create({
session: 'poll-debug-session',
onPollResponse: true, // <--- Flag is explicitly enabled
whatsappVersion: '2.3000.10177x', // Tested with stable alpha/latest versions
headless: true,
}).then((session) => {
console.log('✅ Client is ready. Testing poll listeners...');
// --- THE ISSUE: THIS LISTENER NEVER FIRES ---
session.onPollResponse((poll) => {
// Ye block kabhi execute nahi ho raha, chahe koi bhi vote kare
console.log('🎯 [EVENT TRIGGERED] Poll Vote Received!');
console.log('Poll Data:', JSON.stringify(poll, null, 2));
});
// --- DEBUGGING: CHECKING IF BROADCAST EVENTS ARE VISIBLE ---
session.onAnyMessage((msg) => {
// Jab vote hota hai, toh yahan activity dikhti hai (type: 'poll_update' or 'poll_creation')
// Lekin dedicated onPollResponse silent rehta hai.
if (msg.type === 'poll_creation' || msg.pollUpdates) {
console.log(⚠️ Detected ${msg.type} via onAnyMessage, but onPollResponse did NOT trigger.);
}
});
console.log('🚀 Listener registered. Please vote from another device now.');
});
Additional context / Screenshot
Add any other context about the problem here. If applicable, add screenshots to help explain.