0
votes

As i checked here the KeyboardButton object in telegram have nothing such as tag or data field. I had this implementation for keyboard of my bot:

$keyboardArray = array('Hello', 'Hi');
apiRequestJson("sendMessage", array('chat_id' => $chat_id, "text" => 'Hello', 'reply_markup' => array(
  'keyboard' => array($keyboardArray),
  'one_time_keyboard' => true,
  'resize_keyboard' => true)));

Currently pressing a keyboard button, send the label of button to my bot. I want to know are there any options for telegram keyboard, which it can send special message to bot other than label of keyboard button? For example it send 100 when I press hello, 200 when I press Hi button.

1

1 Answers

0
votes

Nope, it is not possible, these Keyboards can only send their own label. What would be possible are InlineKeyboards (see this). There you can specify callback_data, which is given to your server when the key is pressed. You could also specify a URL to be opened on button click. See documentation for InlineKeyboardButton here.