Jul 13, 2026
How to Create a Telegram Bot with BotFather (Step-by-Step)
Create your own Telegram bot in under five minutes with BotFather, get your bot token, and connect it to an AI assistant.

Blog · Jun 18, 2026
When you create a Telegram bot, BotFather hands you a token that looks like 123456789:AAH.... Treat it casually and you'll regret it. This is a short, practical guide to keeping it safe, no security jargon required.

If you haven't created a bot yet, start with our BotFather guide.
The token is not just an identifier. Anyone who has it can send and receive messages as your bot, read whatever it can see, and control it completely. There's no separate password. The token is the credential. So the whole game is: don't let it leak, and react fast if it does.
The most common leak is an API token pushed to a public repository. Once it's in git history, deleting the line later doesn't remove it from past commits.
Instead, keep the token in an environment variable and load it at runtime:
TELEGRAM_BOT_TOKEN=123456789:AAH...
Add your .env file to .gitignore before your first commit, not after.
If a token is ever exposed, message BotFather and send /revoke. It generates a new token and invalidates the old one instantly. This is the single most effective thing you can do, so do it first and clean up second.
Plenty of sites offer to "test your bot" or "check your webhook" if you paste your token. Some are fine. Some quietly log everything. If you don't trust and recognize the tool, don't hand it your token. Test locally instead.
Every person and every machine that holds the token is another way it can leak. Keep the list short. Share it through a password manager, not a chat message or email, and remove access when someone no longer needs it.
Telegram lets a bot receive updates through a webhook URL. If an attacker sets their own webhook with your token, your messages flow to them instead of you. Check what's currently configured:
https://api.telegram.org/bot<YOUR_TOKEN>/getWebhookInfo
If the URL isn't one you set, that's a red flag. Revoke the token and reconfigure.
Don't keep tokens in plain text files, sticky notes, or chat history. Use a secrets manager or your platform's built-in secret storage. It keeps tokens encrypted, controls access, and gives you one place to rotate them.
If you think your token is exposed, work in this order:
| Step | Action |
|---|---|
| 1 | Run /revoke in BotFather to kill the old token |
| 2 | Update the token everywhere your bot runs |
| 3 | Check getWebhookInfo for a webhook you didn't set |
| 4 | Review recent bot activity for anything unexpected |
| 5 | Find how it leaked (git, a tool, a shared file) and fix that |
Speed matters more than perfection. Revoke first; investigate after.
Token security is really about one habit: treat the token like a house key, not a business card. If you'd rather not manage secrets, webhooks, and rotation yourself, a managed platform handles the storage and connection for you, which removes most of the ways a token leaks in the first place. Either way, the rules above are the baseline. If you want the wider context on running your own setup, see our comparison of a self-hosted assistant versus ChatGPT.
Jul 13, 2026
Create your own Telegram bot in under five minutes with BotFather, get your bot token, and connect it to an AI assistant.

Jun 4, 2026
Seven practical things a Telegram AI assistant can do for you every day, with example prompts you can copy and use right away.
