Display menu in a Telegram bot with PHP when respond to a message

Viewed 392

I am using PHP and Heroku for a Telegram bot. I have seen other questions but they are mostly using frameworks, and I am not using any framework

This is a part of the code that I am using to reply a simple text to the user:


                    case '/whoami':
                {
                    $_text = "Your ID: ".$user_id;
                    $this->sendMessage([
                        'chat_id' => $chat_id,
                        'text' => $_text
                    ]);
                    break;
                }

How can I respond by displaying a menu and not a text message? Should the $_text be in a certain format or structure?

UPDATE : The code bellow worked for me

          $replyMarkup = array(
              'keyboard' => array(
                  array("A", "B")
              )
          );
          $encodedMarkup = json_encode($replyMarkup);
          $this->sendMessage([
              'chat_id' => $chat_id,
              'reply_markup' => $encodedMarkup,
              'text' => $content
          ]);

Now in addition to the text content it also brings up a menu for the user on the Telegram app.

0 Answers
Related