New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Telegram Transport #2114

Closed
f0o opened this Issue Oct 12, 2015 · 19 comments

Comments

Projects
None yet
5 participants
@f0o
Member

f0o commented Oct 12, 2015

That whatsapp alternative app thing

@f0o f0o self-assigned this Oct 12, 2015

@tobiasa1

This comment has been minimized.

Show comment
Hide comment

👍

@f0o

This comment has been minimized.

Show comment
Hide comment
@f0o

f0o Oct 20, 2015

Member

Got my mate on it.

According to him it requires a persistent bot to deliver it so we will joint-venture on editing the IRC bot to speak telegram and xmpp as well as irc.

Member

f0o commented Oct 20, 2015

Got my mate on it.

According to him it requires a persistent bot to deliver it so we will joint-venture on editing the IRC bot to speak telegram and xmpp as well as irc.

@x3m

This comment has been minimized.

Show comment
Hide comment
@x3m

x3m Nov 20, 2015

+1 for such feature.

x3m commented Nov 20, 2015

+1 for such feature.

@snis

This comment has been minimized.

Show comment
Hide comment
@snis

snis Dec 10, 2015

+1
Any updates on this?
But persistent bot? All that's needed is to request a uniqe API key from Telegram and some strings and just POST them with http.
But then again I'm not the sharpest knive in the box.

snis commented Dec 10, 2015

+1
Any updates on this?
But persistent bot? All that's needed is to request a uniqe API key from Telegram and some strings and just POST them with http.
But then again I'm not the sharpest knive in the box.

@f0o

This comment has been minimized.

Show comment
Hide comment
@f0o

f0o Dec 11, 2015

Member

@snis looking at the docs it seems to need a persistent connection to get chat_id's and group_id's which are highly volatile.

It can also work in a Re-Action styled WebHook based thing, but then you need to crack open a webhook from LibreNMS to Telegram and allow bidirectional streams (which is why I'd like to outsource it from the enduser's install to some 3rd entity not directly linked.. paranoia you know.. never trust what could be on the wires :S)
It also seems like hosting this yourself (enduser must go through procedure of creating a bot or app [undecided yet]) is quite messy... So I'm thinking of hosting something as @QuxLabs and let LibreNMS users use it free of charge ofc! (I do intend to give sources open and let you, the enduser, decide if you want hosted vs self-hosted)

Member

f0o commented Dec 11, 2015

@snis looking at the docs it seems to need a persistent connection to get chat_id's and group_id's which are highly volatile.

It can also work in a Re-Action styled WebHook based thing, but then you need to crack open a webhook from LibreNMS to Telegram and allow bidirectional streams (which is why I'd like to outsource it from the enduser's install to some 3rd entity not directly linked.. paranoia you know.. never trust what could be on the wires :S)
It also seems like hosting this yourself (enduser must go through procedure of creating a bot or app [undecided yet]) is quite messy... So I'm thinking of hosting something as @QuxLabs and let LibreNMS users use it free of charge ofc! (I do intend to give sources open and let you, the enduser, decide if you want hosted vs self-hosted)

@f0o

This comment has been minimized.

Show comment
Hide comment
@f0o

f0o Dec 11, 2015

Member

Maybe I'm also missing some point or some hook - I'm just browsing their examples and 'API Docs' and see that they all rely on a WebHook or on LongPolling to figure what to do - So feedback/input/help is highly appreciated!

Member

f0o commented Dec 11, 2015

Maybe I'm also missing some point or some hook - I'm just browsing their examples and 'API Docs' and see that they all rely on a WebHook or on LongPolling to figure what to do - So feedback/input/help is highly appreciated!

@snis

This comment has been minimized.

Show comment
Hide comment
@snis

snis Dec 15, 2015

@f0o stumbled upon this page: http://kb.paessler.com/en/topic/65075-prtg-with-telegram. From my understanding the chat and user ID are static.
There is a limit of 30 messages/sec.

In order to get the group chat id, do the following:

  1. Add the Telegram BOT to the group.

  2. Get the list of updates for your BOT: https://api.telegram.org/bot/getUpdates Ex: https://api.telegram.org/botjbd78sadvbdy63d37gda37bd8/getUpdates

  3. Look for the "chat" object: {"update_id":8393, "message":{"message_id":3,"from":{"id":7474,"first_name":"AAA"},"chat":{"id":,"title":""},"date":25497,"new_chat_participant":{"id":71,"first_name":"NAME","username":"YOUR_BOT_NAME"}}}

