Send a message with a custom keyboard
In this example I created a keyboard with 2 keys on the first row and 3 keys on the second row.
This is not the only possible configuration, you can create your custom layout simply creating an array of rows (and a row is a String array) and create your ReplyKeyboardMarkup.
Once created your ReplyKeyboardMarkup it will automatically create a keyboard with your desired layout.
Here is the code:
public static void main(String[] args) throws GettingUpdatesException, IOException { String yourToken = "YOUR TOKEN"; TelegramBot b = new TelegramBot(yourToken); String[][] keys = new String[2][]; keys[0] = new String[2]; keys[0][0] = "Top-left"; keys[0][1] = "Top-right"; keys[1] = new String[3]; keys[1][0] = "Bottom-left"; keys[1][1] = "Bottom-center"; keys[1][2] = "Bottom-right"; ReplyKeyboardMarkup reply_markup = new ReplyKeyboardMarkup(keys); b.sendMessage("chat_id", "Custom keyboard Message", null, false, false, 0, reply_markup);</ul> }
This is the result:
Hi,
Great work!
Is there a way to disable this keyboard example from the bot?
If you don’t use it, it will never appear 🙂
How to ReplyKeyboardHide send message ?
Hi,
At the moment this functionality is not implemented.
Thanks for your feedback!
I’ll fix it when I’ll have some spare time, but if you need it asap you can create a pull request on github!
Bye!