Create telegram bot and make it send you some news

Yeah I use “some news” so that the bot come with a purpose. I fact we can make some more purposes on top of news, for example the bot can update us price changes of some items on our wishlist, changes of stock price, weather forecast, crypto analysis, etc or anything matters to us.

So the method used to create can be found here on my previous post (How to create telegram channel and have a bot to update it). So once we got the bot created, now we want to be able to let the bot send us messages. Remember to have the bot token ready, yeah the one provided by BotFather with the congratulation message.

First step is to send our bot a message first. Bot cannot initiate a message, else it will spam everyone on this earth. Just send a simple “hello”.

Next is to check for the bot message updates. Do it by accessing getUpdates endpoint here, of course without the square bracket.[your bot token]/getUpdates

Once it loads, take a look at this item:

“chat”:{“id”:123456789,”first_name”:”Your First Name”,”last_name”:”Your Last Name”,”username”:”Your Username”,”type”:”private”},”date”:date,”text”:”hello”}

We need the chat id above so that our bot will be able to send us messages for whatever purposes.

Send messages by accessing the sendMessage end point as below.[your bot token]/sendMessage?chat_id=123456789&text=salam%20my%20test%20message

Remember to replace space with %20. That’s it, now our bot is ready to rock and roll.

Prev PostHow to sync Outlook 365 calendar into your Google calendar
Next PostWhatsapp send text to non-saved numbers

Leave a reply