New Telegram Action

that should be the right place (even if I never user the repo, i build OH on myself)

But you need to wait for:

  1. pull request #3848 approval by the maintainers
  2. jenkins automatically build the new package (it happens once a day, by night, not sure about that)
1 Like

Ah I didn’t know. Patience then appears to be the key :slight_smile:

I merged the change, so it ought to be in the next nightly build.

1 Like

It’s working a treat! Thanks :smiley:

1 Like

you are welcome

2 Likes

@paolo_denti i have problems getting the telegram action to work, i added the chat id and token but getting the error bot1 not defined, or whatever i write as botname in the cfg file. I have 1.8 running on Linux. No idea why it is not working here, need help.

post here your configuration (of course not the real token and chat id, change some characters)

Config
telegram:bots=bot1
telegram:bot1.chatId=xxxxxx
telegram:bot1.token=xxxxx:xxxxxxxxxxxxxxxxxxxx

Rule
rule "Send telegram with Fixed Message"
when
Item telegramTest received command
then
sendTelegram(‘bot1’,“test item changed”)
end

https://api.telegram.org/botxxxxxx:xxxxxxxxxxxxxxxx/sendMessage?chat_id=xxxxxxx&text=testChat

That url runs fine with the same config data

OK found it now, the config is something like

‘# telegram:bot2.chatId=654321’
’# telegram:bot2.token=yyyyyyyyyyy’

and i remove the # tag but not the whitespace, and with that whitespace the config seems not to be shown.

Is it possible to use telegram in console mode (like XMPP)?

help

Usage:
update - sends a status update for an item
send - sends a command for an item
status - shows the current status of an item
items [] - lists names and types of all items matching the pattern
say - Says a message through TTS on the host machine

items Light_*

Light_1_Kitchen_Center (Type=SwitchItem, State=OFF)
Light_1_Kitchen_Zone (Type=SwitchItem, State=OFF)

Ive just discovered Telegram - great work.

I came to ask a possible feature request, and i think @vgrebenschikov is asking the same/similar thing…

I’m using Telegraph in a few rules like “Check Garage Door open at 8pm” - works great, but i thought that perhaps the bot could be somehow set to ask me “Would you like to close it?” - and gives a YES/NO button…which would then activate the item to close the door…

Or… “I see you have left the house - but the back door is open… Would you like me to close it?”

Any thoughts?

It is a complicated matter for openhab users.
First of all it would require deep knowledge of telegram api (or at least of its payload types, both request and response objects)
Then a webhook must be set up in order to get and understand the incoming telegram updates (a menu answer for example). And that webhook cannot be, in my opinion, the openhab rest api with some binding, because within the binding you should parse the json telegram payload in order to take decisions in a flexible way.
So, an additional httpS (http is not allowed for webhook) capable server must be set up, getting telegram updates and calling openhab rest api.

Even just simply sending a menu is also medium complicated, it requires to prepare a json payload, not really a user matter.

And trying to hide all the details preparing some custom and specialized methods would lead to useless methods, they would not be enough flexible and therefore useful.

In general in my opinion it is a pure telegram issue that cannot be implemented within openhab and within the average competences of a user.

Anyway I will think about that, maybe I am wrong in what I am saying.

P.s. By users i mean openhab administrator of course, not the final interface users.

P.p.s. I did not previously answer to @vgrebenschikov because actually I did not understand the question.

@greg
Maybe I am actually wrong. Probably something very cool (automatic menu generation for telegram avtion, using oh as telegram webhook) can be realized … And all this hiding the telegram api remaining very flexible anyway.

@greg
I finished a short analysis. your idea is a very good one and it could it be perfectly implemented insided openhab

however there is an issue: telegram server do callbacks over https without any kind of authentication, the called url must be worldwide accessible.
and the current openhab 1.0 authentication scheme is basic (therefore not compatible) and in 2.0 not even defined.

it is not possible at the moment open just a url because the authentication is server wide.

therefore, even if the implementation could be of super high interest for everybody, it would open a full new range of interaction toward openhab, I am not going to implement it because the authentication would be either impossible or too tricky with proxies or other stuff.

implement a super cool extension but used by no one because unsafe is not an option for me, sorry about that.

paolo

Hi Paolo - thanks for looking into it anyway - fully respect your decision to not compromise on security.
Its a dream of mine to extend automation into having an assistant remind me to do certain actions etc and when i saw Telegraph bots i thought it may be an option to use…

Cheers,
Greg

@greg, I am not sure if the existing Slack integration with openHAB could be expanded upon to achieve the dialog you are looking for. Right now, you can send commands and query state from Slack to openHAB, but with some changes (see @ben_jones12’s gist here) perhaps you could use Slack as a notification system as well. So Slack would tell you: “Garage Door is open; reply ‘@slackhab send GarageDoor close’ to close it.”

@watou

your proposal can work and probably many other could do it
but @greg proposal is much more powerful.
you could get a customizable menu interface, usable by different users with different menus, without any integration (slack or whatever)

in line of principle you could give just a telegram interface to some users (the gardener goes away from the grass and he gets a menu "do i open the exit gate and turn on the alarm?"
with 2 buttons

  • yes, open the gate and turn on the alarm in 2’
  • no, i am staying here
    and without even giving full oh access/credentials (custom sitemaps on roles unfortunately do not exist)

it is a much more powerful paradigm, usable for every situation and every kind of user, also integrating authentication (the telegram binding could accept some commands just from some telegram users)

but the forced basic authentication in front of oh is a real obstacle. you need to set up something like an additional proxy (by apache for example) in order to make it usable.
and develop a binding usable just if an additional proxy is present is not a viable solution in my opinion.

@greg

I did some tests. Everything is doable.

I could add a “sendMenu” method to the telegram action with a “key” parameter (with menus defined in configuration file with key and string options)
I could create a new binding TelegramBot capable to get the answers coming from the menu and change a dedicated item value.
A rule, with change of item value, depending on the value, could take appropriate decision.

Everything looks nice and super useful

However the telegram api has a strong limitation at the moment; the menu is not defined as a key/value pair; the message passed back is just the text shown on the button. And therefore it is pretty impossible to interpret the keyboard answer. You could have YES/NO on different menus and getting back a YES does not mean a thing without an interpretation context.
And having a 001-YES, 002-YES, 003-YES on the keyboard (in order to give a meaning to the YES answer) is super ugly.

And moreover considering that the last sent menu will delete the previous shown (even if not answered) and that the answer is not synchronous with menus sent, an exact answer identification, not just by caption, is pretty necessary.

If and when Telegram will add “keyed menus” this option will be useful; at the moment it could be not very effective.

Thanks again for looking into this.
Is what you need from the telegram a feature in their “requests”? if not any you want to add it, pls let me know and ill second/+1 it to help it along.

Yes Greg, it is a “missing feature” from telegram.