I am trying to get the previous Message. First the User ist sending Message: “Search Student”. Then the Bot replies on that message with: “Enter the name of student”. Then the user has to write something and after that I would like to call a specific function.
Here is my code:
switch (message.getText()){
case "Search Student":
sendMsg(message, "Enter the name of Stunde: ");
//And somewhere here i would like to call a function that is searching for a student (I have
//already created the function)
break;
}
2
Answers
This is my solution, and it works fantastic! You simply have to check if the user had replied on message with a specific text
I have also faced such a problem recently and I have recreated this method. But I am not sure if this solution is a good one! I also believe that there is no very specific answer to this question.
The idea is to write the last action of the user/student/profile to the database by opening one table called
telegram_action
table including following columns:Your changed code:
So, I created one
createTelegramUserAction()
method to save last action as following:Note that this
createTelegramAction
method can be used for other methods as a generic method. But there is always space for improving the idea to make it more generic functions