How to create a Telegram bot

SummaryDetailed instructions on how to create a Telegram Bot for absolute beginners. We go from nothing to obtaining the access token.

Photo of a neosign saying

Photo by Adam Solomon on Unsplash

Prerequisites

(skip this if you already have Telegram)

You need to have a Telegram account. The signup only works within one of their clients. We suggest to use one of the desktop clients. Choose the one for your operating system and download it from their downloads page. Install it (this depends on your operating system hence not covered here) and go through the Telegram registration.

You should have access to Telegram now and see a window like this:

Telegram App

Meet the BotFather

There is a special contact on Telegram that automatically handles all bot related tasks. The „program“ or „bot“ is called the BotFather 😉 You can search for „BotFather“ in the chats-section of the app or use this link, if you are on desktop: open BotFather contact.

Creating a bot is free! If you are being asked to pay, you are messaging the wrong “BotFather”. Unfortunately there are fake accounts out there.

If you click the /start button, the bot will answer with a list of helpful commands like this:

Telegram App

Creating a new bot

All commands are send as messages. Your response to the BotFathers questions are also send as messages. Just type them into the message field and hit send. If there are any problems the bot will tell you and you can try again with a new message.

The command we are interested in is /newbot. Type this as a message and send it to the BotFather. That starts the conversation to create a new bot.

Alternatively you can click on the /newbot link the bot listed for you.

1. Choose a first name for the bot

The BotFather will ask for a name. This is the firstname of your bot and will be the first thing other people will see of your bot. It is also visible in its profile. You can choose whatever you want.

2. Choose a username

This is the part that is used to reference to your bot. If you name it for example TestBot, then the handle will be @TestBot. But there are naming constraints. For example it must end in Bot or bot. It must be within 5-32 characters long, case insensitive, and may only include Latin characters, numbers, and underscores. It must not start with a number. The easiest way to find a username is probably to use the firstname and append Bot.

Some valid examples:

  • TestBot
  • Test_bot
  • A42_bot
  • CompanySupportBot

Keep in mind: this is the username used by others to find and talk to this bot. If you correctly set the two names the BotFather will respond with a success message:

Telegram App

Obtaining the access token

Whatever you want to do now, you will probably need the access token for this particular bot. It is send to you in red text and can be copied to your clipboard by clicking on it.

Remember to keep it secret from others and share it only with third-parties you trust. For example with apps that will breath life into your bot. I suggest to create a new bot for every app you want to use, just to be safe. If you are not happy with your naming decisions you can use the /mybots command to start editing your bots.

You could also create another bot if you so desire.


About the author

A blog about the evolution of Messengerturn. Announcing new features or explaining why things are done this or that way. If you like to know more, you can visit www.messengerturn.com.