Telegram custom keyboards

Client tools or tools that can connect with Domoticz. Tools for Windows, iOS, Android, Linux etc.

Moderator: leecollings

bigpea
Posts: 91
Joined: Thursday 11 August 2016 12:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: IT
Contact:

Telegram custom keyboards

Post by bigpea »

Hi all,
I'm trying to create a custom keyboard with telegram in order to have a simple way to do more action.

Like this (detail: https://core.telegram.org/bots#keyboards):
Image

In detail if I use this link to send a message all works fine:

Code: Select all

https://api.telegram.org/botMyToken/sendMessage?chat_id=myId&text=test
But if I try to add the custom keuboard with this URL (adding only this part "&reply_markup={"keyboard":[[{%20text:%20"Si"%20}]]}"):

Code: Select all

https://api.telegram.org/botMyToken/sendMessage?chat_id=myId&text=test&reply_markup={"keyboard":[[{%20text:%20"Si"%20}]]}
I receive this error:
{"ok":false,"error_code":400,"description":"Bad Request: can't parse reply keyboard markup JSON object"}
I tryied also with serialized JSON but the result is the same.
Somebody use this function in telegram?

Thanks.
User avatar
jvdz
Posts: 2441
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Telegram custom keyboards

Post by jvdz »

You mean like this?
http://www.domoticz.com/forum/viewtopic ... enu#p52245
This is implemented in DTGBOT. ;)

Jos
bigpea
Posts: 91
Joined: Thursday 11 August 2016 12:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: IT
Contact:

Re: Telegram custom keyboards

Post by bigpea »

yes, I had seen this script, but I just wanted to have the correct url string.
But in the code you indicated I can not find the url track.
User avatar
jvdz
Posts: 2441
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Telegram custom keyboards

Post by jvdz »

There is no one single answer to your question as it depends on the functionality you want but generically this is the format i've used:

Code: Select all

reply_markup={"keyboard":[["opt 1","opt 2","opt 3"],["menu"]],"resize_keyboard":true}
The url syntax is defined in the telegram website and I've used that to develop all LUA script functions: https://core.telegram.org/bots/api#replykeyboardmarkup

There is also a version of DTGBOT available that uses the inline keyboard option.

Jos
bigpea
Posts: 91
Joined: Thursday 11 August 2016 12:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: IT
Contact:

Re: Telegram custom keyboards

Post by bigpea »

The inline version works fine, for example:
https://api.telegram.org/bot/sendMessag ... e_keyboard":[[{"text":"Visualizza spoiler!","url":"http://google.com/"}]]}

But when I try a replykeyboardmarkup, for example your url I receive this error:
{"ok":false,"error_code":400,"description":"Bad Request: inline keyboard expected"}
User avatar
jvdz
Posts: 2441
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Telegram custom keyboards

Post by jvdz »

Show me the total URL (without the personal info like API key) so I can have a look please.

Jos
bigpea
Posts: 91
Joined: Thursday 11 August 2016 12:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: IT
Contact:

Re: Telegram custom keyboards

Post by bigpea »

Yes, sure, the link is:

Code: Select all

https://api.telegram.org/botToken/sendMessage?chat_id=-1&text=Choose&reply_markup={"keyboard":[[{"Yes"}],[{"No"}]]}
User avatar
jvdz
Posts: 2441
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Telegram custom keyboards

Post by jvdz »

I can't test it untill the evening, but shouldn't that be like this?:

Code: Select all

https://api.telegram.org/botToken/sendMessage?chat_id=-1&text=Choose&reply_markup={"keyboard":[["Yes"],["No"]]}
Jos
bigpea
Posts: 91
Joined: Thursday 11 August 2016 12:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: IT
Contact:

Re: Telegram custom keyboards

Post by bigpea »

The message is sent but the keyboard not appear.
User avatar
jvdz
Posts: 2441
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Telegram custom keyboards

Post by jvdz »

Just tried your modified command from my previous post with only putting in my bottoken and chat_ID and it shows the Yes/No buttons nicely underneath each other.
Not sure why it doesn't for you.

Jos
bigpea
Posts: 91
Joined: Thursday 11 August 2016 12:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: IT
Contact:

Re: Telegram custom keyboards

Post by bigpea »

I have am IPhone, and you? Maine the problem is this.
User avatar
jvdz
Posts: 2441
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Telegram custom keyboards

Post by jvdz »

I opened the URL to send the telegram in a Chrome browser on my win10 laptop and run Telegram on multiple platforms, but honestly that shouldn't really matter I would think.

Jos
bigpea
Posts: 91
Joined: Thursday 11 August 2016 12:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: IT
Contact:

Re: Telegram custom keyboards

Post by bigpea »

Mmhh ok I will try tomorrow. Thanks for your time.
hoeby
Posts: 531
Joined: Saturday 02 June 2018 11:05
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.1
Location: Echt, Netherlands
Contact:

Re: Telegram custom keyboards

Post by hoeby »

Sorry for putting up this older thread.
But i want to use the HTTP api

