laraveltelegramtelegram-botbotman

Telegram bot inline keyboard disappeared after first click


I'm developing a telegram bot via Botman which displays telegram inline keyboard with callback mode. After receiving callback_query from telegram, I will respond with answerCallbackQuery which works just fine for the first time.

The problem is that after first click on the callback button, the button will disappear from the message.

The button remains appeared until the telegram's callback_query request execution finished on the bot server. After putting sleep(10) on bot's server, the button disappeared after 10 seconds.

The Botman Handler code:


$botman->hears('/inline', function (BotMan $bot) {
    $bot->reply(
        "Inline Keyboard Message",
        Keyboard::create()
            ->type(Keyboard::TYPE_INLINE)
            ->addRow(KeyboardButton::create("callback")->callbackData("callback"))
            ->oneTimeKeyboard(false)
            ->toArray()
    );
});


$botman->hears('callback', function (Botman $bot) {
    $callback = Request::input('callback_query.id');

    $bot->sendRequest('answerCallbackQuery', [
        'callback_query_id' => $callback,
        'text' => 'Message Received',
        'show_alert' => true,
    ]);
    
    sleep(10);
});

I even tried to update keyboards after sending answerCallbackQuery via editMessageReplyMarkup method. Even though the buttons get updated but they still disappeared after request execution finished.


Solution

  • The problem solved by setting hideInlineKeyboard config under telegram configuration entry. This configuration was not documented or existed on example telegram configuration file in botman package, So I wasn't aware of it.

    Final botman configuration file:

    return [
        'telegram' => [
            'token' => env('TELEGRAM_BOT_TOKEN'),
    
            'hideInlineKeyboard' => false,
        ],
    ];