# Notifications via custom Webhook (Telegram)

**URL:** <https://forum.opensearch.org/t/notifications-via-custom-webhook-telegram/18517>\
**Category:** OpenSearch\
**Tags:** alerting\
**Created:** [March 22, 2024, 11:23am UTC](https://forum.opensearch.org/t/notifications-via-custom-webhook-telegram/18517 "2024-03-22T11:23:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![codi639](https://avatars.discourse-cdn.com/v4/letter/c/ba9def/32.png) [@codi639](https://forum.opensearch.org/u/codi639)\
**Post date:** [March 22, 2024, 11:23am UTC](https://forum.opensearch.org/t/notifications-via-custom-webhook-telegram/18517/1 "2024-03-22T11:23:02Z")

</div>

Hello everyone,

Using the version 2.12.2 of OpenSearch, I’m trying to build some alerts to monitor my routers.  
I wanted to send to notification via a telegram bot using a custom webhook. I’m able to send a static message if the alert trigger but I don’t see how to personalize the message with, for example, the address of the router where the alert triggered.  
The problem is the same using slack webhook, I don’t know how to send “interesting” data with my message.

When building the actions of the alert, in the notification part, I can notice the `message` part:

```auto
Monitor {{ctx.monitor.name}} just entered alert status. Please investigate the issue.
  - Trigger: {{ctx.trigger.name}}
  - Severity: {{ctx.trigger.severity}}
  - Period start: {{ctx.periodStart}}
  - Period end: {{ctx.periodEnd}}

```

But I don’t get how this message is supposed to be transmit via my custom telegram webhook…

There’s how I’ve configured my channel:

```auto
Channel type: Custom webhook
Method: POST
Define endpoints by: Webhook URL
Webhook URL: https://api.telegram.org/bot1415818198:.........Y2mUjXl706_0qK3o/sendMessage?chat_id=-4.......772&text=An%20interface%20have%20been%20changed

```

The webhook header is by default on `application/json`

A workaround would be to create a rule for each router and build personalized message for each, but this is way too heavy…

Any helps, ideas would be very appreciate!

Regards

---

<div class="post-metadata">

**Author:** ![Vitalii](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/vitalii/32/7493_2.png) [@Vitalii](https://forum.opensearch.org/u/Vitalii)\
**Post date:** [May 10, 2024, 1:21pm UTC](https://forum.opensearch.org/t/notifications-via-custom-webhook-telegram/18517/2 "2024-05-10T13:21:26Z")

</div>

Hello, you need to specify “text” in Message  
{  
“text”:" Monitor {{ctx.monitor.name}} just entered alert status. Please investigate the issue.

- Trigger: {{ctx.trigger.name}}
- Severity: {{ctx.trigger.severity}}
- Period start: {{ctx.periodStart}}
- Period end: {{ctx.periodEnd}}"  
}

And the Webhook URL: [https://api.telegram.org/bot1415818198:.........Y2mUjXl706\_0qK3o/sendMessage?chat\_id=-4.......772](https://api.telegram.org/bot1415818198:.........Y2mUjXl706_0qK3o/sendMessage?chat_id=-4.......772)

---

<div class="post-metadata">

**Author:** ![gamayun](https://avatars.discourse-cdn.com/v4/letter/g/a4c791/32.png) [@gamayun](https://forum.opensearch.org/u/gamayun)\
**Post date:** [May 29, 2025, 6:29am UTC](https://forum.opensearch.org/t/notifications-via-custom-webhook-telegram/18517/3 "2025-05-29T06:29:00Z")

</div>

Hello! I use v2.19.0.  
I setup webhook like this:  
[https://api.telegram.org/bot7580xxxxxBvN6LhqA/sendMessage?chat\_id=-46xxx942](https://api.telegram.org/bot7580xxxxxBvN6LhqA/sendMessage?chat_id=-46xxx942)

and message {  
“text”:" Monitor {{ctx.monitor.name}} just entered alert status. Please investigate the issue.

```
Trigger: {{ctx.trigger.name}}
Severity: {{ctx.trigger.severity}}
Period start: {{ctx.periodStart}}
Period end: {{ctx.periodEnd}}"
}

```

alert is active but I don’t get it in telegram.  
When i send test message like:

```auto
Webhook URL: https://api.telegram.org/bot1415818198:.........Y2mUjXl706_0qK3o/sendMessage?chat_id=-4.......772&text=An%20interface%20have%20been%20changed
i got it.
```

---

<div class="post-metadata">

**Author:** ![gamayun](https://avatars.discourse-cdn.com/v4/letter/g/a4c791/32.png) [@gamayun](https://forum.opensearch.org/u/gamayun)\
**Post date:** [May 29, 2025, 6:44am UTC](https://forum.opensearch.org/t/notifications-via-custom-webhook-telegram/18517/4 "2025-05-29T06:44:36Z")

</div>

{  
“name”: “monitor”,  
“type”: “monitor”,  
“monitor\_type”: “query\_level\_monitor”,  
“enabled”: true,  
“schedule”: {  
“period”: {  
“unit”: “MINUTES”,  
“interval”: 1  
}  
},  
“inputs”: [  
{  
“search”: {  
“indices”: [  
“logstash-k8s-prod-\*”  
],  
“query”: {  
“size”: 0,  
“aggregations”: {},  
“query”: {  
“bool”: {  
“filter”: [  
{  
“range”: {  
“@timestamp”: {  
“gte”: “{{period\_end}}||-1h”,  
“lte”: “{{period\_end}}”,  
“format”: “epoch\_millis”  
}  
}  
},  
{  
“match\_phrase”: {  
“json.level”: “ERROR”  
}  
}  
]  
}  
}  
}  
}  
}  
],  
“triggers”: [  
{  
“query\_level\_trigger”: {  
“id”: “vmvHGpcBSJrElTHrcE7i”,  
“name”: “trigger”,  
“severity”: “1”,  
“condition”: {  
“script”: {  
“source”: “ctx.results[0].hits.total.value \> 1”,  
“lang”: “painless”  
}  
},  
“actions”: [  
{  
“id”: “notification285712”,  
“name”: “send”,  
“destination\_id”: “0mqzFpcBSJrElTHr5I4x”,  
“message\_template”: {  
“source”: “Monitor {{ctx.monitor.name}} just entered alert status. Please investigate the issue.\n - Trigger: {{ctx.trigger.name}}\n - Severity: {{ctx.trigger.severity}}\n - Period start: {{ctx.periodStart}} UTC\n - Period end: {{ctx.periodEnd}} UTC”,  
“lang”: “mustache”  
},  
“throttle\_enabled”: false,  
“subject\_template”: {  
“source”: “Alerting Notification action”,  
“lang”: “mustache”  
}  
}  
]  
}  
}  
],  
“ui\_metadata”: {  
“schedule”: {  
“timezone”: null,  
“frequency”: “interval”,  
“period”: {  
“unit”: “MINUTES”,  
“interval”: 1  
},  
“daily”: 0,  
“weekly”: {  
“tue”: false,  
“wed”: false,  
“thur”: false,  
“sat”: false,  
“fri”: false,  
“mon”: false,  
“sun”: false  
},  
“monthly”: {  
“type”: “day”,  
“day”: 1  
},  
“cronExpression”: “0 \*/1 \* \* \*”  
},  
“monitor\_type”: “query\_level\_monitor”,  
“search”: {  
“searchType”: “graph”,  
“timeField”: “@timestamp”,  
“aggregations”: ,  
“groupBy”: ,  
“bucketValue”: 1,  
“bucketUnitOfTime”: “h”,  
“filters”: [  
{  
“fieldName”: [  
{  
“label”: “json.level”,  
“type”: “text”  
}  
],  
“fieldValue”: “ERROR”,  
“operator”: “is”  
}  
]  
}  
}  
}