I know that there is dtgbot.
But i don't get it to work. I find it to difficult to setup. Can't find a way to get it to work.
Maybe someone has a great manual, how to do this step by step.

I the meantime i have taken another route.
The route with ESP8266 with telegram. I got it working. But would love to use the option reply keyboard.
But on the esp it didn't work. So i went looking for a HTTP api, just to test and see. But the api also doesn't work and gives this error back

Code: Select all

{"ok":false,"error_code":400,"description":"Bad Request: inline keyboard expected"}
I used this line and filled in the token and chat id

Code: Select all

https://api.telegram.org/botToken/sendMessage?chat_id=-1&text=Choose&reply_markup={"keyboard":[["Yes"],["No"]]}
Is the reply keyboard not supported anymore?
I am sending it to a telegram group, could that be the problem. That with groups this function isn't supported?
Thin-client --> Docker Domoticz main environment
Pi3A+ --> Google home (GAssistPi)
Pi3B+ --> Docker (P1monitor, Domoticz test environment, Ubiquity controller)
User avatar
jvdz
Posts: 2441
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Telegram custom keyboards

Post by jvdz »

hoeby wrote: Saturday 15 August 2020 10:42 I know that there is dtgbot.
But i don't get it to work. I find it to difficult to setup. Can't find a way to get it to work.
Maybe someone has a great manual, how to do this step by step.
I am sure I can help you with that. :)
hoeby wrote: Saturday 15 August 2020 10:42 I the meantime i have taken another route.
The route with ESP8266 with telegram. I got it working. But would love to use the option reply keyboard.
But on the esp it didn't work. So i went looking for a HTTP api, just to test and see. But the api also doesn't work and gives this error back

Code: Select all

{"ok":false,"error_code":400,"description":"Bad Request: inline keyboard expected"}
I used this line and filled in the token and chat id

Code: Select all

https://api.telegram.org/botToken/sendMessage?chat_id=-1&text=Choose&reply_markup={"keyboard":[["Yes"],["No"]]}
Is the reply keyboard not supported anymore?
I am sending it to a telegram group, could that be the problem. That with groups this function isn't supported?
That url works fine for me when I use my ID or a test group. When using it with a group you need to check the privacy mode for the group: (From the Telegram FAQ page https://core.telegram.org/bots/faq#will ... he-bot-api )
What messages will my bot get?
1. All bots, regardless of settings, will receive:

All service messages.
All messages from private chats with users.
All messages from channels where they are a member.
2. Bot admins and bots with privacy mode disabled will receive all messages except messages sent by other bots.

3. Bots with privacy mode enabled will receive:
Commands explicitly meant for them (e.g., /command@this_bot).
General commands from users (e.g. /start) if the bot was the last bot to send a message to the group.
Messages sent via this bot.
Replies to any messages implicitly or explicitly meant for this bot.
Note that each particular message can only be available to one privacy-enabled bot at a time, i.e., a reply to bot A containing an explicit command for bot B or sent via bot C will only be available to bot A. Replies have the highest
Jos
hoeby
Posts: 531
Joined: Saturday 02 June 2018 11:05
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.1
Location: Echt, Netherlands
Contact:

Re: Telegram custom keyboards

Post by hoeby »

I enabled and disabled the privacy mode for group.
Do i have to wait a X-periode?

Because in both privacy modes it doesn't work, still the same error returns
Thin-client --> Docker Domoticz main environment
Pi3A+ --> Google home (GAssistPi)
Pi3B+ --> Docker (P1monitor, Domoticz test environment, Ubiquity controller)
User avatar
jvdz
Posts: 2441
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Telegram custom keyboards

Post by jvdz »

As far as I remember setting the group privacy is a onetime thing working immediately....but it is a long time ago I did that. :)
Have you tried the url from the browser just to see what happens? That is what I did and is working fine with my BOTTOKEN & GroupID.
Does the URL work with your own chat_id?

Jos
hoeby
Posts: 531
Joined: Saturday 02 June 2018 11:05
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.1
Location: Echt, Netherlands
Contact:

Re: Telegram custom keyboards

Post by hoeby »

at this moment i only have the group id, not a non group id. With a minus in front.
With that it doesn't work. When i post the url in the webbrowser i get the response that it expects an inline command
Thin-client --> Docker Domoticz main environment
Pi3A+ --> Google home (GAssistPi)
Pi3B+ --> Docker (P1monitor, Domoticz test environment, Ubiquity controller)
User avatar
jvdz
Posts: 2441
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Telegram custom keyboards

Post by jvdz »

Nah ... you do have your own phone's chat_id or else you couldn't use Telegram on your phone. ;)
hoeby
Posts: 531
Joined: Saturday 02 June 2018 11:05
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.1
Location: Echt, Netherlands
Contact:

Re: Telegram custom keyboards

Post by hoeby »

Yes my chat-id i have.
But simple change the chat-id in the url didn't work.

Do you also know the url api for inline keyboard?
Thin-client --> Docker Domoticz main environment
Pi3A+ --> Google home (GAssistPi)
Pi3B+ --> Docker (P1monitor, Domoticz test environment, Ubiquity controller)
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest