Whatsapp-web js doesn't fire ready event – Whatsapp

by
Maya Patel
node.js whatsapp

Quick Fix: To resolve the issue of WhatsApp-Web.js not firing the "ready" event, try updating the package to version "https://github.com/Julzk/whatsapp-web.js/tarball/jkr_hotfix_7" and installing it using npm.

The Problem:

Whatsapp-web.js library is used to interact with WhatsApp web. The ‘ready’ event is fired when the client is successfully authenticated and connected to WhatsApp. However, in some cases, the ‘ready’ event is not fired, even though the QR code is scanned and authentication is successful. This issue prevents the user from sending or receiving messages or performing other actions on WhatsApp web.

The Solutions:

Solution 1: Fix whatsapp-web.js version

To fix the issue with the ready event not firing in whatsapp-web.js, follow these steps:

  1. Run the command

npm r whatsapp-web.js

  1. In your package.json file, set the whatsapp-web.js version to:
"whatsapp-web.js": "https://github.com/Julzk/whatsapp-web.js/tarball/jkr_hotfix_7"
  1. Run the command

npm install

This should fix the issue and allow the ready event to fire properly.

Solution 2: Modifying the whatsapp-web.js source code

To resolve the issue of the “ready” event not firing in whatsapp-web.js, you can modify the client.js file within the node_modules/whatsapp-web.js/src/client.js directory. Specifically, you need to change line 175 by replacing the following code:

const INTRO_IMG_SELECTOR = 'div[role=\'textbox\']'; //'[data-icon=\'chat\']';

With this change, you can ensure that the “ready” event is triggered as expected when using whatsapp-web.js.

Q&A

Why ready event not work on Whatsapp-web js?

Whatsapp-web.js version lower than Jkr_hotfix_7

What is the fix for ready event not firing?

Need to modify client.js file in node_modules.

Video Explanation:

The following video, titled "How to use Whatsapp web JS - Node JS Setup and Authentication ...", provides additional insights and in-depth exploration related to the topics discussed in this post.

Play video

Are you interested in building a chat application like Whatsapp Web? This tutorial series is for you! In Part 1, we will walk you through ...