telegram-bot-sdk
telegram-bot-sdk copied to clipboard
How to get reply_to_message for sendMessage?
$telegram = new Api(Telegram::getAccessToken()); $update = Telegram::getWebhookUpdates(); $chat_id = $update->getMessage()->getChat()->getId();
$replyMarkup = array(
'force_reply' => true
);
$encodedMarkup = json_encode($replyMarkup);
$response = $telegram->sendMessage([
'chat_id' => $chat_id,
'text' => 'Enter your name , please?',
'reply_markup' => $encodedMarkup
]);
// this gives me entered command, not name $text = $update->getMessage()->getText();
$this->replyWithMessage(['text' => 'Hello, ' . $text]);
Hi @sanzharanarbay you can check if ther's any 'reply_to_message' in the response from user like the code below.
public function commandHandlerWebHook()
{
$updates = Telegram::commandsHandler(true);
$chat_id = $updates->getChat()->getId();
// get Reply_to_message
if(array_key_exists('reply_to_message', $updates['message'])) {
Telegram::sendMessage(['chat_id' => $chat_id, 'text' => 'Hello ' . $updates['message']['text']]);
}
return 'ok';
}
you can put the code in your webhook route. It's work fine.