Telegram Bots - Creating a bot

Creating a Telegram Bot is as easy as starting a chat with BotFather

Now, that you know all about Telegram Bots, lets dig in and create a new bot.

To create a bot, you'll need to start up a chat with @botfather - the only bot that can control other bots (and yet it doesn't have a bot at the end in its name):

Start a chat with BotFather and click the Start button. Did you see that /start was sent to BotFather, the same thing will happen when someone will try to talk to your bot for the first time.

You will be greeted with generic message showing all the commands and what the bot can do. Right now, we need to focus on only one command: /newbot:

BotFather Greeting

You can tap on the /newbot from the message received, or click on the / button near the message box and then choose from there, or directly send the message /newbot.

BotFather will treat it as a command and will ask you about the name that you will want to keep for the bot. Simply type the name that you want to appear in the top bar when a user starts the chat with your bot.

After telling this name, you will be asked to give your bot a user name, and note that the user name must end with bot. For example, GIFBot, important_bot etc.

You might have to enter the name a few times, until you get the name correct so that it is not taken already. And as soon as you get an available name for your bot you will see a message like this:

New Bot - Bot Father

You will see a token for access to the HTTP API. It will be in a format bot_numeric_id:secret_hash. You should keep this key secret as it will be used to access the HTTP API of Telegram. And you should know that anyone having this key can use it to send messages from your bot to any of its user.

And in case this key gets compromised, you can /revoke it or generate the /token again.

Now, that the bot is set up, it is ready to talk. But first, you need to decide where will you put the back end of the bot.

This article was part of a series, whose introduction and index can be found here.