Telegram custom keyboards

Client tools or tools that can connect with Domoticz. Tools for Windows, iOS, Android, Linux etc.
Post Reply
bigpea
Posts: 121
Joined: Thursday 11 August 2016 12:30
Target OS: Raspberry Pi
Domoticz version:
Location: IT
Contact:

Telegram custom keyboards

Post by bigpea » Tuesday 17 October 2017 16:29

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: 1464
Joined: Tuesday 30 December 2014 20:25
Target OS: Raspberry Pi
Domoticz version: Stable
Location: Westland/Netherlands
Contact:

Re: Telegram custom keyboards

Post by jvdz » Tuesday 17 October 2017 16:43

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

Jos

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

Re: Telegram custom keyboards

Post by bigpea » Tuesday 17 October 2017 17:20

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: 1464
Joined: Tuesday 30 December 2014 20:25
Target OS: Raspberry Pi
Domoticz version: Stable
Location: Westland/Netherlands
Contact:

Re: Telegram custom keyboards

Post by jvdz » Tuesday 17 October 2017 17:48

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: 121
Joined: Thursday 11 August 2016 12:30
Target OS: Raspberry Pi
Domoticz version:
Location: IT
Contact:

Re: Telegram custom keyboards

Post by bigpea » Tuesday 17 October 2017 17:55

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: 1464
Joined: Tuesday 30 December 2014 20:25
Target OS: Raspberry Pi
Domoticz version: Stable
Location: Westland/Netherlands
Contact:

Re: Telegram custom keyboards

Post by jvdz » Tuesday 17 October 2017 18:17

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

Jos

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

Re: Telegram custom keyboards

Post by bigpea » Wednesday 18 October 2017 9:34

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: 1464
Joined: Tuesday 30 December 2014 20:25
Target OS: Raspberry Pi
Domoticz version: Stable
Location: Westland/Netherlands
Contact:

Re: Telegram custom keyboards

Post by jvdz » Wednesday 18 October 2017 9:39

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: 121
Joined: Thursday 11 August 2016 12:30
Target OS: Raspberry Pi
Domoticz version:
Location: IT
Contact:

Re: Telegram custom keyboards

Post by bigpea » Wednesday 18 October 2017 10:15

The message is sent but the keyboard not appear.

User avatar
jvdz
Posts: 1464
Joined: Tuesday 30 December 2014 20:25
Target OS: Raspberry Pi
Domoticz version: Stable
Location: Westland/Netherlands
Contact:

Re: Telegram custom keyboards

Post by jvdz » Wednesday 18 October 2017 19:33

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: 121
Joined: Thursday 11 August 2016 12:30
Target OS: Raspberry Pi
Domoticz version:
Location: IT
Contact:

Re: Telegram custom keyboards

Post by bigpea » Thursday 19 October 2017 19:10

I have am IPhone, and you? Maine the problem is this.

User avatar
jvdz
Posts: 1464
Joined: Tuesday 30 December 2014 20:25
Target OS: Raspberry Pi
Domoticz version: Stable
Location: Westland/Netherlands
Contact:

Re: Telegram custom keyboards

Post by jvdz » Thursday 19 October 2017 19:36

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: 121
Joined: Thursday 11 August 2016 12:30
Target OS: Raspberry Pi
Domoticz version:
Location: IT
Contact:

Re: Telegram custom keyboards

Post by bigpea » Thursday 19 October 2017 21:09

Mmhh ok I will try tomorrow. Thanks for your time.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests