Obtaining an API keyΒΆ

Before diving in the source code of the bot, you need to create the bot in Telegram and get its API key. In order to do so, open your favourite Telegram client and start a chat with @botfather. That’s a bot which will help you to register a new bot. When you’ve opened the chat, type the following command:


And follow the instructions it gives to you. When you’ve given it everything it needs to know, it will give you an API key, like this fake one:


Write it down somewhere, but be sure to keep it secret! Everyone with your API key can take full control of your bot, and that’s not a fun thing.

If you want to learn more about creating and customizing bots, check the bot creation chapter of this documentation.