
Ks Tan (Asia Vad) asked a question.
Alert Integrate with Telegram Messaging
VBScript below performs HTTPS post to Telegram server, to send telegram message
Prerequisite:
1. Telegram BOT account, act as member to a Telegram chat group (channel), to post message via script.
2. Two ID: BOT account API_ID, and the unique chat group ID
Code sharts here
- ‘By Kstan, Asia Vad
- ‘Created when new BOT XXX_name is created, enter the token given to access the HTTP API for your BOT
- sAPI_ID = "6140647978:ASIAVadGQeAOspF0tMSOcjxGLrLLxtcz7XI"
- ‘Enter the Chat_ID, corresponding to your telegram channel here, chat group.
- 'Below ID is XXX_AsiaVad_WUGChannel
- sChat_ID = "-1001637099131"
- ‘Test Message - to comment off
- 'Can modify with different WhatsUp Gold percent variables
- sMSG = "%Device.DisplayName (%Device.Address) is %Device.State, at %System.Time on %System.Date"
-
- 'URL to open....
-
- sUrl = "https://api.telegram.org/bot" & sAPI_ID & "/sendMessage"
- 'POST Request to send.
- sRequest = "text=" & sMSG & "&chat_id=" & sChat_ID
-
- HTTPPost sUrl, sRequest
-
- Function HTTPPost(sUrl, sRequest)
- set oHTTP = CreateObject("Microsoft.XMLHTTP")
- oHTTP.open "POST", sUrl,false
- oHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
- oHTTP.setRequestHeader "Content-Length", Len(sRequest)
- oHTTP.send sRequest
- HTTPPost = oHTTP.responseText
-
- End Function
Hello Jason,
Thank you for your collaboration, I want to ask you, I understand that I must create a Monitor (Active Script Monitor) and replace the variables with mine, and then assign that monitor to the host that I want the alert. Did I understand correctly?
Hi Rhael,
The script is to create in Active Script Action method, (reference: https://docs.progress.com/bundle/whatsupgold-user-help-23-0/page/Active-Script-Action_2.html).
Yes, to replace with the percent variables, depends on details requried and monitor assignment, which can be assigned to Device, Active Monitor, Passive Monitor..
Thanks.
Hi Jason, I was creating the VBscript as shown in the example, generated a simple active monitor and replaced the token and chat id with the one we created, but we have had no luck. I would appreciate it if you have a little more documentation or if you have an example of an active monitor with an example variable: %ActiveMonitor.State
Hi, the script above, is to be assigned at Device > Action.
Action Alert with variable %ActiveMonitor.State need to associate with Active Monitor > Action directly.
reference: https://docs.progress.com/bundle/whatsupgold-user-help-23-0/page/Percent-Variables.html
Thanks Jason, I had a comment sign error that prevented me from executing the script.
Thank you so much