Reputation: 31
in telegram bot (php) how can identify relation between message that send to user and user write answer ? how can I identify if it is the answer of this text in telegram bot code like this first I put 5 button and when user press each button user must enter the text i want identify it is the answer of specific button. how can I identify this with php?
Upvotes: 2
Views: 1614
Reputation: 452
When user select one question from bot menu , store it in database. for example user select 'question2':
storLastPlace($userId,'question2');
When comes new message to bot from this user , check it last place and do proper action ex:
$lastPlace = getLastPlace($userId);
if($lastPlace){
switch ($lastPlace) {
case 'question1':
// recive answer1
break;
case 'question2':
// recive answer1
break;
}
}
Upvotes: 4
Reputation: 285
If I understood your problem correctly, you can make a table/collection in your Database and save the last sent message with Telegram ID of the user, it can be like this:
{
userID : xxxxxx
lastMessageSent : Button1
}
Upvotes: 1