For most small, bursty bots, a serverless function behind a Telegram webhook is the lightest operational choice. For bots that need a continuously running process, long polling, local state, or predictable runtime behavior, a VPS is the better fit. Telegram supports both approaches, but a single bot cannot use webhook delivery and long polling at the same time. Choose the hosting model around that delivery method first, then weigh runtime, networking, security, and operational needs.
Start with the delivery model, not the hosting brand
Telegram gives a bot two mutually exclusive ways to receive updates:
As an Amazon Associate I earn from qualifying purchases.
- Webhook: Telegram pushes each update to an HTTPS URL you control.
- Long polling: your process calls
getUpdates, keeps the request open while waiting, then repeats it when the request returns.
The Bot API reference documents both methods at core.telegram.org/bots/api. A webhook is naturally aligned with an event-driven function that starts when an HTTP request arrives. Long polling is naturally aligned with an always-running process, such as one managed on a VPS. A VPS can also receive webhooks, and a serverless platform can sometimes run polling, but those are less natural matches and usually add operational complexity.
Do not run both methods for one bot. Telegram’s FAQ states that updates cannot be fetched with getUpdates while a webhook is configured. If you move from a webhook to polling, remove the webhook first; otherwise the polling request fails.
#1 Best Overall
- Includes Raspberry Pi 5 with 2.4Ghz 64-bit quad-core CPU (8GB RAM)
- Includes 128GB Micro SD Card pre-loaded with 64-bit Raspberry Pi OS, USB MicroSD Card Reader
- CanaKit Turbine Black Case for the Raspberry Pi 5
- CanaKit Low Noise Bearing System Fan
- Mega Heat Sink - Black Anodized
Serverless or VPS: the practical decision
| Question | Serverless webhook | VPS webhook | VPS long polling |
|---|---|---|---|
| Does the bot need a public HTTPS endpoint? | Yes. Telegram must reach the function URL. | Yes. Telegram must reach the server URL. | No public inbound endpoint is needed; this is an inference from the polling mechanism, not a Telegram requirement. |
| How does work start? | A function invocation is triggered by an incoming webhook request. | An always-available web process receives the request. | An always-running process waits on getUpdates. |
| Best fit | Bursty traffic, stateless handlers, minimal server administration. | Teams that want webhook delivery but control over the operating system and runtime. | Simple deployments that prefer an outbound connection and no public URL. |
| Persistent in-memory state | Not a safe assumption; design state outside the invocation. | Available while the process and host remain healthy. | Available while the polling process remains healthy. |
| Idle behavior | The function can stop between requests. | The host and service remain running. | The process remains running while waiting for updates. |
| Pricing conclusion | No general cost or speed advantage is established here; it depends on the platform and traffic. | No general cost advantage is established here. | No general cost advantage is established here. |
The decisive questions are therefore operational: can you expose a reliable HTTPS endpoint, does the bot need a resident process, and who will maintain the operating system and service? Telegram does not prescribe “serverless” or “VPS” as a universal answer.
How webhook delivery works
When an update is generated, Telegram sends it to the URL registered for the bot. Your application receives the HTTP request, authenticates it, handles the update, and returns an HTTP response. The endpoint must be publicly reachable over HTTPS on one of Telegram’s allowed ports:
- 443 is the default.
- 80, 88, or 8443 are also allowed when that port is written explicitly in the webhook URL.
The URL must be reachable from the public internet. A private address, localhost address, or a firewall that blocks Telegram will prevent delivery. Telegram’s webhook traffic originates from the subnets 149.154.160.0/20 and 91.108.4.0/22; you can allow-list those ranges if your firewall policy requires source filtering.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Fix the driver behind crashes, sound loss and screen glitches3Repair Windows errors before they cause bigger problemsProtecting the endpoint with a secret token
Set the optional secret_token when registering the webhook. Telegram then includes the value in the X-Telegram-Bot-Api-Secret-Token header on webhook requests. Your handler should compare the received header with the secret stored in your service configuration and reject requests that do not match. This is an application-level authenticity check; it does not replace HTTPS or ordinary input validation.
Rank #2
- Includes Raspberry Pi 5 with 2.4Ghz 64-bit quad-core CPU (4GB RAM)
- Includes 128GB Micro SD Card pre-loaded with 64-bit Raspberry Pi OS, USB MicroSD Card Reader
- CanaKit Turbine Black Case for the Raspberry Pi 5
- CanaKit Low Noise Bearing System Fan
- CanaKit Mega Heat Sink - Black Anodized
Checking webhook health
Use getWebhookInfo when diagnosing delivery. The response includes the last delivery error and the number of updates waiting to be delivered. A growing waiting count, a recent error, or an unexpected URL points to a reachability, certificate, port, or application problem.
Deploying a Telegram webhook on serverless
Serverless is a good fit when each update can be handled as an independent request and the bot does not depend on a process staying alive between messages. Treat the function as stateless: keep durable conversation data, queues, and files in services designed for persistence rather than in local memory or temporary disk.
- Create an HTTPS function endpoint. Use a public URL on port 443, or explicitly use port 80, 88, or 8443. Confirm that the endpoint accepts Telegram’s POST request before registering it.
- Implement the request handler. Parse the update payload, verify the
X-Telegram-Bot-Api-Secret-Tokenheader when a secret is configured, perform the bot action, and return a successful HTTP response. Keep the handler focused on one update and avoid depending on a later invocation having access to current memory. - Register the webhook. Call the Bot API’s
setWebhookmethod with the function URL and, preferably, a high-entropysecret_token. A generic request shape is:curl -F "url=https://bot.example.com/telegram" -F "secret_token=replace-with-your-secret" https://api.telegram.org/bot<TOKEN>/setWebhook - Verify registration. Call
getWebhookInfoand confirm that the registered URL is the one you deployed, that no recent delivery error is reported, and that the waiting-update count behaves as expected when you send a test message. - Set network rules. If the function is behind an allow-list, permit Telegram’s documented source subnets. Do not expose administrative endpoints on the same public route.
- Observe real requests. Review function logs for rejected secrets, malformed payloads, application exceptions, and responses that take longer than your platform permits. Telegram’s delivery status is visible through
getWebhookInfo; platform logs explain what happened inside your handler.
When serverless is a poor fit
- The bot requires a resident worker, a local queue, or a continuously open connection to another service.
- Processing cannot be completed within the function’s execution model.
- Your design assumes that in-memory variables survive from one update to the next.
- You need operating-system packages, custom networking, or background daemons that the function platform does not provide.
None of these conditions makes serverless impossible, but each requires an additional service or a redesign. If those additions would recreate an always-on server, a VPS may be the simpler architecture.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Running a bot on a VPS with long polling
Long polling avoids inbound networking. Your bot process makes an outbound request to getUpdates and waits until updates arrive or the request’s timeout expires, then calls the method again. Because Telegram does not need to initiate a connection to your machine, you do not need a public domain, an inbound firewall rule, or a webhook port for this mode. That “no public URL” benefit follows from the connection direction; it is not a separate Telegram hosting requirement.
Rank #3
- CanaKit Raspberry Pi 5 Essentials Starter Kit
For a self-managed Linux host, Antihost VPS provides full root access on AMD Ryzen 9 9950X3D hardware in the USA East, Netherlands, and Ukraine; install the bot runtime and supervise its process yourself.
- Provision the host and runtime. Install your bot’s language runtime and dependencies, restrict administrative access, and store the bot token outside source code.
- Remove any existing webhook. Call
deleteWebhookbefore starting polling. If a webhook remains configured,getUpdateswill not work. - Start one polling worker. The worker calls
getUpdates, waits for the response, processes returned updates, and repeats. Run only one active polling consumer for the bot unless your application deliberately coordinates workers. - Keep the service supervised. Use the VPS’s service manager or another process supervisor so the worker restarts after a crash or host reboot. Send logs to a location with rotation and alerting.
- Monitor the loop. Alert when the process exits, authentication fails, requests repeatedly error, or updates stop being processed. A healthy host does not guarantee a healthy polling process.
Polling is often the shortest path for a first deployment because it avoids certificate issuance, DNS, inbound firewall configuration, and webhook registration. The trade-off is that you must keep and supervise a process continuously.
Using a VPS with a webhook instead
A VPS is not limited to polling. You can run a web server and bot application on the VPS, expose an HTTPS endpoint on an allowed port, register it with setWebhook, and use getWebhookInfo for delivery diagnostics. This arrangement combines Telegram’s push model with full host control.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Choose this variant when you already operate HTTPS services, need custom system packages, or want a single host for the bot and other workers. You still carry certificate renewal, patching, firewall rules, process supervision, and uptime responsibility. If the endpoint is unavailable, Telegram cannot deliver updates until it becomes reachable again.
Rank #4
- Includes Raspberry Pi 5 16GB with 2.4Ghz 64-bit quad-core CPU (16GB RAM)
- Includes 128GB Micro SD Card pre-loaded with 64-bit Raspberry Pi OS, USB MicroSD Card Reader
- CanaKit Turbine Black Case for the Raspberry Pi 5
- CanaKit Low Noise Bearing System Fan
- Mega Heat Sink - Black Anodized
Switching safely between polling and webhooks
Polling to webhook
- Stop the polling worker so it is no longer calling
getUpdates. - Deploy and test the public HTTPS handler.
- Call
setWebhookwith the URL and optionalsecret_token. - Call
getWebhookInfoand inspect the URL, last error, and waiting count. - Send a controlled test message and confirm that the handler receives it once and records the result.
Webhook to polling
- Stop or disable the webhook-serving application if it would otherwise continue handling requests.
- Call
deleteWebhook. - Start exactly one polling worker and verify that
getUpdatesreturns normally. - Watch logs for authentication errors and confirm that new test messages are consumed.
The order matters: deleting the webhook is the step that makes polling available. Starting a polling process first only produces an error while the webhook is still set.
Security and reliability checklist
- Keep the bot token secret. Store it in environment configuration or a secret manager, not in a public repository or client-side code.
- Use HTTPS for webhooks. Validate the certificate and hostname normally; do not disable certificate verification in an intermediary proxy.
- Check the secret header. Compare
X-Telegram-Bot-Api-Secret-Tokenbefore processing a webhook request. - Limit exposure. Allow only the required webhook route publicly and keep dashboards, databases, and administration private.
- Apply least privilege. The bot process should have only the filesystem and service permissions it needs.
- Make state durable. Persist user settings, conversation state, and job records in a database or other durable store rather than relying on function memory.
- Instrument both sides. Application logs show handler failures;
getWebhookInfoshows Telegram’s latest delivery error and queued updates. - Plan recovery. Keep the exact webhook URL, secret configuration, and deployment procedure documented so you can restore delivery after a failed release.
Common failure modes and fixes
| Symptom | Likely cause | Fix |
|---|---|---|
getUpdates returns an error while polling |
A webhook is still configured. | Call deleteWebhook, then restart the polling worker. |
| Webhook is registered but no messages arrive | The URL is not publicly reachable, the port is not allowed, or a firewall blocks Telegram. | Confirm HTTPS reachability, use port 443 or an explicitly allowed alternative, review firewall rules, and inspect getWebhookInfo. |
| Requests are rejected by the application | The secret header is missing or does not match. | Verify the configured secret_token, read the X-Telegram-Bot-Api-Secret-Token header exactly, and update deployment secrets consistently. |
| Waiting updates increase | Telegram cannot complete delivery or the handler is failing. | Read the last delivery error from getWebhookInfo, check platform logs, and test the endpoint from outside your network. |
| Polling stops after a reboot | The worker was started manually and is not supervised. | Register it with the host’s service manager or another restart-capable supervisor. |
| State disappears between serverless requests | The design relies on process memory or temporary files. | Move state to durable storage and treat each invocation as independent. |
Which setup fits common bot profiles?
Small notification or command bot
If traffic is intermittent and each command finishes quickly, a serverless webhook minimizes the amount of infrastructure that must remain active. Use durable storage only if the bot remembers users or settings.
Prototype on a private network
A VPS with long polling is usually easier when you cannot expose an HTTPS endpoint or configure public DNS. The process makes outbound requests, so the network only needs to permit those connections.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Bot with background workers
If updates enqueue jobs, consume files, or maintain a resident connection, an always-on VPS can keep the worker model straightforward. A serverless webhook can still accept updates, but it will need a queue and separate worker service.
Best Value
- Includes Raspberry Pi 5 with 2.4Ghz 64-bit quad-core CPU (8GB RAM)
- Includes 32GB EVO+ Micro SD Card pre-loaded with 64-bit Pi OS, USB MicroSD Card Reader
- CanaKit Turbine Black Case for the Raspberry Pi 5
- CanaKit 45W PD Power Supply for the Raspberry Pi 5
- Display Cable - 6 foot (Supports up to 4K 60p)
Existing web application on a VPS
Add the bot as another HTTPS route and use webhook delivery if your reverse proxy, certificate management, and process supervision are already established. This avoids introducing a separate polling loop.
Production bot with strict isolation
Either hosting model can be hardened. Serverless reduces host maintenance, while a VPS offers direct control over network boundaries and operating-system policy. Base the choice on your team’s ability to operate those controls, not on an assumed universal uptime or cost benefit.
A concise selection checklist
- Choose webhook if you can provide a public HTTPS endpoint and want Telegram to push updates.
- Choose long polling if you want no inbound endpoint and can keep a process running.
- Choose serverless when the webhook handler is stateless, short-lived, and traffic is naturally bursty.
- Choose a VPS when you need a resident process, custom system access, or one host for webhooks and workers.
- When changing methods, stop the old consumer and delete the webhook before enabling polling.
- For webhooks, configure the secret header, allowed port, firewall policy, and
getWebhookInfomonitoring before going live.
Telegram Bot API documentation remains the authority for method parameters and any limits that may change over time: core.telegram.org/bots/api. Telegram also maintains an overview of serverless bot deployment at core.telegram.org/bots/serverless; check current platform-specific details there rather than assuming a particular provider’s limits or pricing.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




