Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Zabbix alerts via Telegram

Zabbix alerts via Telegram

Replace my_zabbix_bot and My Zabbix Bot below with your own names.

Create and test telegram bot

Add @BotFather contact in Telegram and press 'start',
then type:

My Zabbix Bot

The bot will reply you with a token, which we will refer to as ${TOKEN} below.

Add a @my_zabbix_bot contact to your Telegram, press 'start' and send a random message.

Now we need to retrieve a chat_id for this conversation.

$ curl "${TOKEN}/getUpdates"

The <CHAT_ID> above is what you need. It's the RESULT.result[0] key in JSON notation.

Test that it actually works:

$ curl -X POST --retry 5 --retry-delay 0 --retry-max-time 60 --data-urlencode "chat_id=${CHAT_ID}" --data-urlencode "text=Hello" "${TOKEN}/sendMessage?disable_web_page_preview=true"

Install zabbix media type

Find out your AlertScriptsPath from the zabbix_server.conf. It's ${datadir}/zabbix/alertscripts by default.

Put the file (attached) to that folder. Don't forget to chmod +x

Open your Zabbix web interface, navigate to 'Administration - Media types - Create',
Put in the form:

  • Name: Telegram
  • Type: Script
  • Script name:
  • Script parameters (Zabbix 3 only):


Ensure that you have an action (Configuration - Actions) which sends to the Telegram media type.


Navigate to 'Administration - Users - <Your user> - Media', add Telegram, in the 'Send to' field put your ${CHAT_ID} and ${TOKEN}, separated with space, for example: 12345678 123456789:AAaaaaAAAaaa_aAAaaAaA-aaAAa.


CHAT_ID=`echo "$1" | cut -d " " -f 1`
TOKEN=`echo "$1" | cut -d " " -f 2`
curl --silent -X POST --retry 5 --retry-delay 0 --retry-max-time 60 --data-urlencode "chat_id=${CHAT_ID}" --data-urlencode "text=Subject: ${SUBJECT}${NL}${NL}${MESSAGE}" "${TOKEN}/sendMessage?disable_web_page_preview=true" | grep -q '"ok":true'

This comment has been minimized.

Copy link

gitTerrence commented Jun 7, 2018

Hi KostyaEsmukov expert,
Need your help, saw your post here to integrate telegram in Zabbix. But i have no idea how to do it.


This comment has been minimized.

Copy link

RahPraSingh commented Dec 12, 2018

curl --silent -X POST --retry 5 --retry-delay 0 --retry-max-time 60 --data-urlencode "chat_id=${CHAT_ID}" --data-urlencode "text=Subject: ${SUBJECT}${NL}${NL}${MESSAGE}" "${TOKEN}/sendMessage?disable_web_page_preview=true" | grep -q '"ok":true'
this is sending mail to telegram but zabbix getting failed .
I am not sure where i am doing wrong , can you help me on same


This comment has been minimized.

Copy link

Ediacarium commented Mar 2, 2019

Zabbix doesn't create an environment for notification scripts, so if anyone else sits behind a http(s)-proxy, the curl-command fails if you configured the proxy with an environment variable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.