Mikrotik telegram notification on openvpn access: Difference between revisions
From Fvettore-WIKI
Created page with "Here is the **English translation** of your article, maintaining the **MediaWiki markup and formatting** exactly: --- == To receive Telegram notifications for OpenVPN connections/disconnections == In the following example: * we have two bot user chatIds (Fabrizio and Banion), respectively 173072004 and 5704842034.</br> * the BOT API key is: 1757914630\:AAFw1EE42wCTJ4Vy5HTUtRUb34BQna6nU3I (not a real value, example only)</br> On the routerboard, open the PPP configura..." |
No edit summary |
||
| Line 12: | Line 12: | ||
In the profile configuration, there is a SCRIPT tab. You can configure scripts for connection and disconnection (On Up & On Down).</br> | In the profile configuration, there is a SCRIPT tab. You can configure scripts for connection and disconnection (On Up & On Down).</br> | ||
===Example On Up:=== | |||
<pre> | <pre> | ||
| Line 28: | Line 28: | ||
</pre> | </pre> | ||
===Example On Down=== | |||
<pre> | <pre> | ||
Revision as of 09:29, 21 July 2025
Here is the **English translation** of your article, maintaining the **MediaWiki markup and formatting** exactly:
---
To receive Telegram notifications for OpenVPN connections/disconnections
In the following example:
- we have two bot user chatIds (Fabrizio and Banion), respectively 173072004 and 5704842034.
- the BOT API key is: 1757914630\:AAFw1EE42wCTJ4Vy5HTUtRUb34BQna6nU3I (not a real value, example only)
On the routerboard, open the PPP configuration
In the profile configuration, there is a SCRIPT tab. You can configure scripts for connection and disconnection (On Up & On Down).
Example On Up:
;local chatid "173072004" ;local chatid1 "5704842034" :local botapi "1757914630:AAFw1EE42wCTJ4Vy5HTUtRUb34BQna6nU3I" :local message "VPN CONNECTION on "; :local who "$[/system identity get name]"; :local address $"remote-address"; :local caller $"caller-id"; /tool fetch url="https://api.telegram.org/bot$botapi/sendMessage?text=$message$who USER $user $address $caller&chat_id=$chatid1" keep-result=no; /tool fetch url="https://api.telegram.org/bot$botapi/sendMessage?text=$message$who USER $user $address $caller&chat_id=$chatid" keep-result=no;
Example On Down
;local chatid "173072004"; ;local chatid1 "5704842034"; :local botapi "1757914630:AAFw1EE42wCTJ4Vy5HTUtRUb34BQna6nU3I"; :local message "VPN DISCONNECTED on "; :local who "$[/system identity get name]"; :local address $"remote-address"; :local caller $"caller-id"; /tool fetch url="https://api.telegram.org/bot$botapi/sendMessage?text=$message$who USER $user $address $caller&chat_id=$chatid1" keep-result=no; /tool fetch url="https://api.telegram.org/bot$botapi/sendMessage?text=$message$who USER $user $address $caller&chat_id=$chatid" keep-result=no;
