Telegram bot does not auto-wake up on request

My telegram bot that I hosted on glitch runs on polling (Code written in nodejs). It stays active for 5 minutes on idle, no big deal, it can go offline after that. But the main problem is, it doesnt restart when it gets a new message from the user. I don’t mind the restart time or whatever, but it just doesn’t wake up unless I manually go and open my project from the glitch.com website. Am I doing anything wrong? Any fixes for this?

UPDATE: I have tried switching to webhook, set my webhook by adding this piece of code:

  bot.telegram.setWebhook('https://projectname.glitch.me/bot' + BOT_TOKEN)
  bot.startWebhook("/bot"+BOT_TOKEN, null, 5000)

I have also sent a POST request to set the webhook url to Telegram by:

https://api.telegram.org/bot<BOT_TOKEN>/setWebhook?url=https://projectname.glitch.me/bot<BOT_TOKEN>

But, the webhooks are not working and doing /getWebhookInfo returns this:

{
  "ok": true,
  "result": {
    "url": "https://projectname.glitch.me/bot<BOT_TOKEN>",
    "has_custom_certificate": false,
    "pending_update_count": 8,
    "last_error_date": 1653741880,
    "last_error_message": "Wrong response from the webhook: 403 Forbidden",
    "max_connections": 40,
    "ip_address": "52.203.39.37"
  }
}

How do I fix this? Is the port number wrong?

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