Telegram-bot-sdk: send message with inline keyboard

Created on 17 Oct 2016  路  4Comments  路  Source: irazasyed/telegram-bot-sdk

I wanna send message with inline keyboard.
can u help me to do this?

Most helpful comment

Here's an example on how to use it in 3.x:

use Telegram\Bot\Keyboard\Keyboard;
use Telegram;

$keyboard = Keyboard::make()
    ->inline()
    ->row(
        Keyboard::inlineButton(['text' => 'Test', 'callback_data' => 'data']),
        Keyboard::inlineButton(['text' => 'Btn 2', 'callback_data' => 'data_from_btn2'])
    );

$response = Telegram::sendMessage([
  'chat_id' => 'CHAT_ID', 
  'text' => 'Hello World',
  'reply_markup' => $keyboard
]);

$messageId = $response->getMessageId();

The above should work right now but in develop branch, this has been changed too. So you gotta keep an eye when it's released and upgrade your codes.

All 4 comments

Do you use with Laravel or without?

Here's an example on how to use it in 3.x:

use Telegram\Bot\Keyboard\Keyboard;
use Telegram;

$keyboard = Keyboard::make()
    ->inline()
    ->row(
        Keyboard::inlineButton(['text' => 'Test', 'callback_data' => 'data']),
        Keyboard::inlineButton(['text' => 'Btn 2', 'callback_data' => 'data_from_btn2'])
    );

$response = Telegram::sendMessage([
  'chat_id' => 'CHAT_ID', 
  'text' => 'Hello World',
  'reply_markup' => $keyboard
]);

$messageId = $response->getMessageId();

The above should work right now but in develop branch, this has been changed too. So you gotta keep an eye when it's released and upgrade your codes.

@irazasyed Can you please tell me us how to update a message with inline keyboard.
I saw for example in @vote bot, clicking at inline button update whole message and its inline keyboard to brand new one.
How they did it? Delete & resend new message with new inline keybord?
Any help appreciated

I guess, I found the answer. editMessageText is exactly what I'm looking for.
@irazasyed BTW, thanks for your great work. Waiting for version 3.0 and its documentation.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

behnamazimi picture behnamazimi  路  3Comments

b10585 picture b10585  路  4Comments

mccarlosen picture mccarlosen  路  3Comments

realtebo picture realtebo  路  4Comments

chaskayu picture chaskayu  路  4Comments