After reading source code for botman telegram driver i found that keyboard not supported for botman/driver-telegram ^1.6 . (or i not have idea how it work outofbox)
I solve this by override all driver code. Like this.
Copy all original code to my own CustomTelegramDriver.php and load it
DriverManager::loadDriver(CustomTelegramDriver::class);
Then in buildServicePayload method i check reply_markup
key in $additionalParameters
like this:
if ($message instanceof Question) {
self::getLogger()->info("message instanceoff Question", ["custom_telegram_driver"]);
$parameters['text'] = $message->getText();
// Where reply_markup passed from additionalParameters!
// this line of code is my fix and it get to work keyboard
if(isset($additionalParameters['reply_markup'])) {
$parameters['reply_markup'] = $additionalParameters['reply_markup'];
} else {
$parameters['reply_markup'] = json_encode([
'inline_keyboard' => $this->convertQuestion($message)
], true);
}
}
then in my bot code in ask i passed this
$keyboard = Keyboard::create(Keyboard::TYPE_KEYBOARD)
->oneTimeKeyboard()
->addRow(KeyboardButton::create(OnboardingConversation::translate("btn_lang_en", "en"))->callbackData('en'))
->addRow(KeyboardButton::create(OnboardingConversation::translate("btn_lang_ru", "en"))->callbackData('ru'))
->toArray();
And in my ask code
$question = Question::create("test");
$this->ask($question, function (Answer $answer) {
// some stuff
}, $keyboard);