Message-Driven Bean implementation class for TelegramAlertingJob in SAP PI/PO. Sends messages from standard JMS queue alertingVP to Telegram channel via bot.
- Create public channel with public link (@nickname)
- Create bot via @botfather
- Add bot to channel as admin
- Operations->Jobs and open Java Scheduler
- On Java Scheduler screen go to tab Tasks and click the Add button
- Select TelegramAlertingJob
- Enter Job Parametres
alertConsumer: name of a consumer that was set in SAP PO Alert Rule. This is used as a name for JMS queue in alertingVP.
maxAlertCount is max count of consumed alerts from JMS queue
apiToken: can be retrieved from BotFather;
chatId: id of telegram channel (described below in How to get id of private telegram channel)
- Do not forget to set back channel as private one unless you want everyone to see a mess in your system ^^
- Set timer parameters. Running job every 2 min would be enough and much more representative than emails.
- Finish the job configuration. As a result you will find a job on Tasks tab
- Add bot as administrator to channel
- Set channel as Public channel and set channel nickname like @nickname
- Send message using https request: https://api.telegram.org/{botToken}/sendMessage?chat_id=@{channelNickName}&text=*test*&parse_mode=Markdown
As a result you will get JSON including real chat id:
{
"ok": true,
"result": {
"chat": {
"id": -100187777,
"title": "SAP PO Critical Alerts",
"type": "channel",
"username": "nickname"
},
"date": 1667811418,
"entities": [
{
"length": 4,
"offset": 0,
"type": "bold"
}
],
"message_id": 4,
"sender_chat": {
"id": -100187777,
"title": "SAP PO Critical Alerts",
"type": "channel",
"username": "nickname"
},
"text": "test"
}
}