Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Fix the driver behind crashes, sound loss and screen glitches3Clear out junk files and repair common Windows errorsThe simplest reliable deployment is a Python bot running Application.run_polling() inside a virtual environment, supervised by systemd on an always-on Linux VPS. Create the bot with Telegram’s @BotFather, keep the token in an environment file outside Git, test polling, and then let systemd restart the process after failures or reboots. Choose a webhook instead only when you already have a public HTTPS endpoint and are prepared to operate inbound routing and secret-header validation.
Need a server to try this on? Antihost offers Linux VPS plans with NVMe storage, full root access and a 14-day free trial.
What you need before deployment
This guide assumes a Debian- or Ubuntu-like VPS, although the same files and commands work with equivalent packages on other Linux distributions. The server must be reachable over SSH and remain powered on. You need:
As an Amazon Associate I earn from qualifying purchases.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →- A Telegram account with permission to create a bot through
@BotFather. - A publicly reachable Linux VPS and a deployment account that is not root.
- SSH public-key authentication, rather than relying on a password for routine administration.
- Python 3, its virtual-environment module, and a current
python-telegram-botrelease. - A plan for storing the BotFather token outside your source repository.
Telegram bots communicate with Telegram’s Bot API as JSON over HTTPS. Your Python process either repeatedly asks Telegram for updates (long polling) or waits for Telegram to deliver updates to your HTTPS endpoint (webhook).
Create the bot and protect its token
Register the bot in Telegram
- Open Telegram and start a chat with
@BotFather. - Send
/newbot, choose a display name, and choose a username that ends inbot. - Copy the generated token into a password manager or another private secret store. Treat it like a password: anyone who has it can operate the bot through the API.
Do not paste the token into Python source, shell history, screenshots, issue reports, or a public Git repository. If it is exposed, return to @BotFather, revoke it, issue a replacement, and update the service environment before restarting the bot.
#1 Best Overall
- BLUE LIGHT BLOCKING GLASSES: Our blue light glasses for women boast UV400 protection, blocking harmful blue rays from computer screens. With these bluelight glasses women, you can enjoy gaming, reading, or watching TV with no worries of eye strain.
- EYE RELIEF: Our blue light glasses are engineered to reduce blurry vision or strain caused by prolonged screen time. These womens blue light glasses aid in better sleep by preventing blue light from disrupting your natural sleep cycle, helping you fall asleep faster and enjoy a more restful night's sleep, making them the perfect christmas present.
- COMFORTABLE: Crafted from durable material, our trendy blue light glasses for woman or blue light glasses men ensure long-lasting comfort. The high-transmittance lenses accessories, gamer gifts for men, help keep your eyes relaxed. Perfect stocking stuffers, gifts for gamers men, christmas gifts for men, halloween costumes.
- LIGHTWEIGHT: These clear blue light glasses feature a lightweight frame, meaning they’ll stay comfy for long-term wear. Perfect as blue blockers glasses for women or mens blue light glasses, these non-prescription fake glasses for men can be worn throughout the day. The blue light blocking glasses women feature polycarbonate HD lenses, which are anti-reflective and restore true color.
- WORRY-FREE PURCHASE: If you experience any issues, our support team is ready to assist you quickly. These are the perfect costume glasses for cosplay dressing up.
Provision the Linux VPS
Use a non-root account and SSH keys
Log in initially with the VPS provider’s administrative method, create a dedicated account, and grant only the administrative access needed to install packages and manage the service. On a Debian- or Ubuntu-like system, the broad sequence is:
sudo apt update
sudo apt upgrade
sudo adduser --system --group --home /opt/telegram-bot botuser
sudo mkdir -p /opt/telegram-bot
sudo chown -R botuser:botuser /opt/telegram-bot
The exact account-creation prompts differ by distribution. Configure your SSH daemon for public-key authentication, verify that a second terminal can log in with the key, and only then consider disabling password authentication. Keep an administrative account available for recovery; the bot service itself should run as botuser, not root.
Install Python tooling
Install Python 3, python3-venv, and python3-pip using your distribution’s package manager. Confirm the interpreter that will be used by the service:
python3 --version
python3 -m venv --help
Pin dependencies after installation. Because the appropriate library release can change, first install the current release available to you, then record the exact resolved version in a requirements file and review future upgrades deliberately.
Rank #2
- WINDEX GAMING WIPES: effortlessly clean all your gaming gear and gaming electronics in one easy step with our new Windex Gaming Wipes
- AMMONIA FREE: our ammonia-free formula is safe to use on all of your favorite gaming equipment like consoles, headsets, controllers, screens, keyboards, and more
- PRE-MOISTENED WIPES: each wipe instantly removes dust, dirt, and stubborn smudges and fingerprints leaving a streak-free shine
- ANTI-STATIC: great for cleaning and wiping down your gaming gear and electronics leaving behind no visible residue
- COMPACT RESEALABLE PACKAGE: store your pack of Windex Gaming Wipes anywhere in your home for whenever a quick and easy wipedown is needed
Create an isolated project
Build the virtual environment
Work in the application directory as the deployment user:
sudo -u botuser -H bash
cd /opt/telegram-bot
python3 -m venv .venv
. .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install python-telegram-bot
python -m pip freeze > requirements.txt
The virtual environment keeps the bot’s packages separate from operating-system Python and gives systemd an unambiguous interpreter at /opt/telegram-bot/.venv/bin/python. When upgrading, activate the environment, install the reviewed versions, regenerate requirements.txt, and test before restarting the service.
Free tools Windows power users keep installed
One-click scans. No signup required.
Store the secret outside Git
Create a root-owned environment file so the token is not part of the project checkout:
sudo install -d -m 0750 /etc/telegram-bot
sudo sh -c 'printf "%s\n" "TELEGRAM_BOT_TOKEN=replace-with-the-token-from-botfather" > /etc/telegram-bot/bot.env'
sudo chmod 0640 /etc/telegram-bot/bot.env
sudo chown root:botuser /etc/telegram-bot/bot.env
Replace the value on the server without committing the file. Add both /etc/telegram-bot/bot.env and any local .env file to .gitignore. The service account needs to read the file; ordinary users should not.
Rank #3
- Ergonomic & Adjustable Design: Fight "text neck" and improve your posture. Designed for comfort, it offers an adjustable height (7.1in-8.5in) (1.4in adjustable range) and angle (5°-85°) Please note: cell phone stand is only 9 inches tall—the length of a standard pencil
- Without blocking subtitles Perfect for office desk Tiktok Face Time Zoom video—this is the ultimate kitchen desk essential for phones! Perfect viewing experience while reducing neck back strain, A must-have for gamers streamers desk, and anyone who values both style and support!
- Sleek & Stable Design fits Otterbox Case: Say goodbye to bent cables, tangles, and tip-overs! LISEN’s stylish adjustable desk phone holder features a built-in charging hole and smart cable management, keeping your phone secure and your workspace clutter-free cool gadgets for men
- ANTI-SLIP DESIGN free hands: The under 10.00 items easy gadgets back and the bottom of this kitchen essentials for women are fully covered by anti-skid silicone, which LISEN stand up desk decor can provide maximum protection device from any scratches and slides
- Your Perfect Viewing Companion:If your product arrives damaged or breaks within 365 days, reach out to LISEN for a quick and hassle-free solution. Struggling with assembly, like tightening the screw? We’ve got your back! Your experience matters to us. (Product including: phone Holder stand*1, screw*1, hexagon screwdriver*1, specification*1)
Write and test a minimal polling bot
Create the handlers
Save this as /opt/telegram-bot/bot.py. It reads the token from the process environment, responds to /start, and echoes text so you can verify the full update path:
import os
from telegram import Update
from telegram.ext import Application, CommandHandler, ContextTypes, MessageHandler, filters
TOKEN = os.environ["TELEGRAM_BOT_TOKEN"]
async def start(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
await update.message.reply_text("Bot is running.")
async def echo(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
await update.message.reply_text(update.message.text)
def main() -> None:
application = Application.builder().token(TOKEN).build()
application.add_handler(CommandHandler("start", start))
application.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, echo))
application.run_polling()
if __name__ == "__main__":
main()
Set the token only in the shell for an initial test, or load the same environment file that the service will use:
cd /opt/telegram-bot
set -a
. /etc/telegram-bot/bot.env
set +a
. .venv/bin/activate
python bot.py
Send /start and a normal text message to the bot. Stop the foreground process with Ctrl+C after confirming both replies. If the token is missing, the process should fail immediately rather than start with an invalid credential; check the variable name and file permissions before trying again.
Keep the bot running with systemd
Create a service unit
Running the script in an SSH session is not a deployment: it ends when the session closes and does not automatically recover from a crash or reboot. Create /etc/systemd/system/telegram-bot.service:
Rank #4
- Easy Installation: Our gaming lights have been designed to enhance your entertainment experience. Simply position the led light bar next to your TV or game console to create a game room environment with ease. They come with USB power and a 60 inch cord for direct mounting and mobility
- Audio Syncing & Extensive Mode: The built-in high-sensitivity music sensor allows you to sync the TV led lights to your favorite music. Lights react and move to the beat of music, film and game audio, creating an incredible immersive sound and light experience – and all without the need for an additional hub. You can choose from 64+ patterns, including strobe, illusion, jump, energy, gradient, running, chasing, fluttering mode etc. Each mode can be applied to different scenes
- 64+ Chasing IC+RGB & W Effect: The independent control design of IC+RGB and white all-in-one multifunctional rgbw led bar lights monitor backlight allows you to easily switch the led lights for desk between IC+RGB and white to enjoy a variety of lighting effects, you can choose white lighting mode with high brightness for better illumination when working, etc. Choose IC+RGB lighting mode when you need to create an entertaining atmosphere for the light show, 16 million colours of Color changing rgb light bar let you dance to the beat and create a dynamic party atmosphere
- Dynamic and Dimmable Lights: 1%-full brightness free brightness adjustment gives you the flexibility to adjust dimmable led light bar for room decorations or a variety of occasions
- USB Powered: USB light bars for room can be powered by powernank, usb charger, TV, Monitor, laptop PC mainframe, making behind TV led lighting bar easy to install in any location.TV led lights are powered by the TV usb interface / PC mainframe, can be turned on/off synchronously with TV / PC
[Unit]
Description=Python Telegram bot
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=botuser
Group=botuser
WorkingDirectory=/opt/telegram-bot
EnvironmentFile=/etc/telegram-bot/bot.env
ExecStart=/opt/telegram-bot/.venv/bin/python /opt/telegram-bot/bot.py
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
The unit uses the virtual environment’s interpreter, sets the working directory explicitly, loads the secret at start-up, and runs with the least-privileged account. Restart=on-failure handles an unexpected exit without creating a tight restart loop.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallOutdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchEnable, start, and inspect it
- Ask
systemdto reread unit files:sudo systemctl daemon-reload. - Enable the service for boot and start it now:
sudo systemctl enable --now telegram-bot.service. - Check its state:
sudo systemctl status telegram-bot.service. - Read recent application output:
sudo journalctl -u telegram-bot.service -n 100 --no-pager. - Follow new log entries while sending a test message:
sudo journalctl -u telegram-bot.service -f.
After a VPS reboot, verify that the unit is active and that the bot answers. If it repeatedly restarts, inspect the journal before changing the restart policy; common causes are a missing environment variable, an incorrect working directory, a failed dependency install, or a Python exception during startup.
Polling or webhook: choose the network model
| Aspect | Long polling | Webhook |
|---|---|---|
| Network shape | The VPS makes outbound requests to Telegram for updates. | Telegram sends updates to a public URL on the VPS or to a reverse proxy. |
| Setup burden | Lowest; no inbound TLS endpoint is required. | Higher; you must operate a public endpoint, HTTPS, routing, and optional secret-token validation. |
| Good fit | Small to medium bots, prototypes, and straightforward VPS services. | Deployments that already operate HTTPS infrastructure or specifically need push delivery. |
| Constraint | An outgoing webhook must not remain configured for the same bot. | Do not run long polling for the same bot at the same time. |
Long polling is usually the right first deployment because Telegram handles the server side of the update connection and the VPS needs only outbound HTTPS access. A webhook becomes attractive when you already maintain a domain, certificate, reverse proxy, and inbound firewall rules.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Switching to a webhook
Meet the endpoint requirements
A webhook needs a public IP address or domain, a valid HTTPS certificate, and a route that forwards Telegram’s requests to the bot process. The Python library’s webhook extra must be installed in the same virtual environment. A reverse proxy commonly terminates TLS and forwards traffic to a local port; the bot process itself can then listen on loopback instead of exposing its application port publicly.
Best Value
- Compatible with Wide Screens - To ensure compatibility with the dual monitor mount, your each monitor must meet three conditions at the same time: First, computer screens size range: 13 to 32 inches. Second, screen weight range: 4.4 to 19.8 lbs. Third, the back of the monitor screen must have VESA mounting holes with a pitch of 75x75mm or 100x100mm.
- Regarding the compatibility with desks - Your desk must meet three conditions at the same time: First, desk material: Only wooden desks are recommended, plastic or glass desks cannot be used. Second, desk thickness range: 0.59" - 3.54". Third, the bottom of the desk should not have any cross beams or panels, as this will interfere with installation. We recommend carefully checking that your desk and monitors meets all above conditions before purchasing.
- Dual C-Clamp Hold - Worried your dual monitors might wobble or slip? Our upgraded base uses a larger platform plus a dual C-clamp structure to lock the dual monitor arm firmly to your desk. Each arm safely keeps your screens steady while you type, click and game—no shaking, no sliding, just a clean and secure setup you can trust every day. It also provides Grommet Mounting installation choice, both options ensure stable and secure fixation for your 0.59" - 3.54" desk.
- Full-Motion Adjustment For Comfortable View - Pull the screen closer when you’re deep in a spreadsheet, push it back to watch videos, or rotate to portrait for coding — moving everything smoothly with just one hand. The monitor stand offers +85°/-50° tilt, ±90° swivel and 360° rotation. Raise your monitor up to 15.75″ to support a healthy sitting posture. Whether you’re working from home, gaming through the night, or switching between video calls and documents, getting the screens to your natural line of sight helps relieve neck, shoulder and back strain so you can stay focused longer with less fatigue.
- Keep Your Desk Organized: By lifting both screens off the desktop, this dual monitor stand opens up valuable space for your keyboard, notebook, docking station or a simple, clutter-free work area. Built-in cable management guides wires along the arms, keeping cords out of sight and out of the way. Enjoy a tidy, modern workstation that looks as good as it feels to use.
. /opt/telegram-bot/.venv/bin/activate
python -m pip install "python-telegram-bot[webhooks]"
python -m pip freeze > /opt/telegram-bot/requirements.txt
Start the application in webhook mode
Use an environment variable for the secret and for the externally reachable webhook URL. The exact proxy and certificate configuration depends on your web server, but the application can be started with the library’s webhook runner:
WEBHOOK_SECRET=os.environ["TELEGRAM_WEBHOOK_SECRET"]
PUBLIC_WEBHOOK_URL=os.environ["TELEGRAM_WEBHOOK_URL"]
application.run_webhook(
listen="127.0.0.1",
port=8080,
url_path="telegram",
webhook_url=PUBLIC_WEBHOOK_URL,
secret_token=WEBHOOK_SECRET,
)
Keep the path difficult to guess and do not publish the secret in a repository or process arguments. The current updater expects Telegram’s X-Telegram-Bot-Api-Secret-Token header. Requests with a missing or incorrect value receive HTTP 403, so a reverse proxy must preserve that header when forwarding the request.
Move between transports deliberately
Only one update-delivery method can be active for a bot. Telegram’s FAQ states that long polling cannot retrieve updates while an outgoing webhook is configured. Before changing modes, use the Bot API’s webhook-management method to remove or set the webhook, and decide whether pending updates should be retained or dropped. Start the new process only after the old transport is stopped, then send a test message and inspect the service log.
Operate and maintain the deployment
Read the right logs first
- Service inactive: run
systemctl status, then read the journal for the first startup error rather than only the final restart message. - Unauthorized or invalid token: verify the environment-file path, variable name, and token status in
@BotFather; rotate the token if it was exposed. - No replies in polling mode: ensure the process is running and that no outgoing webhook remains configured for the bot.
- Webhook HTTP 403: compare the configured secret with the
X-Telegram-Bot-Api-Secret-Tokenheader and check that the proxy passes it unchanged. - Webhook connection failures: check DNS, certificate validity, firewall rules, proxy routing, and whether the local listener is bound to the address and port used by the proxy.
Update code and dependencies safely
- Back up the current project and environment file; never include the secret in the backup’s Git history.
- Pull or copy the reviewed source into
/opt/telegram-bot. - Activate the virtual environment and install only the dependency versions you have reviewed from
requirements.txt. - Run the bot interactively or execute a focused smoke test before restarting the service.
- Restart with
sudo systemctl restart telegram-bot.service, followjournalctl, and send a real Telegram message.
Confirm the installed python-telegram-bot version before using APIs that may be version-specific. Keep a rollback copy of the previous code and requirements file so a failed upgrade can be reversed without changing the secret.
Security checklist
- Use a non-root service account and SSH public-key authentication.
- Keep the BotFather token and webhook secret in an environment file or secret store outside Git.
- Restrict environment-file permissions so only root and the service account can read them.
- Use HTTPS for every webhook endpoint, a hard-to-guess path, and the Telegram secret-token header check.
- Allow only one update transport at a time and handle pending updates intentionally during migrations.
- Pin dependencies, review upgrades, and verify the installed library version before relying on version-specific methods.
- Enable a restart policy and inspect logs after deployment, after reboot, and after every dependency or configuration change.
A practical deployment sequence
For a new bot, follow this order: create and protect the BotFather credential; provision the VPS and SSH keys; create the non-root project directory; build the virtual environment; install and record the library version; write the minimal polling handler; test it in the foreground; create the systemd unit; enable it at boot; and verify logs and messages. Adopt a webhook only after the public HTTPS route, certificate, proxy, and secret-header validation are ready. This sequence gives you a working, recoverable service before adding the operational complexity of inbound delivery.
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.




