Error Sending Message with Venom js

Asked

Viewed 123 times

0

I’m using Venom.js to send messages by Whatsapp, it works perfectly, as long as the client sends the first interaction, ie when I try to send some basic text, at first it sends, but the second time I run the code it, Promise error appears in Puppeteer, I already searched the internet something that talks about but unsuccessfully; I tried to use Sulla, but the problem is the same, Follow the code and just below the error, I thank the staff of the forum, for giving valuable time to answer us;

const venom = require('venom-bot');

venom.create().then((client) => start(client));

async function start(client) {
// Send basic text
  await client
    .sendText('[email protected]', 'Olá Sou um Robô!')
    .then((result) => {
        console.log('Result: ', result.status);        
    })
    .catch((erro) => {
        console.error('Error no Processo: ', erro.status); //return object error
    });
}

I tried with async/await or without, but it only works once, maybe it’s a detail, but I need it to work constantly, because I will put data from a setInterval and every time another api receives a response will call Venomjs so it can send to Whatsapp;

(node:5420) UnhandledPromiseRejectionWarning: Error: Evaluation failed: ReferenceError: WAPI is not defined
    at __puppeteer_evaluation_script__:3:45
    at ExecutionContext._evaluateInternal (C:\wamp64\www\apiplug\desktop_dev\node_modules\puppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:221:19)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async ExecutionContext.evaluate (C:\wamp64\www\apiplug\desktop_dev\node_modules\puppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:110:16)
(node:5420) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use 
the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:5420) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

1 answer

-1

hello, I’m having the same problem , I also found no answer on other sites, so if you have solved let me know, because sometimes who needs help can also help.

BS: after I updated the Venom in August-21 , it only sends when someone has already started a conversation , but my goal has always been to warn the client not to interact.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.