I was using the Telegram Action to send Messages from one bot to multiple chats individually.
But now I’d like to use the “Query” function to get responses to those messages.
I installed the Telegram-Binding and edited the telegram.things fire, I created:
chatid1, chatid2 and bottoken were changed out with my peripherals
Now, in the `telegram.rules`-file, I would like to send my query to only one of those chat-ids
telegram.rules
rule "dev_switch001"
when
Item dev_switch001 changed
then
getActions("telegram","telegram:telegramBot:telegram001").sendTelegramQuery("Test Question", "Reply_Lights", "Yes", "No")
end
This will send the query to both chatid1 and chatid2
How can I adress the specific chat-id from the .things in my .rules?
but all those examples lead into sending the query to both given chat-ids
I also tried to split the two chat-ids into two different things. But the openhab-log tells me to not create two things out of one binding.
So the main goal is to address chat1 with e.g. telegram:telegramBot:telegram001:chat1 and chat2 with telegram:telegramBot:telegram001:chat2
I dont think that no one else has tried to send separate queries to different telegram-chats yet.
Have a play with it. Using your existing Thing with its list of chatids create and link Items to the lastMessageText and chatid channels. See what you get when a message is sent.
But this would get me the chatId, replyId and lastMessageText of the button pressed or message sent by the Telegram-user.
My problem starts with providing the user with the following buttons, called “query”:
rule "dev_switch001"
when
Item dev_switch001 changed
then
getActions("telegram","telegram:telegramBot:telegram001").sendTelegramQuery("Test Question", "Reply_Lights", "Yes", "No")
end
which, for right now, results in the following chat for both “chatid1” and “chatid2”
I just want to be able to descide, which chatId(s) the rule should send it to.
Okay, so what happens when you follow the example “Actions to send messages to a particular chat” and specify one chatid in your Action, as the first parameter?
the parameter for the Query is missing in the official documentation.
The Soution:
rule "dev_switch001"
when
Item dev_switch001 changed
then
getActions("telegram","telegram:telegramBot:telegram001").sendTelegramQuery(chat_id_as_long, "Test Question", "Reply_Lights", "Yes", "No")
end
Be useful to show how you created a Long variable - not common in rules.
Might be worth raising a github for group -chatid (if that is a sensible thing to do in this telegram usage) for an enhancement. I guess it only needs to recognize a negative number.