Answer the question
In order to leave comments, you need to log in
Implementation of nested logic of chat bot vk in php?
Hello.
I decided to start learning how to build chatbots for self-development. I came up with this problem. The user writes to the community, a message is returned to him where he is asked to indicate a number in order to go to a specific question. When the user enters a number, another message arrives where a choice of numbers is also provided. When the user enters a number here, the answer is returned accordingly.
I'm having difficulty implementing the last step. As I see it, the php script is constantly restarted on the server when accessed and does not save the value of the variable in order to build the correct logic.
Code snippet:
case CALLBACK_API_EVENT_MESSAGE_NEW:
$msg = $event['object']['text'];
if (!isset($isChecked)){
$isChecked = '';
}
if ($msg == '1'){
$isChecked = 'Donate';
_callback_handleMessageNew($event['object'],$isChecked,0);
}
else if ($isChecked == 'Donate' && $msg == '1'){
_callback_handleMessageNew($event['object'],$isChecked,$msg);
}
if ($msg == '0'){
unset($isChecked);
_callback_handleMessageNew($event['object'], '', 0);
_callback_handleMessageNew($event['object'], '', 0);
}
break;
What is the correct way to make it store the value of $isChecked and go to the condition section $isChecked == 'Donate' && $msg == '1'
Thank you.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question