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:

 

Segments of Part II:

  1. Creating a bot from BotFather.
  2. 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.

Creating a New Bot using BotFather
Creating a New Bot using BotFather

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!

Getting Bot Token
Getting Bot Token

 

 

 

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:

Telegram API
Telegram API Development Tools

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.

Leave a Reply