How to Create a Telegram Bot with BotFather

Step-by-step guide to creating a Telegram bot, getting an API token, and storing it securely.

Telegram’s official bot manager BotFather lets you create a bot in just a few minutes. No programming knowledge needed — just a Telegram account.


1. Find BotFather

Open Telegram (desktop, web, or mobile) and search for @BotFather.

Select the account with the blue verified checkmark. Other “BotFather” accounts may be scams — always verify the blue tick.


2. Start the conversation

In the BotFather chat, tap the Start button or type /start and send it.

BotFather will return a list of available commands.


3. Create a new bot

Type and send:

/newbot

BotFather will ask for two things:

Display name

This is the name shown in chat lists and on the bot’s profile. It can be anything:

My Awesome Bot

Username

This is the unique identifier used for @mentions and the t.me/ link. Rules:

  • Only letters, numbers, and underscores (_)
  • Must end with bot — e.g. myawesomebot or my_awesome_bot
  • Case-insensitive, but you may use uppercase
  • Must not already be taken
my_awesome_bot

If the username is available, BotFather will confirm. Otherwise, try a different name.


4. Get your API token

After the bot is created, BotFather will send a message like this:

Done! Congratulations on your new bot. You will find it at t.me/my_awesome_bot.

Use this token to access the HTTP API:
7123456789:AAFxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Keep your token secure and store it safely, it can be used by anyone to
control your bot.

The long string in that message is your API token. Its format is:

<bot_id>:<random_string>

Example: 7123456789:AAFxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Copy it and save it somewhere — you’ll need it next.


5. Store your token securely

Your API token gives full control over your bot. If it leaks, anyone can use your bot.

Don’t:

  • Commit the token to GitHub or any public repository
  • Paste it in Discord, Slack, or other chat apps
  • Hardcode it directly in your source code

Do:

Use an environment variable — read the token at runtime:

export TELEGRAM_BOT_TOKEN="7123456789:AAFxxx..."

Python example:

import os
token = os.environ["TELEGRAM_BOT_TOKEN"]

Use a .env file — and add it to .gitignore:

# .env
TELEGRAM_BOT_TOKEN=7123456789:AAFxxx...
# .gitignore
.env

Use a secrets manager — for production environments, consider AWS Secrets Manager, HashiCorp Vault, or similar.


6. Get your Chat ID

After creating your bot, you need your personal Chat ID so the bot knows where to send alerts.

  1. Open Telegram and start a conversation with your bot — search for its username and click Start.
  2. Open this URL in your browser (replace <TOKEN> with your actual token):
https://api.telegram.org/bot<TOKEN>/getUpdates
  1. You’ll see a JSON response. Find the "id" field inside "chat":
{"chat": {"id": 123456789, "first_name": "...", "type": "private"}}
  1. That number (123456789) is your Chat ID. Copy it.

7. Enter credentials in SentinelBox

  1. Open SentinelBox → click the Settings button (gear icon in the title bar).
  2. Navigate to the Telegram tab.
  3. Paste your Bot Token into the Bot Token field.
  4. Paste your Chat ID into the Chat ID field.
  5. Click 📨 Test Message — if everything is correct, you’ll receive a test notification in Telegram within seconds.
  6. Click Save.

Summary

StepWhat was done
1Found BotFather on Telegram (@BotFather)
2Started the conversation with /start
3Created a bot with /newbot, set display name and username
4Copied the API token
5Stored the token in an environment variable or secrets manager
6Retrieved Chat ID via getUpdates
7Entered token and Chat ID in SentinelBox, sent a test message

Your bot is ready. For next steps, refer to Telegram’s official Bot API documentation.