I want to implement Telegram so I can send push notifications to my phone.
I did everything, I have a bot now. However when I want to get the chat id of the bot I get (/getUpdates):
What I’m missing? Why this response is so empty?
It’s not easy
You will find the answer on telegram blogs and website
I struggled but I can’t remember how I did it
I remember getting the same json reply as you as then I googled
and googled and googled and tried many things until I found the answer
Sorry I can’t help more
It solved itself… I don’t know why.
I have sent another message to the bot (it was the 3rd or 4th message) and then every message got showed up…
Don’t know what happened but now it works…
That di not help.
I have sent many messages - but no change.
Just the short response “OK” true…
I figured it, so I will note down here for the other.
Seem like at the moment (11/2023), the way to get chat ID from API
https://api.telegram.org/bot<YourBOTToken>/getUpdates is not working. So here is my way:
- Create channel
- Add bot then make it admin
- Make channel public, give it a link
- Try to make request to this Telegram API:
https://api.telegram.org/bot[your bot id]/sendMessage?chat_id=@[your public channel url]&text=[your message]
After testing success, your can set the channel to private and still can use your channel public url link like your chatId.
UPDATED: My misstake, you can not use bot to send to your private channel. It have to be public
Update image when I create ChatId for channel by make it public
Solution for group chat: Telegram Bot - how to get a group chat id? - Stack Overflow