pedroslopez / whatsapp-web.js

A WhatsApp client library for NodeJS that connects through the WhatsApp Web browser app
https://wwebjs.dev
Apache License 2.0
15.46k stars 3.68k forks source link

Reply to a message won't work when the message is not in the cache #1456

Open rodrigogomide opened 2 years ago

rodrigogomide commented 2 years ago

Is there an existing issue for this?

Describe the bug

When I send a reply to a message, indicating the message ID, it shows an error and does not send.

Expected behavior

By indicating the message ID for reply, the reply should be sent normally.

Steps to Reproduce the Bug or Issue

  1. Start the API;
  2. In whatsapp APP, send any message;
  3. Capture the serialize of the received message;
  4. Send a reply to the message indicating the serialize received;
  5. The reply will be sent normally;
  6. Disable the API;
  7. Reactivate the API by reading the QR again;
  8. Try sending the reply again for the same message, redoing step 4. The reply will not be sent, indicating an error;

Relevant Code

send_to = whatsapp_number@c.us send_msg = "hello man!" reply_msd_id = msg serialized received

ex.: reply_msg_id = "false_553111112222@c.us_ASD123ASD123JHASD"

const sent_msg = await CLIENT.sendMessage(send_to, send_msg, {"linkPreview": set_link_preview, "quotedMessageId": reply_msg_id});

When the message ID is from a message received by the API in a previous instance, when trying to send the response it fails. It looks like the message ID is not in the WhatsApp Web cache. It would be necessary to search for the message using the given ID to load the message object and then send the response.

Browser Type

Google Chrome

WhatsApp Account Type

Standard

Does your WhatsApp account have multidevice enabled?

Yes, I am using Multi Device

Environment

Debian Linux Android + iOs

Additional context

We could use searchMessage to find the message by indicating the message ID. With the message object returned, apply the reply for sending.

Armanzahedi commented 2 years ago

Same problem over here. can not reply to a message even if client is restored from a previous session.

Error: "Evaluation failed: TypeError: Cannot read properties of undefined (reading 'canReply')\n at Object.window.WWebJS.sendMessage (__puppeteer_evaluation_script__:34:31)\n at __puppeteer_evaluation_script__:10:45"

satriowicaksn commented 2 years ago

Hi is this problem not resolved?

kevindevm commented 2 years ago

Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'canReply')
    at Object.window.WWebJS.sendMessage (__puppeteer_evaluation_script__:34:31)
    at __puppeteer_evaluation_script__:10:45```
wenked commented 2 years ago

Same here

natanjborba commented 1 year ago

Same here, solution?

Hasnen-mr commented 8 months ago

Same here, any solution?

JshGrn commented 8 months ago

Same :/

juancruzsosagab commented 7 months ago

Same!