I'm using whatsapp-web.js for automating responses on my WhatsApp business profile. But there's a recurring issue where the bot mistakenly interprets my contact's status updates (posted publicly to their profile) as incoming messages from them, and sends me "ghost notifications" for messages I didn't receive from these contacts.. Is that a common issue?
Here's my basic message handling logic, as you can see I incorporated bunch of checks to exclude status updates but none of them are working.
client.on('message', async (msg) => {
// Ignore messages if client isn't ready, from the bot itself, or from a group:
if (!isReady || msg.fromMe || msg.isGroup) return;
// Ignore non-chat message types (status updates, calls, sys msgs, etc.):
const ignoredTypes = ['status_v3', 'e2e_notification', 'notification_c', 'call_log', 'revoked', 'chatstate'];
if (ignoredTypes.includes(msg.type)) {
return;
}
const chatId = msg.from;
try {
// THIS BLOCK CONTAINS MAIN MESSAGE HANDLER ...
}
});
None of these checks are working; the client continues to execute the main message handler code for contacts even if they just uploaded a status update. If it would help to see the message hander code too let me know.
Thanks in advance for the help. P.S. I'm terrible at coding, I just learned the minimum amt needed to code scripts to automate tasks for my freelance work! Apologies in advance for noob mistakes.