sending buttons dont work in Whatsapp web js
Asked Answered
P

3

5

for some reason it doesn't want to send buttons, I looked it up online but didn't found help, here's my code:


const { Client, LocalAuth ,MessageMedia, Buttons } = require('whatsapp-web.js');

const client = new Client({
    authStrategy: new LocalAuth()
});

client.on('qr', qr => {
    qrcode.generate(qr, {small: true});
});

client.on('ready', () => {
    console.log('Client is ready!');
});


client.on('message', message => {
    console.log('message from', message.from)
    if (message.body === "!button") {

        let button = new Buttons('Button body',[{body:'bt1'},{body:'bt2'},{body:'bt3'}],'title','footer');
        client.sendMessage(message.from, button);

    }
});
 
client.initialize();
Polio answered 25/9, 2022 at 8:18 Comment(0)
F
6

Install using:

npm i github:pedroslopez/whatsapp-web.js#fix-buttons-list

or

yarn add github:pedroslopez/whatsapp-web.js#fix-buttons-list
Fatimahfatimid answered 23/10, 2022 at 2:14 Comment(3)
sendmessage doesnot work with thisTeshatesla
It has stopped working. Apparently, WhatsApp is reserving it for their API. However, when I use list sending or buttons in some clients like (web or iOS), sometimes it arrives but it's not predictable. For now, we need to avoid this.Fatimahfatimid
Sending buttons not working using thisNanette
C
0

-install Git Bash from here.

-open CMD and write: 'npm install git+https://github.com/pedroslopez/whatsapp-web.js#fix-buttons-list' in the project directory.

Don't forget call "Buttons" when you are define module. like this:

const { Client, LocalAuth  ,Buttons,List,MessageMedia} = require('whatsapp-web.js');
Complicity answered 24/12, 2022 at 9:3 Comment(2)
There was already an almost identical answerHarlanharland
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From ReviewPipsissewa
S
0

Buttons are no longer supported in unofficial libraries because Meta has deprecated them for web clients

Spiniferous answered 27/4 at 13:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.