0

I want to make a bot that responds to my message on Telegram.

In fact, the bot I wrote responds to me, but it does not respond by quoting my message.

What do I need to do in my PHP file so that my Telegram bot replies to my message in a quote?

This is my Lowercase Converter Bot's code:

<?php

$website = 'https://api.telegram.org/bot{API}/';
$content = file_get_contents("php://input");
$update = json_decode($content, true);

if (isset($update["message"])){

    $chatID = $update["message"]["chat"]["id"];
    $text = $update["message"]["text"];

    if ( $text == '/start' ) {
        // send welcome message
        file_get_contents($website."sendMessage?chat_id=".$chatID."&text=Send your Text for Converting to Lowercase");
    }else{

    $text = mb_strtolower($text,"UTF-8");
    file_get_contents($website."sendMessage?chat_id=".$chatID."&text=$text");

        }
    }

?>

1 Answers1

1

You have to specify the reply_to_message_id parameter with the message_id of the message you sent to the bot in the sendMessage request.

<?php

$website = 'https://api.telegram.org/bot{API}/';
$content = file_get_contents("php://input");
$update = json_decode($content, true);

if (isset($update["message"])) {

  $chatID = $update["message"]["chat"]["id"];
  $text = $update["message"]["text"];
  $message_id = $update["message"]["message_id"];

  if ($text == '/start') {
    // send welcome message
    file_get_contents($website . "sendMessage?chat_id=" . $chatID . "&text=Send your Text for Converting to Lowercase");
  } else {

    $text = mb_strtolower($text, "UTF-8");
    file_get_contents($website . "sendMessage?chat_id=" . $chatID . "&text=$text&reply_to_message_id=$message_id");
  }
}

?>



GioIacca9
  • 406
  • 4
  • 8