This is a sample of the response when you add your BOT into a group.

  1. Use the "id" of the "chat" object to send your messages.

snis commented Dec 15, 2015

@f0o stumbled upon this page: http://kb.paessler.com/en/topic/65075-prtg-with-telegram. From my understanding the chat and user ID are static.
There is a limit of 30 messages/sec.

In order to get the group chat id, do the following:

  1. Add the Telegram BOT to the group.

  2. Get the list of updates for your BOT: https://api.telegram.org/bot/getUpdates Ex: https://api.telegram.org/botjbd78sadvbdy63d37gda37bd8/getUpdates

  3. Look for the "chat" object: {"update_id":8393, "message":{"message_id":3,"from":{"id":7474,"first_name":"AAA"},"chat":{"id":,"title":""},"date":25497,"new_chat_participant":{"id":71,"first_name":"NAME","username":"YOUR_BOT_NAME"}}}

This is a sample of the response when you add your BOT into a group.

  1. Use the "id" of the "chat" object to send your messages.
@snis

This comment has been minimized.

Show comment
Hide comment
@snis

snis Dec 15, 2015

Also, there are some php bot examples at: https://core.telegram.org/bots/samples#php

snis commented Dec 15, 2015

Also, there are some php bot examples at: https://core.telegram.org/bots/samples#php

@snis

This comment has been minimized.

Show comment
Hide comment
@snis

snis Dec 15, 2015

Managed to get this to work by using the "API Transport". By using the following API URL (Post method):
https://api.telegram.org/botTOKEN/sendMessage?chat_id=CHATID&text=%title

replace TOKEN and CHATID with your settings.

snis commented Dec 15, 2015

Managed to get this to work by using the "API Transport". By using the following API URL (Post method):
https://api.telegram.org/botTOKEN/sendMessage?chat_id=CHATID&text=%title

replace TOKEN and CHATID with your settings.

@f0o

This comment has been minimized.

Show comment
Hide comment
@f0o

f0o Dec 15, 2015

Member

The chat_id however isnt static, how do you figure which one it is?

On 15 December 2015 14:59:34 CET, snis notifications@github.com wrote:

Managed to get this to work by using the "API Transport". By using the
following API URL (Post method):
https://api.telegram.org/bot/sendMessage?chat_id=<chat_id>&text=%title

replace token and chat_id with your settings.


Reply to this email directly or view it on GitHub:
#2114 (comment)

Member

f0o commented Dec 15, 2015

The chat_id however isnt static, how do you figure which one it is?

On 15 December 2015 14:59:34 CET, snis notifications@github.com wrote:

Managed to get this to work by using the "API Transport". By using the
following API URL (Post method):
https://api.telegram.org/bot/sendMessage?chat_id=<chat_id>&text=%title

replace token and chat_id with your settings.


Reply to this email directly or view it on GitHub:
#2114 (comment)

@snis

This comment has been minimized.

Show comment
Hide comment
@snis

snis Dec 15, 2015

By visiting https://api.telegram.org/botTOKEN/getUpdates

I added the bot to a group and typed /start in the group after that the getUpdates URL displayed the chat_id

snis commented Dec 15, 2015

By visiting https://api.telegram.org/botTOKEN/getUpdates

I added the bot to a group and typed /start in the group after that the getUpdates URL displayed the chat_id

@f0o

This comment has been minimized.

Show comment
Hide comment
@f0o

f0o Dec 15, 2015

Member

Fair, can hack something together on that basis

Member

f0o commented Dec 15, 2015

Fair, can hack something together on that basis

@snis

This comment has been minimized.

Show comment
Hide comment
@snis

snis May 6, 2016

For future reference and or plugin:

LibreNMS alert via Telegram bot

  1. First you must create a telegram account and add BotFather to you list. To do this click on the following url: https://telegram.me/botfather
  2. Generate a new bot with the command "/newbot" BotFather is then asking for a username and a normal name. After that your bot is created and you get a HTTP token. (for more options for your bot type "/help")
  3. Add your bot to telegram with the following url:
    http://telegram.me/<botname>
    and send some text to the bot.
  4. Now copy your token code and go to the following page in chrome:
    https://api.telegram.org/bot<tokencode>/getUpdates
  5. You see a json code with the message you sent to the bot. Copy the Chat id. In this example that is “-9787468”
    "message":{"message_id":7,"from":"id":656556,"first_name":"Joo","last_name":"Doo","username":"JohnDoo"},"chat":{"id":-9787468,"title":"Telegram Group"},"date":1435216924,"text":"Hi"}}]}
  6. Now create a new "API URL" in LibreNMS (Global Settings -> Alerting Settings -> API transport). Put the following url in the box:
    https://api.telegram.org/bot<tokencode>/sendMessage?chat_id=<chatid>&text=%title

