Friday, December 12, 2025

.::: Create alert using API Bot Telegram to private / username bot :::.

 
Berikut panduan cara membuat alert/notification ke Telegram dari server atau aplikasi Anda. Saya jelaskan cara paling umum dan paling mudah: mengirim pesan ke Telegram via Bot API.

1. Buat Bot Telegram (via BotFather) example bot 'teguhth' usernamebot 'teguhth_alert_bot'

Buka Telegram.
Cari BotFather.

Ketik:

/start
/newbot

 
Masukkan nama bot dan username bot. 
BotFather akan memberikan API Token, contoh:

8537695777:AAF6qO3Hm3l695Mw0CpvuIJtQppexF2jAW8

Simpan token ini.
 


2. go to boot start and test (teguhth)

/start

test first

 

3. Dapatkan Chat ID

Ada 2 cara termudah:

Cara A — Kirim pesan ke bot lalu buka:
https://api.telegram.org/bot<token>/getUpdates

Contoh:

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

Anda akan melihat JSON yang berisi:

"chat":{"id":232763961}
 
[root@teguhth ~]# curl -s https://api.telegram.org/bot8537695777:AAF6qO3Hm3l695Mw0CpvuIJtQppexF2jAW8/getUpdates | grep -i test
"message":{"message_id":3,"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":1765503495,"text":"test"}},{"update_id":557475911,
"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,
"message":{"message_id":8,"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":1765504490,"text":"test bot"}},{"update_id":557475918,
"message":{"message_id":9,"from":{"id":232763961,"is_bot":false,"first_name":"Teguh","last_name":"Triharto","username":"teguhth","language_code":"en"},"chat":{"id":-4547711556,"title":"Bangun Rumah (Cloud)","type":"group","all_members_are_administrators":true,"accepted_gift_types":{"unlimited_gifts":false,"limited_gifts":false,"unique_gifts":false,"premium_subscription":false}},"date":1765504525,"text":"test"}},{"update_id":557475919,
"message":{"message_id":45,"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":1765525402,"text":"test subgroup"}},{"update_id":557475927,
[root@teguhth ~]#

Itu adalah chat_id Anda.

4. Kirim Alert ke Telegram Manually (Testing) / Private

Coba kirim pesan:

using url / post

https://api.telegram.org/bot8537695777:AAF6qO3Hm3l695Mw0CpvuIJtQppexF2jAW8/sendMessage?chat_id=232763961&text=Hello%20Telegram_url

postman

linux 

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

windows

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

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

powershell 

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

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=232763961 --data-urlencode "text=$msg"


[root@teguhth temp]# more 1.sh
msg="cat message.txt"

curl -s -X POST https://api.telegram.org/bot8537695777:AAF6qO3Hm3l695Mw0CpvuIJtQppexF2jAW8/sendMessage -d chat_id=232763961 -d text="$msg"
[root@teguhth temp]#

No comments:

Post a Comment

Popular Posts