How to use simutaniously puppeteer and telegraf?

Hello everybody! I’m making a program for web scrap a page with Puppeteer and then send me the screenshot of this page in telegram, with the Telegraf module (telegram bot). Seperately it worked but I’m looking for solutions to integrate it so I can write it in the same code. Do you guys have an idea on how I can do it? I thought of using the Puppeteer part inside of a function inside a command of the Telegraf, but I don’t know how to do it and didn’t found anything about it in Telegraf’s documentation.
Above you can see the isolated parts:

const { Telegraf } = require('telegraf')

const bot = new Telegraf('ID'); => {

    ctx.reply("The bot can perform the following commands\n - /start\n - /help\n - command")


bot.command((ctx) => ctx.replyWithPhoto({ source: 'screenshot.png' }))


const puppeteer = require('puppeteer');

const santos_SELECTOR = 'body > div:nth-child(1) > div:nth-child(1) > div:nth-child(5) > a:nth-child(1)'

const username_SELECTOR = '#userid';

const password_SELECTOR = '#password';

const cta_SELECTOR = '#btLog'; 

const username = 'user'

const password = 'password'

const movimentacoes = 'div.itPagina:nth-child(30) > a:nth-child(1)'

const url = ''

async function startBrowser() {

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

  const page = await browser.newPage();

  return {browser, page};


async function playTest() {

  const {browser, page} = await startBrowser();

  page.setViewport({width: 1366, height: 768});

  await page.goto(url);



  await page.keyboard.type(username);


  await page.keyboard.type(password);



  await page.screenshot({path: "screenshot.png"})


(async () => {

  await playTest("");



This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.