Telegram-bot-sdk: Callback and Inline query button loadings

Created on 28 Sep 2017  路  14Comments  路  Source: irazasyed/telegram-bot-sdk

Here is my code :

$keyboard = Keyboard::make()
    ->inline()
    ->row(
        Keyboard::inlineButton(['text' => 'Button 1', 'callback_data' => 'this is button 1']),
        Keyboard::inlineButton(['text' => 'Button 2', 'callback_data' => 'this is another button being pressed'])
    );

$response = Telegram::sendMessage([
    'chat_id' => $some_chat_id, 
    'text' => 'Voila! Here come buttons you requested!',
    'reply_markup' => $keyboard
]);

The button works flawlessly, but if i press it, it keep showing loading for 5-15 seconds even the process have been completed.
Any help would be appreciated. Cheers!

Most helpful comment

Sorry I should clarify.

You MUST return a answerCallbackQuery to the user even if you're not going to display anything. See the highlighted text for the warning.

image

All 14 comments

I receive this behavior only in Android Telegram client. Where you receive this @yongkylie ?

@sautchenkov Android Telegram client too. I don't know how it affects for iOS phone. But it may confuse some people.

@yongkylie I did tests and web, ios and desktop clients don't have this behavior. I think this is Android Client specific problem.

I also have this problem and will search some solution.

Hello, we have the same issue on Mac OS client. Any hints on possible reason would be very useful.

Sorry I should clarify.

You MUST return a answerCallbackQuery to the user even if you're not going to display anything. See the highlighted text for the warning.

image

@yongkylie @sautchenkov @bagaiev

No feedback guys?

I resolve my problem with loading using this code:

 $update = Telegram::getWebhookUpdates();
 $query = $update->getCallbackQuery();
 $this->callback_id = $query->getId();

Telegram::answerCallbackQuery([
            'callback_query_id' => $this->callback_id
        ]);

Thanks @jonnywilliamson

@sautchenkov what is $update variable? Would you like to show the code above that?

Hi! @wedhasmara I updated my code above. Please look this.

Oh I see. Thank you so much @sautchenkov

@jonnywilliamson I should be more careful and read through all the docs before opening an issue I guess. Works pretty well with @sautchenkov code. Thanks a bunch guys! :)

I used guzzle for bot-sdk 2.2
public static function answerCallbackQuery($callback_query_id) { $client = new Client(); $client->request('GET', config('telegram.api_url') . config('telegram.bot_token') . '/answerCallbackQuery?callback_query_id='.$callback_query_id); }

@jonnywilliamson thanks sir. I never see thats message before when i open the documentation. It working properly.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

YaroslavStrigun picture YaroslavStrigun  路  4Comments

realtebo picture realtebo  路  4Comments

behnamazimi picture behnamazimi  路  3Comments

b10585 picture b10585  路  4Comments

khalilst picture khalilst  路  3Comments