Answer the question
In order to leave comments, you need to log in
How to send a message to a bot in telegram via url?
Everywhere they write about how to send a message through the bot. I need, knowing the token, to send a request with the text to the bot,
upd: I understand what my problem is. I don't know what to enter in the chat_id= field. When you enter a bot id, it says 'bot can't send messages to bots'. When requesting from the bot, it returns my id to me and then, when I enter the url, I send messages through the bot to myself.
Answer the question
In order to leave comments, you need to log in
https://api.telegram.org/bot " + $token + "/sendMessage?chat_id=" + $chat_id + "&text=" + $text
Instead of highlighted bold ones, insert the appropriate value.
Well, pluses and spaces are not necessary, respectively , I just pulled out a line from the script.
You need to send a request to the address https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/se... and specify the following data in the parameters: chat_id=direct chat id, text=message itself
Example
Yes, everything is written correctly in upd, you must first get the chat_id. This can be done by sending any message to the bot, and then using the .../getUpdates call to get it. The message will contain the desired chat_id. Then you can send messages to this chat_id. If this is all in order to simply send notifications to yourself in telegrams, then you don’t need to keep a constantly running bot, just pull sendMessage if necessary.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question