How to use telegram chat bots to communicate ( with each other )?

  • Platform information:
    • Hardware: cubietruck
    • OS: Ubuntu 16.04
    • Java Runtime Environment: armv7l zulu 1.8.0
    • openHAB version: 2.5.10-1

I would like to use tasker which will be triggered by an event and should send a telegram message to OH.
The telegram message then should trigger a rule.
For this purpose I created a telegram group and 'subscribed to bots to this group.
Both both have admin privileges and read access to all messages in this group.

When I send a message via the page I can see that the messages are received in the group ( using the telegram app on my smartphone ).
None of these two messages is received by the telegram binding item/thing.
When I use the telegram app and send message in the bot window to the other bot or to the group the message does not appear in the app nor in OH.

Sending a message with my own personal user to the group then appears in OH.
The thing setup uses the chat id of the group ( negative number ).

Do you have any advice what I need to try ?
Should it work to use curl/wget/browser to send a message on behalf of the bot by using the api ?

Is there a reason for using Telegram for this? Tasker can talk directly to the OH Android app and send a command to an Item directly without Telegram in the middle.

Beyond that I can be of no help. I’ve no experience with Telegram.

1 Like

It is not possible that a bot talks to an other telegram bot.

So you have installed the telegram binding.

Created a telegram thing

Thing telegram:telegramBot:Telegram_Bot [ chatIds="1number0", botToken="13number7:AAEtoken6j0", parseMode="Markdown" ]

Then you have items like

String telegramMessage "Telegram Message" { channel = "telegram:telegramBot:Telegram_Bot:lastMessageText" }

String telegramReplyId "Telegram Reply Id" { channel = "telegram:telegramBot:Telegram_Bot:replyId" }

You read the binding note

Notice: By default your bot will only receive messages that either start with the ‘/’ symbol or mention the bot by username (or if you talk to it directly). However, if you add your bot to a group you must either talk to BotFather and send the command “/setprivacy” and then disable it or you give admin rights to your bot in that group. Otherwise you will not be able to receive those messages.

Can you send messages to openHAB using the telegram app?

Yes, I defined a bot, the items exactly as you described it. I also used the privacy setting to make the chat content visible for the bots and yes the bots receive messages from the telegram app.
What I wanted to do is to use the webapi to send a message ( from one bot ) to a group chat and let the ( OH ) bot receive the message.
According to telegram FAQs this ( bot talking to a bot ) seems not to be possible by design.