open-wa / wa-automate-nodejs

💬 🤖 The most reliable tool for chatbots with advanced features. Be sure to 🌟 this repository for updates!
https://docs.openwa.dev/
Other
3.15k stars 600 forks source link

Something just changed and my buttons are not working #2328

Closed TramontaG closed 2 years ago

TramontaG commented 2 years ago

Are you using the latest version of the library?

Are you using Multi-device?

Current Behavior

I was using buttons just fine. However today I started to experience a crash on puppeteer when trying to send buttons. It is not related to my code because it remained unchanged.

Here is an example: My whatsapp bot is capable of doing google searches. When an user wants to search my bot gives two options: web search or image search.

const buttons = [
    {
        id: `!google web ${args.immediate}`,
        text: 'Pesquisa Web',
    },
    {
        id: `!google image ${args.immediate}`,
        text: 'Imagens',
    }
]

args.immediate is just text someone typed like a search bar.

When I try to send those buttons, I get nothing. No crash, no output, nothing, it's like I've never called this method.:

It was working fine like two hours ago. My code hasn't changed. I guess something just updated on the whatsapp web client and it changed how buttons are sent.

Expected Behavior

Send buttons normally again, maybe with some changes in the code.

Steps To Reproduce

Try to evoke

client.sendButtons(requester, "TestButtons", [
    {
        id: `!google web ${args.immediate}`,
        text: 'Pesquisa Web',
    },
    {
        id: `!google image ${args.immediate}`,
        text: 'Imagens',
    },
    ""
])

Mode

My own code

create() code

const startupOptions = {
    licenseKey: process.env.CLIENT_KEY,
    blockCrashLogs: false,
    disableSpins: false,
    hostNotificationLang: NotificationLanguage.PTBR,
    logConsole: false,
    viewport: {
        width: 1920,
        height: 1200,
    },
    deleteSessionDataOnLogout: true,
    popup: 3012,
    defaultViewport: null,
    sessionId: 'TramontaBot',
    headless: false,
    qrTimeout: 0,
    authTimeout: 60,
    restartOnCrash: false,
    useChrome: true,
    killProcessOnBrowserClose: true,
    throwErrorOnTosBlock: false,
    chromiumArgs: [
        '--no-sandbox',
        '--disable-setuid-sandbox',
        '--aggressive-cache-discard',
        '--disable-cache',
        '--disable-application-cache',
        '--disable-offline-load-stale-cache',
        '--disk-cache-size=0',
    ],
};

create(startupOptions).then(client => {
    start(client);
});

DEBUG INFO

WA_VERSION: 2.2146.9
PAGE_UA: WhatsApp/2.2144.11 Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36
WA_AUTOMATE_VERSION: 4.24.2
BROWSER_VERSION: Chrome/93.0.4577.0
OS: Windows 10
START_TS: 1638132617035

Environment

- OS: Windows 11
- Node: 16.2.0
- npm: 7.13.0

Screenshots

No response

Anything else?

No response

smashah commented 2 years ago

@TramontaG thanks a lot for filling the issue tempalte.

I think there's a problem with your code:

client.sendButtons(requester, "TestButtons", [
    {
        id: `!google web ${args.immediate}`,
        text: 'Pesquisa Web',
    },
    {
        id: `!google image ${args.immediate}`,
        text: 'Imagens',
    },
    "" // <=== Why is this empty string part of the buttons array?
])

Instead, try this:

client.sendButtons(requester, "TestButtons", [
    {
        id: `!google web ${args.immediate}`,
        text: 'Pesquisa Web',
    },
    {
        id: `!google image ${args.immediate}`,
        text: 'Imagens',
    }
], "", "")

I have tested the former and it results in no message being sent. The latter sends the message successfully.

Thanks

erickmourasilva commented 2 years ago

@smashah can't send buttons in MD version, prompt insider version. How do I solve this?

smashah commented 2 years ago

@smashah can't send buttons in MD version, prompt insider version. How do I solve this?

Hey Erik, you can get an insider's license or wait until MD buttons become Generally available/ MD is no longer beta and everyone is forced to use it.