IntegrationsBeginner

How to create a Telegram bot with BotFather and get your token

Register a brand new Telegram bot through BotFather and copy the API token you need for every other integration.

6 minBeginner

Every Telegram automation starts with one thing: a bot token. The token is a long string that lets your code talk to Telegram on behalf of a bot account. You get it from BotFather, the official bot that creates other bots. This guide walks through the whole flow so you finish with a working token you can paste into any script or service.

What you need

  • A Telegram account on phone or desktop
  • Two minutes to chat with BotFather
  • A safe place to store the token (a password manager or .env file)

Step 1: Open BotFather

In the Telegram search bar, type @BotFather and open the account with the blue verified check mark. There are copycats, so the verified badge matters. Press Start to see the command list.

Telegram - search
Search: botfather
----------------------------------
BotFather [verified] @BotFather
BotFatherBot @bot_father_x
official_botfather @official_botf
Pick the verified BotFather, not a lookalike.

Step 2: Run /newbot

Send the command /newbot. BotFather asks for a display name (anything you like, e.g. Order Helper) and then a username. The username must be unique across all of Telegram and must end in bot, for example order_helper_bot.

Chat with @BotFather
You
/newbot
Agent
Alright, a new bot. How are we going to call it? Please choose a name for your bot.
You
Order Helper
Agent
Good. Now let's choose a username for your bot. It must end in 'bot'.
You
order_helper_bot
Agent
Done! Congratulations on your new bot. Use this token to access the HTTP API: 7843201955:AAH9k...redacted

Step 3: Copy and store the token

BotFather replies with the token. It looks like a number, a colon, then a long random string. Copy it right away. Anyone who has this token can fully control your bot, so treat it like a password.

.env
TELEGRAM_BOT_TOKEN="7843201955:AAH9k...your-real-token-here"
If the token leaks
Run /revoke in BotFather and pick the bot. It instantly invalidates the old token and gives you a new one, so any leaked copy stops working.

Step 4: Verify the token works

Telegram exposes a simple HTTP API. The getMe endpoint returns the bot's own profile, which is the quickest way to confirm the token is valid.

zsh - verify token
$curl "https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/getMe"
{"ok":true,"result":{"id":7843201955,"is_bot":true,
"first_name":"Order Helper","username":"order_helper_bot"}}
$

Result

You now have a live bot and a verified token. The "ok":true response proves the credential is good. Keep that token handy: every other guide in this series starts from it.

Watch related tutorials

Tags
#telegram#botfather#bot#token