Friday, December 12, 2025

.::: Create alert using API Bot Telegram to group & subtopic :::.

 


correlation to https://teguhth.blogspot.com/2025/12/create-alert-using-api-bot-telegram-to.html

1. add bot group to new group with message privilegde
 
2. run chat sample to username bot 

 



3. get message with id group (record group id chat)

https://api.telegram.org/bot8537695777:AAF6qO3Hm3l695Mw0CpvuIJtQppexF2jAW8/getUpdates

or 

curl -s https://api.telegram.org/bot8537695777:AAF6qO3Hm3l695Mw0CpvuIJtQppexF2jAW8/getUpdates

[root@teguhth ~]# curl -s https://api.telegram.org/bot8537695777:AAF6qO3Hm3l695Mw0CpvuIJtQppexF2jAW8/getUpdates | grep -i tele
"message":{"message_id":6,"from":{"id":232763961,"is_bot":false,"first_name":"Teguh","last_name":"Triharto","username":"teguhth","language_code":"en"},"chat":{"id":232763961,"first_name":"Teguh","last_name":"Triharto","username":"teguhth","type":"private"},"date":1765503828,"text":"testing alert telegram"}},{"update_id":557475915,
[root@teguhth ~]#


4. Kirim Alert ke Telegram Manually (Testing) group chat_id=-4547711556

Coba kirim pesan:

using url / post

https://api.telegram.org/bot8537695777:AAF6qO3Hm3l695Mw0CpvuIJtQppexF2jAW8/sendMessage?chat_id=-4547711556&text=Hello%20Telegram_url_group

postman

linux 

curl -s -X POST https://api.telegram.org/bot8537695777:AAF6qO3Hm3l695Mw0CpvuIJtQppexF2jAW8/sendMessage -d chat_id=-4547711556 -d text="Test from linux manual group"

curl.exe -s -X POST https://api.telegram.org/bot8537695777:AAF6qO3Hm3l695Mw0CpvuIJtQppexF2jAW8/sendMessage -d chat_id=-4547711556 -d text="Test from windows manual group"

C:\Windows\System32\curl.exe -s -X POST https://api.telegram.org/bot8537695777:AAF6qO3Hm3l695Mw0CpvuIJtQppexF2jAW8/sendMessage -d chat_id=-4547711556 -d text="Test from windows manual group"

powershell 

Invoke-RestMethod "https://api.telegram.org/bot8537695777:AAF6qO3Hm3l695Mw0CpvuIJtQppexF2jAW8/sendMessage?chat_id=-4547711556&text=Test from powershell group"

Jika berhasil, alert siap digunakan.
  





5. for checking history message 

url 

https://api.telegram.org/bot8537695777:AAF6qO3Hm3l695Mw0CpvuIJtQppexF2jAW8/getUpdates

linux 
curl -s https://api.telegram.org/bot8537695777:AAF6qO3Hm3l695Mw0CpvuIJtQppexF2jAW8/getUpdates

windows

curl.exe -s https://api.telegram.org/bot8537695777:AAF6qO3Hm3l695Mw0CpvuIJtQppexF2jAW8/getUpdates

C:\windows\system32\curl.exe -s https://api.telegram.org/bot8537695777:AAF6qO3Hm3l695Mw0CpvuIJtQppexF2jAW8/getUpdates

powershell 
Invoke-RestMethod "https://api.telegram.org/bot8537695777:AAF6qO3Hm3l695Mw0CpvuIJtQppexF2jAW8/getUpdates"


C:\Windows\System32\curl.exe

Invoke-RestMethod "https://api.telegram.org/bot8537695777:AAF6qO3Hm3l695Mw0CpvuIJtQppexF2jAW8/getUpdates" | ConvertTo-Json -Depth 100

(Invoke-WebRequest "https://api.telegram.org/bot8537695777:AAF6qO3Hm3l695Mw0CpvuIJtQppexF2jAW8/getUpdates").Content

6. if using shell script 

msg=$(cat message.txt)

curl -s -X POST https://api.telegram.org/bot8537695777:AAF6qO3Hm3l695Mw0CpvuIJtQppexF2jAW8/sendMessage -d chat_id=-4547711556 --data-urlencode "text=$msg"


[root@teguhth temp]# more 1.sh
msg=$(cat messages.txt)

curl -s -X POST https://api.telegram.org/bot8537695777:AAF6qO3Hm3l695Mw0CpvuIJtQppexF2jAW8/sendMessage -d chat_id=-4547711556 -d text="$msg"
#curl -s -X POST https://api.telegram.org/bot8537695777:AAF6qO3Hm3l695Mw0CpvuIJtQppexF2jAW8/sendMessage -d chat_id=232763961 --data-urlencode "text=$msg"

[root@teguhth temp]#



7. test using message_id":45 subgroup

curl -s "https://api.telegram.org/bot8537695777:AAF6qO3Hm3l695Mw0CpvuIJtQppexF2jAW8/getUpdates" | grep -i alert_sample

[root@teguhth ~]# curl -s "https://api.telegram.org/bot8537695777:AAF6qO3Hm3l695Mw0CpvuIJtQppexF2jAW8/getUpdates" | grep -i alert_sample
"message":{"message_id":2,"from":{"id":232763961,"is_bot":false,"first_name":"Teguh","last_name":"Triharto","username":"teguhth","language_code":"en"},"chat":{"id":-1003406604204,"title":"Bangun Rumah (Cloud)","is_forum":true,"type":"supergroup"},"date":1765525299,"message_thread_id":2,"forum_topic_created":{"name":"alert_sample","icon_color":7322096,"icon_custom_emoji_id":"5312241539987020022"},"is_topic_message":true}},{"update_id":557475925,
"message":{"message_id":3,"from":{"id":232763961,"is_bot":false,"first_name":"Teguh","last_name":"Triharto","username":"teguhth","language_code":"en"},"chat":{"id":-1003406604204,"title":"Bangun Rumah (Cloud)","is_forum":true,"type":"supergroup"},"date":1765525299,"message_thread_id":2,"reply_to_message":{"message_id":2,"from":{"id":232763961,"is_bot":false,"first_name":"Teguh","last_name":"Triharto","username":"teguhth","language_code":"en"},"chat":{"id":-1003406604204,"title":"Bangun Rumah (Cloud)","is_forum":true,"type":"supergroup"},"date":1765525299,"message_thread_id":2,"forum_topic_created":{"name":"alert_sample","icon_color":7322096,"icon_custom_emoji_id":"5312241539987020022"},"is_topic_message":true},"text":"/start","entities":[{"offset":0,"length":6,"type":"bot_command"}],"is_topic_message":true}},{"update_id":557475926,
[root@teguhth ~]#


8. sample alert to soubgroup

curl -s -X POST https://api.telegram.org/bot8537695777:AAF6qO3Hm3l695Mw0CpvuIJtQppexF2jAW8/sendMessage -d chat_id=-1003406604204 -d message_thread_id=2 -d text="Hello alert_sample subtopic"

 


9. for sub group alert  script 

[root@teguhth temp]# more 1.sh
msg=$(cat messages.txt)

curl -s -X POST https://api.telegram.org/bot8537695777:AAF6qO3Hm3l695Mw0CpvuIJtQppexF2jAW8/sendMessage -d chat_id=-1003406604204 -d message_thread_id=2 -d text="$msg"
#curl -s -X POST https://api.telegram.org/bot8537695777:AAF6qO3Hm3l695Mw0CpvuIJtQppexF2jAW8/sendMessage -d chat_id=-4547711556 -d text="$msg"
#curl -s -X POST https://api.telegram.org/bot8537695777:AAF6qO3Hm3l695Mw0CpvuIJtQppexF2jAW8/sendMessage -d chat_id=232763961 --data-urlencode "text=$msg"

[root@teguhth temp]#

No comments:

Post a Comment

Popular Posts