Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting message as Sent but message is not sent #34

Open
koyalkarvarun opened this issue Oct 14, 2021 · 8 comments
Open

Getting message as Sent but message is not sent #34

koyalkarvarun opened this issue Oct 14, 2021 · 8 comments

Comments

@koyalkarvarun
Copy link

I have followed all all things but messages are not been sent. In cmd it is showing message as sent but in real message is not been sent

@linco6054
Copy link

getting the same problem any solution to this ?

@Guyc1800
Copy link

getting the same problem any solution to this ?

yes me also, it worked only when I set showBrowser: true. but it works really slow. this is my code
wbm.start({showBrowser:false}).then(async () => {
const message = 'Good Morning. this message sent using javascript';
await wbm.send(phones, message);
await wbm.end();
}).catch(err => console.log(err));

@neelv-wmt
Copy link

Is there any update on this I am getting the same issue and cannot figure out why this is happening

@Guyc1800
Copy link

Guyc1800 commented Feb 9, 2022

Is there any update on this I am getting the same issue and cannot figure out why this is happening

What did you use ? Send or sendto and what are your settings

@neelv-wmt
Copy link

Is there any update on this I am getting the same issue and cannot figure out why this is happening

What did you use ? Send or sendto and what are your settings

I am using send with showBrowser as false and even when I change the value to true the message is sent to only the first number rest it shows as sent but is not reflected on WhatsApp

@Guyc1800
Copy link

Guyc1800 commented Feb 10, 2022

There are couple of bugs here from what I saw, first the package works in this way, it opens chromium in the background, then goes to whatsapp web and from there if you already logged in(with qr) it detects that you already in chat(using Dom and other methods) else if you are not already connected then it takes the qr data from the element in the dom , print the qr to the console using its data and another package then exit the code.
You have 2 functions which is send and sendto , basically send is sendto in for loop so lets ignore this for now.
What sendto does is go to
Http://web.whatsapp.com/send?phone=1234567&text=message
This opens the chat with the message already typed(but not sent) for this phone number.
From there it waits for the element on the page to load and when it does load, it press enter and end.
This rise couple of problems
First , the problem with showbrowser=false, since chromium runs in the background the key doesn't trigger the send method so the message doesn't send although it says it does, my solution for this problem was replace the enter key press with this, first I wait for the send button to load then I the button element using the dom and run button.click() . This works great in the background.
The second problem was that if you send multiple messages using send method it doesn't always send them all and usually only the last one.
Whatsapp message has 4 states. 1.waiting to be send(little clock symbol), 2. sent(1 gray V) 3. delivered ( 2 gray V) and read which is 2 blue V.
The problem is when you sending multiple messages it click send and then immediately goes to a different chat(to send the next message) although the message is still in stage 1 (waiting to be send).
Simple solution is go to the dom make a collection of all the messages (they have same classes) find the little icon of the state of the message , over there in one of the many elements you have an attribute of the message status (read sent etc..), you can test what is the status when the message is on wait(first stage) and then wait for it to change using dom. I dont remember exactly what is the names of the different stages but you can find it easily using devtools, i suggest disconnect first from the wifi so the attribute will stay on first stage and will not move to the next one.
In addition I suggest you to read the api code in node_modules>wbm>src>api.js
It only about 200 lines , not that complicated, and anything you don't quite understand you can find easily on Google, the 2 main packages that he use is puppeteer for chromium and qrcode-terminal for the qr in the console, there are other packages like rxjs which is used for a part of the code which has observers (like promise but different).
If you have any questions feel free to mail me

Is there any update on this I am getting the same issue and cannot figure out why this is happening

What did you use ? Send or sendto and what are your settings

I am using send with showBrowser as false and even when I change the value to true the message is sent to only the first number rest it shows as sent but is not reflected on WhatsApp

@neelv-wmt
Copy link

neelv-wmt commented Feb 11, 2022

There are couple of bugs here from what I saw, first the package works in this way, it opens chromium in the background, then goes to whatsapp web and from there if you already logged in(with qr) it detects that you already in chat(using Dom and other methods) else if you are not already connected then it takes the qr data from the element in the dom , print the qr to the console using its data and another package then exit the code. You have 2 functions which is send and sendto , basically send is sendto in for loop so lets ignore this for now. What sendto does is go to Http://web.whatsapp.com/send?phone=1234567&text=message This opens the chat with the message already typed(but not sent) for this phone number. From there it waits for the element on the page to load and when it does load, it press enter and end. This rise couple of problems First , the problem with showbrowser=false, since chromium runs in the background the key doesn't trigger the send method so the message doesn't send although it says it does, my solution for this problem was replace the enter key press with this, first I wait for the send button to load then I the button element using the dom and run button.click() . This works great in the background. The second problem was that if you send multiple messages using send method it doesn't always send them all and usually only the last one. Whatsapp message has 4 states. 1.waiting to be send(little clock symbol), 2. sent(1 gray V) 3. delivered ( 2 gray V) and read which is 2 blue V. The problem is when you sending multiple messages it click send and then immediately goes to a different chat(to send the next message) although the message is still in stage 1 (waiting to be send). Simple solution is go to the dom make a collection of all the messages (they have same classes) find the little icon of the state of the message , over there in one of the many elements you have an attribute of the message status (read sent etc..), you can test what is the status when the message is on wait(first stage) and then wait for it to change using dom. I dont remember exactly what is the names of the different stages but you can find it easily using devtools, i suggest disconnect first from the wifi so the attribute will stay on first stage and will not move to the next one. In addition I suggest you to read the api code in node_modules>wbm>src>api.js It only about 200 lines , not that complicated, and anything you don't quite understand you can find easily on Google, the 2 main packages that he use is puppeteer for chromium and qrcode-terminal for the qr in the console, there are other packages like rxjs which is used for a part of the code which has observers (like promise but different). If you have any questions feel free to mail me

Is there any update on this I am getting the same issue and cannot figure out why this is happening

What did you use ? Send or sendto and what are your settings

I am using send with showBrowser as false and even when I change the value to true the message is sent to only the first number rest it shows as sent but is not reflected on WhatsApp

Thanks this was helpful

@Sajad321
Copy link

I am facing the same issues here

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

No branches or pull requests

5 participants