# Howto Write a Telegram Alert Endpoint for ntopng | ntop

> Telegram is a popular messaging application that many people use daily to do instant messaging and receive notifications. As of ntopng 4.2, it is now possible

[Blog](https://www.ntop.org/blog/)[ntopng](https://www.ntop.org/category/ntopng/)

# Howto Write a Telegram Alert Endpoint for ntopng

November 5, 20203 min read

[Telegram](http://telegram.org) is a popular messaging application that many people use daily to do instant messaging and receive notifications. As of ntopng 4.2, it is now possible to deliver alerts to external entities including Slack, email and Discord.

This post will show you how the Telegram alert endpoint has been developed so that readers can learn how to contribute to the ntopng development by coding new integrations. For a complete guide about alert endpoints, please refer to the [ntopng user’s guide](https://www.ntop.org/guides/ntopng/scripts/alert_endpoints.html), whereas the complete [telegram endpoint source code can be found here](https://github.com/ntop/ntopng/telegram_alert_endpoint).

We suppose that you have downloaded the [ntopng code from github](https://github.com/ntop/ntopng). Done that, go to [ntopng/scripts/plugins/endpoints](https://github.com/ntop/ntopng): here you can find the folder where endpoints are stored. Similar to all the other endpoints, you need to create a new folder for your endpoint (e.g. “some\_alert\_endpoint”): for telegram we created a folder named telegram\_endpoint. Then you need to create two files named

-   *[http\_lint.lua](https://github.com/ntop/ntopng)  
    *This file is used to check (this is know as [linting](https://medium.com/@artemhorbenko/introduction-to-linting-d3b172999f54)) the values of the parameters that will be passed to the endpoint through the ntopng web interface. This file needs to have a single function called *script.getAdditionalParameters(http\_lint)* and has to return the checks needed to be done on the inputs.  
    ![](/images/2020/11/telegram_http_lint.webp)
-   [*manifest.lua *](https://github.com/ntop/ntopng)It contains the title, the description and the author of the plugin.![](/images/2020/11/telegram_manifest.webp)

Inside the telegram endpoint you also need to create a [*templates*](https://github.com/ntop/ntopng/telegram_alert_endpoint/templates) folder that will contain both the endpoint and recipient html templates. These two templates are used to show the various input arguments, descriptions, ecc. on the GUI  
respectively of the recipient and endpoint configuration.

![](/images/2020/11/new_endpoint_blank-1.webp)

The various template parameters (format, inputs and so on) shown on the GUI, are taken from the locales folder divided according to the respective language file such as [en.lua](https://github.com/ntop/ntopng) (English), [it.lua](https://github.com/ntop/ntopng) (Italian) and so on. ntopng will choose the language set in the preferences panel for the ntopng web user.

Furthermore, there is a new directory named [*alert\_endpoint*](https://github.com/ntop/ntopng/telegram_alert_endpoint/alert_endpoints) folder, where we’re going to store the endpoint code. In this folder create a file named [telegram.lua](https://github.com/ntop/ntopng), and put here all the code necessary to send telegram messages, format the parameters and so on.

The first part of this script is depicted below.

![](/images/2020/11/telegram_variable.webp)

and it defines the HTTP parameters used in the recipient and endpoint forms used by telegram. Inside the XXX\_params you need to specify the parameters passed in the input forms: the endpoint\_params will be used by the endpoint form template, and the other for the recipient form. Additionally it is required to create a function called telegram.format\_recipient\_params(recipient\_params) responsible to format the output of the recipient parameters.

![](/images/2020/11/format_recipient_params.webp)

At this point you can create a function to be called periodically responsible to process the queued alerts (generated by ntopng when specific traffic patterns are detected, e.g. when a host contacts a malware site), dequeue and deliver them to telegram. This function is named telegram.dequeueRecipientAlerts().

![](/images/2020/11/dequeue_alerts.webp)

In the above code the ntop.recipient\_dequeue() function is the one that will dequeue triggered alerts that need to be sent via telegram.

Once notifications have been dequeued, they can be delivered to Telegram via a HTTP POST according to the JSON format specified by the [Telegram API](https://core.telegram.org).

We’re almost ready: we just need to create an additional function that is used by the ntopng engine when during recipient configuration, the administrator wants to check if the setup is correct by sending a test message.

![](/images/2020/11/test_function.webp)

That’s all. Your telegram endpoint is now completed. As you can see most of the work is required to create the web template and format the message that will be sent via HTTP POST. As most systems now feature a REST API, we believe that integrating additional endpoints should be pretty simple by cloning the telegram endpoint code, renaming telegram to my\_endpoint and doing little cosmetic changes. Are you ready to contribute to the ntopng development  by creating a new endpoint?

Enjoy!

## Keep reading

nDPINov 7, 2026

### [Detecting CVE-2026-98432 using nDPI/ntopng](https://www.ntop.org/detecting-cve-2026-98432-using-ndpi-ntopng/)

CVE-2026-98432 is a critical, 9.8-severity use-after-free (UAF) vulnerability in the Linux kernel’s IPv4 TCP networking stack. It allows an unauthenticated remote attacker to potentially cause system crashes, memory corruption, or execute arbitrary commands with root privileges. From a network stand

[![](/images/2026/09/Screenshot-2026-09-09-151028-1.webp)](https://www.ntop.org/october-20th-join-us-for-the-ntopng-7-0-webinar/)

AnnounceOct 5, 2026

### [October 20th: Join us for the ntopng 7.0 Webinar](https://www.ntop.org/october-20th-join-us-for-the-ntopng-7-0-webinar/)

Is your network monitoring keeping pace with AI, larger infrastructures, and the growing need for real observability? We’re excited to introduce ntopng 7.0, alongside new releases of the rest of the ntop…

[![](/images/2026/09/Screenshot-2026-09-09-163410-1.webp)](https://www.ntop.org/ntopng-user-interface-introducing-the-new-navigation-bar/)

ntopngSep 21, 2026

### [ntopng User Interface: Introducing the New Navigation Bar](https://www.ntop.org/ntopng-user-interface-introducing-the-new-navigation-bar/)

In our continuous effort to improve user experience and make network monitoring more intuitive, we have completely redesigned the ntopng Navigation Bar. As our feature set expands—with crucial additions like the nAnalyst…

## Try it on your own network

Download the free Community edition and see your first flows in five minutes.

[Download ntopng free](https://www.ntop.org/support/documentation/software-installation/)[Talk to an engineer](https://www.ntop.org/support/need-help/contacts/)
Source: https://www.ntop.org/howto-write-a-telegram-alert-endpoint-for-ntopng/