New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Backward conversations #28
Comments
I didn't quite get the issue but I try to explain: class MyConversation extends Conversation {
protected ?string $step = 'askName';
public function askName(Nutgram $bot)
{
$bot->sendMessage('What is your name?');
$this->next('confirmName');
}
public function confirmName(Nutgram $bot)
{
$name = $bot->message()->text;
$bot->sendMessage("Your name is $name, right?");
$this->next('replyConfirmation');
}
public function replyConfirmation(Nutgram $bot)
{
$reply = $bot->message()->text;
if ($reply === 'yes') {
$bot->sendMessage('Nice!');
$this->end();
} else if ($reply === 'no') {
$this->askName($bot);
} else {
$bot->sendMessage('Please reply with yes or no.');
}
}
} As you can see, at any time you can call back a previous step direcly from another step, just passing the current
|
oh sorry i didn't know that every time step property from class is changing
so i have to change it manually 😅 |
On complex menus, if the update match the condition Nutgram call the last step (also do this for more one step back). Its also come handy on making forms like AskIceCream that user wants to change the previous answers before submit.
(yes its possible to create that condition on every step but for more steps and menus it takes so much duplicated code)
The text was updated successfully, but these errors were encountered: