DocumentationTelegram Bot
Before creating your bot, if you’re not familiar with BotFather yet, We recommend to read the previous chapter in the documentation to know more about it, then return here.
The first step in creating a Telegram bot is to interact with BotFather, which is the official Telegram bot for managing and creating other bots. Open the Telegram app and search for BotFather.
Once you’ve found BotFather, click on it and start a conversation. You can do this by clicking on the Start button in the chat window.
To create a new bot, send the command /newbot. BotFather will prompt you to enter a name for your bot. This name will be displayed when users search for your bot on Telegram.
After you’ve chosen the name, you will be asked to select a username for your bot. The username must be unique and end with the suffix bot. For example, if your bot’s name is “Crown,” you might choose a username like CrownGameBot. This username will be used to create a unique URL that people can use to access your bot. Choose a username that is easy to remember and related to your bot’s purpose.
After you’ve selected the username, BotFather will generate a Token for your bot. This token is crucial for connecting your bot to the Telegram API. Copy this token as you will need it to integrate the bot with your application.
Make sure to keep this token in a secure place. It allows access to control the bot, and sharing it with unauthorized individuals can lead to misuse of your bot.
BotFather allows you to configure several additional settings for your bot, such as setting a description, adding a profile picture, and adjusting other settings related to commands and privacy. You can modify these later using commands like /setdescription or /setprofilepic.
After integration, test your bot by sending a message to it on Telegram. You can send simple commands or make sure it responds as expected according to the functionality you’ve set up for it.
Once you’ve obtained the API key for your Telegram bot, the next step is to set up a Cloudflare Worker. This worker will be used to connect your bot with the necessary services, and you will enter the API key into the worker configuration to enable its functionality. We recommend reading the section of the documentation related to Cloudflare and Workers.