Get your API key

Lesson 4 of 5

Keep it online: webhooks and hosting

Why the bot dies when the laptop sleeps, polling vs webhook with a secret token, free and cheap hosts compared, where data lives, and debugging with getWebhookInfo.

9 min Log in to open
One step at a time, like flipping pages.

By the end of this lesson your bot will run on a server that never sleeps, receive messages by webhook with a secret check, keep its orders in a hosted database, and send the 11 AM reminder without your laptop.

You need: the bot from lesson 3, a free Cloudflare account (or another host from the table below), your coding agent · Time: 9 minutes

  1. Right now the bot lives on your laptop. Close the lid, lose Wi-Fi or let Windows restart for an update, and the program stops. Telegram keeps new messages for up to 24 hours, then drops them. Customers see a bot that does not answer, and the 11 AM reminder never goes out.

    For a business bot you need a host: a computer in a data centre that runs your code all day, every day.

    Why?

    Mrs. Sharma's customers order at 10 PM and 7 AM, not when your laptop happens to be open. A bot that answers only sometimes is worse than no bot: people stop trusting it.

Log in free to read the rest of this lesson

Every lesson is free. A free account unlocks all of them and saves your progress.

Still to come in this lesson:

  1. Polling vs webhook, for Telegram
  2. Choose a home for the bot
  3. Move the bot online with one prompt
  4. Check the webhook with getWebhookInfo
  5. Recap