63 lines
2.0 KiB
PHP
63 lines
2.0 KiB
PHP
<?php
|
|
|
|
// namespace App\Conversations;
|
|
namespace App\Controllers\Chatbot;
|
|
|
|
use BotMan\BotMan\Messages\Conversations\Conversation;
|
|
use BotMan\BotMan\Messages\Outgoing\Question;
|
|
use BotMan\BotMan\Messages\Outgoing\Actions\Button;
|
|
|
|
use App\Helpers\ChatbotHelper;
|
|
|
|
class policyConversation extends Conversation
|
|
{
|
|
|
|
|
|
public function run()
|
|
{
|
|
$this->showNewPolicy();
|
|
}
|
|
|
|
protected function showNewPolicy()
|
|
{
|
|
$question = Question::create("Choose Policy Type:")
|
|
->addButtons([
|
|
Button::create("🏍️ 2 Wheeler")->value("2_wheeler"),
|
|
Button::create("🚗 4 Wheeler")->value("4_wheeler"),
|
|
Button::create("🩺 Medical Claim")->value("mediclaim"),
|
|
Button::create("◀️ Go Back")->value("go_back"),
|
|
]);
|
|
|
|
$this->bot->ask($question, function ($answer) {
|
|
$path = $this->bot->userStorage()->get('path');
|
|
array_push($path,
|
|
$answer->getValue()
|
|
);
|
|
$this->bot->userStorage()->save([
|
|
'path' => $path
|
|
]);log_message("error","Path ".json_encode($path));
|
|
switch ($answer->getValue()) {
|
|
case "2_wheeler":
|
|
// $cityName = $response->getText();
|
|
$this->bot->startConversation(new twoWheelerOptionsConversations());
|
|
break;
|
|
case "4_wheeler":
|
|
$this->bot->startConversation(new fourWheelerOptionsConversations());
|
|
break;
|
|
case "mediclaim":
|
|
$this->bot->startConversation(new medicalClaimOptionConversations());
|
|
|
|
break;
|
|
case "go_back":
|
|
$this->bot->startConversation(new MainMenuConversation());
|
|
break;
|
|
default:
|
|
$this->say("Invalid selection. Please choose an option.");
|
|
$this->showHospitalMenu();
|
|
break;
|
|
}
|
|
});
|
|
}
|
|
|
|
}
|