1
votes

I want to run a support telegram bot, that user send message to bot and bot send it to admin's account. And when admin replied a message it will send it to user.

$telegram = new telegram(TOKEN);

$result =  $telegram->recivedText();

$userid = $result->message->from->id;
$text   = $result->message->text;

if ($userid != '665467300' )
{
    $telegram->sendMessage('665467300',$text);
}
else 
{
    $userid = $result->message->reply_to_message->from->id;
    $text   = $result->message->text;
    $telegram->sendMessage($userid,$text);
}

but the problem is here the "else" doesn't work and don't send a message after reply to user.

1
have you checked the value of $result->message->reply_to_message->from->id ? It looks like to me it will be the id of the bot, instead of the original user's - William Chong
You should use forward instead of send new one - Sean

1 Answers

0
votes

You'd better save the User's ChatID and the message's MessageID in a DataBase or File. and then you should make the bot forward the user's message to you.

After that when the Admin(You) replies to the message that bot has sent you can find the original sender of it using its MessageID then you can force the bot to answer it.