Whatsapp BOT with nodeJs

`
const puppeteer = require(‘puppeteer’);

(async function(){

try{

const browser = await puppeteer.launch({ headless:false })
const page = await browser.newPage()

await page.setUserAgent(
“Mozilla/5.0 (X11; Linux x86_64) AppleWe…


This content originally appeared on DEV Community 👩‍💻👨‍💻 and was authored by pawan deore

`
const puppeteer = require('puppeteer');

(async function(){

try{

    const browser = await puppeteer.launch({ headless:false })
    const page = await browser.newPage()

    await page.setUserAgent(
        "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
      );

    await page.goto("https://web.whatsapp.com/")
    await page.waitForSelector("._13NKt");
    await delay(5000)


    const contactName = "Corona Bot";
    await page.click(`span[title='${contactName}']`);
    await page.waitForSelector('.fd365im1')


    const amountOfMessages = 10;

    for(var i =0; i<amountOfMessages; i++){

        await page.type(".p3_M1", "Hi, how are you, I hope you are good!");
        delay(2000)
        await page.keyboard.press("Enter");
        await delay(500)
    }


}catch(err){
    console.log(err)
}

})();

function delay(time){
return new Promise(function(resolve){
setTimeout(resolve, time)
})
}
`


This content originally appeared on DEV Community 👩‍💻👨‍💻 and was authored by pawan deore


Print Share Comment Cite Upload Translate Updates
APA

pawan deore | Sciencx (2022-11-20T06:04:20+00:00) Whatsapp BOT with nodeJs. Retrieved from https://www.scien.cx/2022/11/20/whatsapp-bot-with-nodejs/

MLA
" » Whatsapp BOT with nodeJs." pawan deore | Sciencx - Sunday November 20, 2022, https://www.scien.cx/2022/11/20/whatsapp-bot-with-nodejs/
HARVARD
pawan deore | Sciencx Sunday November 20, 2022 » Whatsapp BOT with nodeJs., viewed ,<https://www.scien.cx/2022/11/20/whatsapp-bot-with-nodejs/>
VANCOUVER
pawan deore | Sciencx - » Whatsapp BOT with nodeJs. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/11/20/whatsapp-bot-with-nodejs/
CHICAGO
" » Whatsapp BOT with nodeJs." pawan deore | Sciencx - Accessed . https://www.scien.cx/2022/11/20/whatsapp-bot-with-nodejs/
IEEE
" » Whatsapp BOT with nodeJs." pawan deore | Sciencx [Online]. Available: https://www.scien.cx/2022/11/20/whatsapp-bot-with-nodejs/. [Accessed: ]
rf:citation
» Whatsapp BOT with nodeJs | pawan deore | Sciencx | https://www.scien.cx/2022/11/20/whatsapp-bot-with-nodejs/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.