telegram-bot-sdk: Keyboard not work (webhook)
Hi, first of all thank you very much for your great work.
I have a problem sending a message with an options keyboard. Selecting an option displays a wait icon. The application does not receive the callback of the selected option.
My settings are as follows:
Laravel: 6.18.8 telegram-bot-skk: 3.1.0
File web.php
Route::post('/bot', function () {
Telegram::commandsHandler(true);
return 'ok';
});
Config file telegram.php
'bot_token' => env('TELEGRAM_BOT_TOKEN', 'YOUR-BOT-TOKEN'),
'async_requests' => env('TELEGRAM_ASYNC_REQUESTS', false),
'http_client_handler' => null,
'commands' => [
Telegram\Bot\Commands\HelpCommand::class,
ResumenDiarioCommand::class,
BuscarCommand::class,
],
File MyCustomCommand.php
public function handle()
{
$update = $this->telegram->getWebhookUpdate();
Log::info('handle');
Log::info($update);
if ($update->isType('callback_query')) {
Log::info('...is callback');
} else {
Log::info('show keyboard...');
$keyboard = Keyboard::make()
->inline()
->row(
Keyboard::inlineButton(['text' => 'DOE', 'callback_data' => 'doe']),
Keyboard::inlineButton(['text' => 'BOE', 'callback_data' => 'boe'])
);
$this->replyWithMessage([
'chat_id' => $this->dataRequest->chat()->id(),
'text' => 'Select',
'reply_markup' => $keyboard
]);
}
}
also, I have configured a connection with Ngrok.
When the buttons are displayed, the following appears … and nothing happens.
I’ve reviewed a lot of documentation and issues but can’t find a solution. Thank you very much for your time.
A greeting.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 19
Where you have put the code? at routes/web.php ???
How i handle it:
if anybody else stumbles upon the issue of non-working buttons, please check this answer https://stackoverflow.com/questions/62876048/telegram-inline-keyboard-button-not-working basically, revoke your token and try again. pavel durov says no.
Do not forget to answer callback query
in your route web.php