Skip to Content
EmsyaNet 4.0 is released 🎉
Bot Telegram

Tutorial Notifikasi PPPoE ke Telegram

Panduan ini akan membahas cara membuat notifikasi otomatis ke Telegram ketika koneksi PPPoE (baik Client maupun Server) mengalami perubahan status (Connect/Disconnect).


🛠️ Persiapan

Sebelum memulai, pastikan Anda sudah memiliki:

  1. Akun Telegram
  2. Bot Token (dari @BotFather)
  3. Chat ID (tujuan pengiriman notifikasi)
  4. Router MikroTik

🤖 Langkah 1: Membuat Bot Telegram

  1. Buka aplikasi Telegram.
  2. Cari @BotFather.
  3. Ketik /newbot dan ikuti petunjuk untuk memberi nama bot.
  4. Salin HTTP API Token yang diberikan.

🆔 Langkah 2: Mendapatkan Chat ID

  1. Chat bot yang baru Anda buat, ketik apa saja (misal: halo).
  2. Buka browser dan akses: https://api.telegram.org/bot<TOKEN_ANDA>/getUpdates
  3. Cari bagian "id": di dalam respon JSON (biasanya diawali angka seperti 123456789 atau - jika grup).

⚙️ Langkah 3: Script MikroTik

Kita akan menggunakan script pada PPP Profile agar berjalan otomatis saat status koneksi berubah.

Script Notifikasi

Ganti variabel berikut:

  • botToken: Token dari BotFather
  • chatId: ID tujuan notifikasi

1. Masuk ke Menu PPP

Buka Winbox, masuk ke menu PPP -> Profiles.

2. Edit atau Buat Profile Baru

Pilih profile yang digunakan (misal: default atau pppoe-profile).

3. Tab Scripts

Di tab Scripts, masukkan kode berikut:

➡️Untuk ROS 6

On Up (Saat Terkoneksi):

:local botToken "8531005882:AAHSknzJEhdwdwdwddwddghghgg8"; :local chatId "43434343"; :local usrName $user; :local ips [/ppp active get [find name=$usrName] address]; :local up [/ppp active get [find name=$usrName] uptime]; :local caller [/ppp active get [find name=$usrName] caller-id]; :local service [/ppp active get [find name=$usrName] service]; :local active [/ppp active print count]; :local date [/system clock get date]; :local board [/system resource get board-name]; :local time [/system clock get time]; :local msg ("\F0\9F\9F\A2 LOGIN-PPPOE:%0A=================%0A\E2\9E\9C Mikrotik : $board%0A\E2\9E\9C User Client : $user%0A\E2\9E\9C IP Client : $ips%0A\E2\9E\9C Caller ID : $caller%0A\E2\9E\9C Uptime : $up%0A\E2\9E\9C Service : $service%0A\E2\9E\9C Total Active : $active%0A\E2\9E\9C Date : $date $time"); :local url ("https://api.telegram.org/bot" . $botToken . "/sendMessage\?chat_id=" . $chatId . "&text=" . $msg); /tool fetch url=$url keep-result=no;

On Down (Saat Terputus):

:local chat "43434343"; :local bot "8531005882:AAHSknzJEhdwdwdwddwddghghgg8"; :local nama "$user"; :local profile [/ppp secret get [find name=$nama] profile]; :local date "$[/system clock get date] $[/system clock get time]"; :local active [/ppp active print count]; :local reason [/ppp secret get [find name=$nama] last-disconnect-reason]; :tool fetch url="https://api.telegram.org/bot$bot/sendMessage?chat_id=$chat&text=\F0\9F\9A\A8 DISCONNECT%0A\E2\9E\9C Nama : $nama%0A\E2\9E\9C Profile : $profile%0A\E2\9E\9C Date: $date%0A\E2\9E\9C Active: $active%0A\E2\9E\9C Reason: $reason" keep-result=no;

➡️Untuk ROS 7

On Up (Saat Terkoneksi):

:local botToken "8531005882:AAHSknzJEhdwdwdwddwddghghgg8"; :local chatId "43434343"; :local usrName $user; :local ips [/ppp active get [find name=$usrName] address]; :local up [/ppp active get [find name=$usrName] uptime]; :local caller [/ppp active get [find name=$usrName] caller-id]; :local service [/ppp active get [find name=$usrName] service]; :local active [/ppp active print count]; :local date [/system clock get date]; :local board [/system resource get board-name]; :local time [/system clock get time]; :local msg ("\F0\9F\9F\A2 LOGIN-PPPOE:%0A=================%0A\E2\9E\9C Mikrotik : $board%0A\E2\9E\9C User Client : $user%0A\E2\9E\9C IP Client : $ips%0A\E2\9E\9C Caller ID : $caller%0A\E2\9E\9C Uptime : $up%0A\E2\9E\9C Service : $service%0A\E2\9E\9C Total Active : $active%0A\E2\9E\9C Date : $date $time"); :local url ("https://api.telegram.org/bot" . $botToken . "/sendMessage\?chat_id=" . $chatId . "&text=" . $msg); /tool fetch url=$url keep-result=no;

On Down (Saat Terputus):

:local botToken "8531005882:AAHSknzJEhdwdwdwddwddghghgg8"; :local chatId "43434343"; :local usrName $user; :local service [/ppp secret get [find name=$usrName] service]; :local profile [/ppp secret get [find name=$usrName] profile]; :local active [/ppp active print count]; :local date [/system clock get date]; :local time [/system clock get time]; :local msg ("\F0\9F\94\B4 LOGOUT-PPPOE:%0A==================%0A\E2\9E\9C User Client : $user%0A\E2\9E\9C Service : $service %0A\E2\9E\9C Profile: $profile%0A\E2\9E\9C Total Active : $active%0A\E2\9E\9C Date : $date $time"); :local url ("https://api.telegram.org/bot" . $botToken . "/sendMessage\?chat_id=" . $chatId . "&text=" . $msg); /tool fetch url=$url keep-result=no;

Catatan: Variabel $user, $interface, dan $local-address disediakan otomatis oleh sistem MikroTik pada script PPP Profile.


✅ Langkah 4: Pengujian

  1. Lakukan koneksi ulang pada PPPoE Client.
  2. Cek Telegram Anda, seharusnya notifikasi akan masuk saat status Connected dan Disconnected.

💡 Tips Tambahan

Mengatasi Spasi di Pesan

Script di atas menggunakan URL sederhana. Jika pesan mengandung karakter khusus yang membuat error, Anda mungkin perlu mengubah spasi menjadi %20, namun MikroTik versi terbaru biasanya menangani URL dengan cukup baik. Jika gagal, coba ganti spasi dengan _ atau %20 manual.

Debugging

Jika pesan tidak terkirim:

  1. Pastikan Router bisa ping ke api.telegram.org.
  2. Cek Log di MikroTik (/log print) untuk melihat pesan error.
Last updated on