Step-by-Step Tutorial: Building a Telegram Bot in Python [Part II – Creating A Bot]
This is a continuation of our Telegram Bot Development series. We will be building a ChatBot using OpenAI API. In this particular tutorial, we are creating a bot and then create a developer App on Telegram. To follow along, you must read Building a Telegram Bot in Python [Part I -Setting Up]
Series Outline:
- Installing Python and Packages
- Preparing The Bot
- Coding Our Script
- Implementing Our Script Into The Bot
- Deploying The Bot
Segments of Part II:
- Creating a bot from BotFather.
- Create a Web app for the Bot
1. Creating a bot from BotFather
To create a bot, we need to create it using the help of BotFather. Go to https://t.me/BotFather and start the bot. Type /newbot
to create a new bot.
It will ask you for a name and then a username. You can give it any name you want. But while choosing a username, it must end with “bot”.
After completing this, BotFather will reply with a TOKEN, which you can store in a safe place. DO NOT SHARE YOUR TOKEN WITH ANYONE ELSE!
2. Create a Web Application For The Bot
We need to create an Application. Go to https://my.telegram.org/ and enter your phone number (with the same number associated with your telegram account). Telegram will send a code to your telegram account, verify and sign in using it. You’ll see something similar to this:
Click on API development tools and you will be asked to provide a name, shortname, URL, and Description. You can use anything you want here. In the platform, you need to choose web. Click on Create Application. You’ll get your APP API ID and APP API Hash. These credentials are important to create session files for our Pyrogram bot. Keep all the credentials (Bot token, API ID, API Hash) somewhere safe where only you can access them.
This is about it. See you in the next tutorial.