snis commented May 6, 2016

For future reference and or plugin:

LibreNMS alert via Telegram bot

  1. First you must create a telegram account and add BotFather to you list. To do this click on the following url: https://telegram.me/botfather
  2. Generate a new bot with the command "/newbot" BotFather is then asking for a username and a normal name. After that your bot is created and you get a HTTP token. (for more options for your bot type "/help")
  3. Add your bot to telegram with the following url:
    http://telegram.me/<botname>
    and send some text to the bot.
  4. Now copy your token code and go to the following page in chrome:
    https://api.telegram.org/bot<tokencode>/getUpdates
  5. You see a json code with the message you sent to the bot. Copy the Chat id. In this example that is “-9787468”
    "message":{"message_id":7,"from":"id":656556,"first_name":"Joo","last_name":"Doo","username":"JohnDoo"},"chat":{"id":-9787468,"title":"Telegram Group"},"date":1435216924,"text":"Hi"}}]}
  6. Now create a new "API URL" in LibreNMS (Global Settings -> Alerting Settings -> API transport). Put the following url in the box:
    https://api.telegram.org/bot<tokencode>/sendMessage?chat_id=<chatid>&text=%title
@f0o

This comment has been minimized.

Show comment
Hide comment
@f0o

f0o May 6, 2016

Member

My biggest issue with Telegram as API and not as Bot is that having an API requires either the enduser to periodically update their chatid's in the config or have a cronjob doing that for them. Neither is nice.

A bot would be nicer but I lack the time and motivation to do it as I dont use telegram for this whatsoever.

PRs welcome

Member

f0o commented May 6, 2016

My biggest issue with Telegram as API and not as Bot is that having an API requires either the enduser to periodically update their chatid's in the config or have a cronjob doing that for them. Neither is nice.

A bot would be nicer but I lack the time and motivation to do it as I dont use telegram for this whatsoever.

PRs welcome

@f0o f0o removed their assignment May 6, 2016

@f0o f0o added the Help Wanted label May 6, 2016

@snis

This comment has been minimized.

Show comment
Hide comment
@snis

snis May 6, 2016

The chatid is static. Have this working setup for five months now

snis commented May 6, 2016

The chatid is static. Have this working setup for five months now

@f0o

This comment has been minimized.

Show comment
Hide comment
@f0o

f0o May 6, 2016

Member

PRs welcome :)

But from the telegram docs i thought the chat-id is dynamic and changes whenever either a chat expires or gets closed/reopened... I might be wrong though

On 6 May 2016 17:05:01 CEST, snis notifications@github.com wrote:

The chatid is static. Have this working setup for five months now


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
#2114 (comment)

Member

f0o commented May 6, 2016

PRs welcome :)

But from the telegram docs i thought the chat-id is dynamic and changes whenever either a chat expires or gets closed/reopened... I might be wrong though

On 6 May 2016 17:05:01 CEST, snis notifications@github.com wrote:

The chatid is static. Have this working setup for five months now


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
#2114 (comment)

@carson20

This comment has been minimized.

Show comment
Hide comment
@carson20

carson20 May 17, 2016

How about graph been sent by default on perticular time using telegram bot ?
something like this
https://github.com/ableev/Zabbix-in-Telegram

carson20 commented May 17, 2016

How about graph been sent by default on perticular time using telegram bot ?
something like this
https://github.com/ableev/Zabbix-in-Telegram

@f0o

This comment has been minimized.

Show comment
Hide comment
@f0o

f0o May 20, 2016

Member

PRs welcome :)

Member

f0o commented May 20, 2016

PRs welcome :)

@lock

This comment has been minimized.

Show comment
Hide comment
@lock

lock bot May 17, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed.

lock bot commented May 17, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed.

@lock lock bot locked as resolved and limited conversation to collaborators May 17, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.