Part 1: Create A Telegrambot and Obtain Token Step 1: Create A New Chat by Click in Icon in Right Top Corner
Part 1: Create A Telegrambot and Obtain Token Step 1: Create A New Chat by Click in Icon in Right Top Corner
Part 1: Create A Telegrambot and Obtain Token Step 1: Create A New Chat by Click in Icon in Right Top Corner
This is simple guides to create your own Telegrambot and make it capable to send
message/photo/video/document to you (or other that chat with your bot or group) without
programming code and without your own personal Telegrambot Server. Please take note that
knowledge in this document can only ask your bot to “send” but cannot “reply” as without your
own personal Telegrambot server (can be a normal Windows Computer) that require programming
codes.
There are 3 parts of this documents namely (1) create Telegrambot and obtain Token (2) Obtain
chat_id (chat_id of user, i.e., you) and (3) Send message/photo/video/document. Each parts bream
down to some steps.
Note that screenshots in this documents were captured using Telegram App in IOS. But same
steps/processes can be done in Android/Windows.
Step 3: Start chatting with @BotFather, type /newbot command. Then @BotFather will ask you
for name of bot and username of bot. For simplicity at beginner level, put both name and
username to be the same. In my example, the name of bot is ksyapdemobot. You may choose
username of your bot as long as it is unique and with “bot” behind. Also, you may create as many
bot as you like, not just one.
Step 4: Obtain API Token (or usually refer as Token) of the bot from the message of @BotFather
to you right after bot is created. You need to keep the Token as security code. API is Application
Programming Interface.
Step 5: If needed, you can revoke current token, generate new token or other advance setting of
bot using /mybots command then select respective bot. For revoke token and generate new token,
select API Token.
Part 2: Obtain chat_id of user (or group that bot joined) currently chatting with bot
Step 1: Start a new chat similar to Step 1 of Part 1, but this time type @usernameyourbot (username
of your bot start with @ and in full, for my case is @ksyapdemobot) in search box. Then select it
for chatting.
Step 2: Then click on Start menu, then best add some text (such as Hello) and send to your bot.
Step 3: Refer to full details API of Telegrambot at https://core.telegram.org/bots/api , you may get
the chat_id (ID of a user or group that currently sent message to bot using follow https protocol
i.e.,
https://api.telegram.org/bot<token>/getupdates
However, you need to replace the whole <token> to the API Token you obtained from Part 1 Step
4.
Step 4: Copy the whole http protocol command in Step 3, and paste on URL address of Mozilla
Firefox web browser and press enter. You can use Edge, Chrome, or other browsers, but by default
other bowers can’t display JSON hence is confusing so best is use Firefox.
The results should display the JSON (JavaScript Object Notation) of your bot.
From here, you can see chat_id (ID of a telegram user chatting with your bot now, in this case,
your own chat_id of Telegram) display here. The chat_id is unique long number (positive for a
user, negative for a group) for a user/group that remain the same no matter who or which bot he/she
chatting with. For example, my Telegram ID/chat_id is 8xxxxxxx10. Not highly confidential like
Token but still best is to keep it to yourself.
Step 5: In the case you pasted the https protocol command to Firefox browers, it show only little
information with chat_id as my previous screenshot. You need to go back to Telegram App
chatting with your bot, type and send more text. Then back to Firefox to redo the https protocol
command. You should be chat_id after several trials.
https://api.telegram.org/bot<token>/sendMessage?chat_id=<chat_id>&text=<text>
You need to replace the whole <token> with Token of your bot obtained in Part 1, replace whole
<chat_id> with chat_id obtained in Part 2, and replace <text> with message you want to send, such
as hello%20world. Here the %20 represent empty space in between hello and world.
For example
Then, copy this https protocol command, and paste to URL address of any web browser and hint
enter key.
Step 3: Go back to Telegram App, look at chatting of your bot with you. You can see your bot just
send you a hello world.
Step 4: You can edit <text> of https protocol command and try again to send more other messages.
Step 5: For send photo/jpg, video/mp4 and document (such as pdf), you can look at API page of
Telegram bot https://core.telegram.org/bots/api and look for sendPhoto, sendVideo and
sendDocument. Similar format to sendMessage https protocol I shared here. You can enjoy learn
how to send photo/video/pdf! Or we can further discuss in next round.
If you want to do /photo topic thing that I created for my bot, you need to setup a server in your
windows computer and some programming. Trust me, not difficult at all just have to learn. I will
try my best to cover in my AI class this semester and my youtube channel. Note that the same
server can do other task too such as home automation, face recognition etc, not just as server of
your Telegrambot.