The event onConversation fires, but nothing comes to the user. I tried to fix the error, but the message has not send. All other bot`s functions are working fine.
Please tell me where is the error and how can i fix it.
$bot = new Bot(['token' => $apiKey]);
$bot
->onConversation(function ($event) use ($bot, $botSender, $log ) {
$log->info('onConversation ' . var_export($event, true));
$context = $event->getContext();
if ($context != "" && $context != null) {
add_with_referral($event->getSender()->getId(), $event->getSender()->getName(), $context);
} else {
add_user($event->getSender()->getId(), $event->getSender()->getName(), $log);
}
return (new \Viber\Api\Message\Text)
->setSender($botSender)
->setText("Can i help you?");
})
I use SDK Bogdaan/viber-bot
Нашел решение. Удаляем стандартное событие bot->onConversation(). В самое начало файла bot.php пишем вот этот код: