Setting Up Telegram Bot¶
PoshGram requires that you create a Bot and get its Bot ID token. You will also need to add your bot to a group or channel and retrieve the chat ID of that group.
How to get a Telegram Bot API Key¶
Just message the BotFather and follow the directions.
If you want more resources here are some links and a video guide below.
- To learn how to create and set up a bot:
- Official Telegram Documentation
- TechThoughts video on how to make a Telegram Bot
How do I determine my chat ID number?¶
I've got a bot setup, and I have a token, but how do I determine my chat ID number (also referred to as the channel ID)?
Preferred Method - Web Client¶
The easiest way is to login to the Telegram Web Client and find your channel on the left. When you select it the address in your URL bar will change.
- Go to https://web.telegram.org
- Click on your channel
- Look at the url, and copy the channel ID in your browser's address bar
- It may look something like the below examples:
#/im?p=g112345678
#-828938028
- Just copy the ending numbers with no characters or symbols.
- It may look something like the below examples:
- Add a
-
to the front of your numbers to and this is your Chat ID number.- Ex
-#########
- Ex from above would be:
-112345678
- Ex
Message Method¶
Send your bot a message and then retrieve your bot's getUpdates
which contains your chat ID.
- Go to your channel
- Message your bot. Note: your bot needs to be a member of the channel for this method to work
- In this example I message the
@poshgram_bot
/my_id @yourbot_bot
- In this example I message the
-
Retrieve the
getUpdates
for your bot using its token