NodeJs Telegram bot on VPS, need help switching to webhook

27
February 21, 2021, at 10:00 AM

please, help me understand how to switch my Telegram bot from polling to webhook. I have a VPS server where my bot is deployed. There's no domain name, just the IP. Also, I have created a public and a private self-signed certificates:

openssl req -newkey rsa:2048 -sha256 -nodes -keyout YOURPRIVATE.key -x509 -days 365 -out YOURPUBLIC.pem -subj "/C=RU/ST=Moscow/L=Moscow/O=School/CN=111.11.111.11

Currently, this bot example works via polling. This is what's inside /opt/mybot/index.js on my server.

    const TelegramBot = require('node-telegram-bot-api');
    const token = 'AAAAAAAAAAA:BBBBBBBBBBBBBBBBBBBBBBBBBBBB';
    const bot = new TelegramBot(token, {
        polling: {
            interval: 100,
            autoStart: true,
            params: {
                timeout: 10
            }
        }
    });
    bot.on('message', msg => {
        console.log('Hey!')
        bot.sendMessage(msg.chat.id, 'I am alive!');
});

How do I switch it to working via webhook? I've been trying, but can't seem to get the hang of it. Thank you.

READ ALSO
I have problem with IE11 in Grid. I uploaded my code. It work fine in chrome and firefox [closed]

I have problem with IE11 in Grid. I uploaded my code. It work fine in chrome and firefox [closed]

Want to improve this question? Add details and clarify the problem by editing this post

30
Does the usage of FLAG_SECURE with respect to activity's window blocks the user triggered foreground screenshots too?

Does the usage of FLAG_SECURE with respect to activity's window blocks the user triggered foreground screenshots too?

I m using a web view wherein my pages are renderedI want to apply FLAG_SECURE on the web view

64
Copy half the rows in a pandas dataframe to another dataframe

Copy half the rows in a pandas dataframe to another dataframe

I copied one dataframe to another using the below code

58