Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev
This commit is contained in:
commit
fe02b2b1a9
@ -17,7 +17,8 @@ class EcardDownloadConversation extends Conversation
|
||||
|
||||
protected function showEcardMenu()
|
||||
{
|
||||
$policy_list = ChatbotHelper::getListOfPolicies();
|
||||
$chat_session_info = get_chatbot_session_info();
|
||||
$policy_list = ChatbotHelper::getListOfPolicies($chat_session_info);
|
||||
$buttons = [];
|
||||
$question = 'Choose Policy to Download Ecard:';
|
||||
if(is_array($policy_list) && count($policy_list))
|
||||
@ -41,7 +42,8 @@ class EcardDownloadConversation extends Conversation
|
||||
->addButtons($buttons);
|
||||
|
||||
$this->bot->ask($question, function ($answer) {
|
||||
// print_r($answer->getValue());die();
|
||||
$selectedOption = $answer->getText();
|
||||
$this->say("You have selected {$selectedOption}");
|
||||
switch ($answer->getValue()) {
|
||||
case "go_back":
|
||||
$this->bot->startConversation(new MainMenuConversation());
|
||||
|
||||
@ -21,6 +21,7 @@ class MainMenuConversation extends Conversation
|
||||
|
||||
public function run()
|
||||
{
|
||||
$this->bot->userStorage()->delete();
|
||||
$this->bot->types(); // Typing indicator for the first message
|
||||
sleep(0.5); // Delay
|
||||
$this->showMainMenu();
|
||||
@ -32,7 +33,9 @@ class MainMenuConversation extends Conversation
|
||||
foreach ($this->buttonsData as $key => $data) {
|
||||
$buttons[] = Button::create($data['response_text'])->value($key);
|
||||
}
|
||||
|
||||
$this->bot->userStorage()->save([
|
||||
'path' => []
|
||||
]);
|
||||
$question = Question::create("Please choose an option:")->addButtons($buttons);
|
||||
$temp = $this->buttonsData;
|
||||
$this->bot->ask($question, function ($answer) use( $temp ){
|
||||
@ -46,13 +49,23 @@ class MainMenuConversation extends Conversation
|
||||
if (!$answer->isInteractiveMessageReply()) {
|
||||
$user_reponse = null;
|
||||
}
|
||||
// Get just the existing path array
|
||||
$path = $this->bot->userStorage()->get('path') ?? [];
|
||||
|
||||
// Add new value
|
||||
array_push($path, $answer->getValue());
|
||||
|
||||
// Save ONLY the path back
|
||||
$this->bot->userStorage()->save([
|
||||
'path' => $path
|
||||
]);
|
||||
|
||||
switch ($user_reponse) {
|
||||
|
||||
case "ecard_download":
|
||||
$this->bot->startConversation(new EcardDownloadConversation());
|
||||
break;
|
||||
case "network_hospital":
|
||||
log_message('error', 'Network Hospital clicked');
|
||||
$this->bot->startConversation(new NetworkHospitalConversation());
|
||||
break;
|
||||
case "reimbursement_claim":
|
||||
@ -63,7 +76,7 @@ class MainMenuConversation extends Conversation
|
||||
break;
|
||||
case "new_policy":
|
||||
case "renew_policy":
|
||||
$this->bot->startConversation(new PolicyConversation());
|
||||
$this->bot->startConversation(new policyConversation());
|
||||
break;
|
||||
default:
|
||||
$this->say("Invalid selection. Please choose an option.");
|
||||
|
||||
@ -52,6 +52,13 @@ class NetworkHospitalConversation extends Conversation
|
||||
// });
|
||||
|
||||
$this->bot->ask($question, function ($answer) {
|
||||
$path = $this->bot->userStorage()->get('path');
|
||||
array_push($path,
|
||||
$answer->getValue()
|
||||
);
|
||||
$this->bot->userStorage()->save([
|
||||
'path' => $path
|
||||
]);
|
||||
switch ($answer->getValue()) {
|
||||
case is_string($answer->getValue()) && is_array(explode('#',$answer->getValue())) && count((explode('#',$answer->getValue()))) == 2:
|
||||
|
||||
@ -74,7 +81,7 @@ class NetworkHospitalConversation extends Conversation
|
||||
break;
|
||||
default:
|
||||
$this->say("Invalid selection. Please choose an option.");
|
||||
$this->bot->startConversation(new EcardDownloadConversation());
|
||||
$this->bot->startConversation(new NetworkHospitalConversation());
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
@ -20,7 +20,8 @@ class ReimbursementClaimProcessConversation extends Conversation
|
||||
|
||||
protected function claimProcess()
|
||||
{
|
||||
$res = ChatbotHelper::sendReimbursementProcessOverMail();
|
||||
$chat_session_info = get_chatbot_session_info();
|
||||
$res = ChatbotHelper::sendReimbursementProcessOverMail($chat_session_info);
|
||||
if($res == true)
|
||||
{
|
||||
$this->say("Reimbursement process shared over your registered mail...!");
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
// namespace App\Conversations;
|
||||
namespace App\Controllers\Chatbot;
|
||||
use App\Helpers\ChatbotHelper;
|
||||
|
||||
use BotMan\BotMan\Messages\Conversations\Conversation;
|
||||
use BotMan\BotMan\Messages\Outgoing\Question;
|
||||
@ -19,29 +20,19 @@ class ReimbursementClaimStatusConversation extends Conversation
|
||||
|
||||
protected function claimStatus()
|
||||
{
|
||||
$question = Question::create("Do you Need Anything Else ?")
|
||||
->addButtons([
|
||||
Button::create("🔹 Yes I need some more Help")->value("yes"),
|
||||
Button::create("🔹 No, Thank You")->value("no"),
|
||||
// Button::create("◀️ Go Back")->value("go_back"),
|
||||
]);
|
||||
$this->say("Fetching Status please wait ...");
|
||||
|
||||
$this->bot->ask($question, function ($answer) {
|
||||
switch ($answer->getValue()) {
|
||||
case "yes":
|
||||
|
||||
$this->say("Sure, How can I help you ");
|
||||
$this->bot->startConversation(new MainMenuConversation());
|
||||
break;
|
||||
case "no":
|
||||
$this->say("Thank you for your time! If you need anything else, feel free to reach out. Goodbye!");
|
||||
break;
|
||||
default:
|
||||
$this->say("Invalid selection. Please choose an option.");
|
||||
$this->askQuestion();
|
||||
break;
|
||||
}
|
||||
});
|
||||
$chat_session_info = get_chatbot_session_info();
|
||||
$data = ChatbotHelper::getReimbursementClaimStatus($chat_session_info);
|
||||
|
||||
$this->bot->types();
|
||||
if ($data){
|
||||
$this->say("The claim status for the claim Number {$data['claim_number']} is currently in {$data['claim_status']} status. <br> More Detailed Information is sent to your mail");
|
||||
$this->bot->startConversation(new doYouWantToContinueConversation());
|
||||
}else{
|
||||
$this->say("No Claim Raised against the user.");
|
||||
$this->bot->startConversation(new doYouWantToContinueConversation());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -11,7 +11,11 @@ use App\Helpers\ChatbotHelper;
|
||||
|
||||
class commonPolicyOptionConversations extends Conversation
|
||||
{
|
||||
|
||||
protected $buttonsData = [
|
||||
"upload_vehicle_details" => ["response_text" => "🔹 Upload Vehicle Details"],
|
||||
"service_executive" => ["response_text" => "🔹 Talk to our Service Executive"],
|
||||
"go_back" => ["response_text" => "◀️ Go Back"],
|
||||
];
|
||||
|
||||
public function run()
|
||||
{
|
||||
@ -20,15 +24,36 @@ class commonPolicyOptionConversations extends Conversation
|
||||
|
||||
protected function policyOptions()
|
||||
{
|
||||
$question = Question::create("Choose Policy Type:")
|
||||
->addButtons([
|
||||
Button::create("🔹 Upload Vehicle Details")->value("upload_vehicle_details"),
|
||||
Button::create("🔹 Talk to our Service Executive")->value("service_executive"),
|
||||
Button::create("◀️ Go Back")->value("go_back"),
|
||||
]);
|
||||
$buttons = [];
|
||||
foreach ($this->buttonsData as $key => $data) {
|
||||
$buttons[] = Button::create($data['response_text'])->value($key);
|
||||
}
|
||||
// $this->bot->userStorage()->save([
|
||||
// 'path' => []
|
||||
// ]);
|
||||
$question = Question::create("Please choose an option:")->addButtons($buttons);
|
||||
$temp = $this->buttonsData;
|
||||
$this->bot->ask($question, function ($answer) use( $temp ){
|
||||
$user_reponse = $answer->getValue();
|
||||
if (isset($temp[$user_reponse])) {
|
||||
$message = "You've chosen " . $temp[$user_reponse]['response_text'];
|
||||
// $this->bot->say($message,,WebDriver::class);
|
||||
$this->bot->reply($message);
|
||||
}
|
||||
|
||||
$this->bot->ask($question, function ($answer) {
|
||||
switch ($answer->getValue()) {
|
||||
if (!$answer->isInteractiveMessageReply()) {
|
||||
$user_reponse = null;
|
||||
}
|
||||
$path = $this->bot->userStorage()->get('path');
|
||||
array_push($path,
|
||||
$answer->getValue()
|
||||
);
|
||||
$this->bot->userStorage()->save([
|
||||
'path' => $path
|
||||
]);
|
||||
$path = $this->bot->userStorage()->get('path');
|
||||
// $this->say(json_encode($path));
|
||||
switch ($user_reponse) {
|
||||
case "upload_vehicle_details":
|
||||
// $cityName = $response->getText();
|
||||
$this->bot->startConversation(new vehicleFormConversation());
|
||||
@ -48,3 +73,5 @@ class commonPolicyOptionConversations extends Conversation
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -11,6 +11,10 @@ use App\Helpers\ChatbotHelper;
|
||||
|
||||
class doYouWantToContinueConversation extends Conversation
|
||||
{
|
||||
protected $buttonsData = [
|
||||
"yes" => ["response_text" => "🔹 Yes I need some more Help"],
|
||||
"no" => ["response_text" => "🔹 No, Thank You"]
|
||||
];
|
||||
|
||||
|
||||
public function run()
|
||||
@ -22,21 +26,56 @@ class doYouWantToContinueConversation extends Conversation
|
||||
|
||||
protected function askQuestion()
|
||||
{
|
||||
$question = Question::create("Do you Need Anything Else ?")
|
||||
->addButtons([
|
||||
Button::create("🔹 Yes I need some more Help")->value("yes"),
|
||||
Button::create("🔹 No, Thank You")->value("no"),
|
||||
// Button::create("◀️ Go Back")->value("go_back"),
|
||||
$buttons = [];
|
||||
foreach ($this->buttonsData as $key => $data) {
|
||||
$buttons[] = Button::create($data['response_text'])->value($key);
|
||||
}
|
||||
// $this->bot->userStorage()->save([
|
||||
// 'path' => []
|
||||
// ]);
|
||||
$question = Question::create("Please choose an option:")->addButtons($buttons);
|
||||
$temp = $this->buttonsData;
|
||||
$this->bot->ask($question, function ($answer) use( $temp ){
|
||||
$user_reponse = $answer->getValue();
|
||||
if (isset($temp[$user_reponse])) {
|
||||
$message = "You've chosen " . $temp[$user_reponse]['response_text'];
|
||||
// $this->bot->say($message,,WebDriver::class);
|
||||
$this->bot->reply($message);
|
||||
}
|
||||
|
||||
if (!$answer->isInteractiveMessageReply()) {
|
||||
$user_reponse = null;
|
||||
}
|
||||
$path = $this->bot->userStorage()->get('path');
|
||||
array_push($path,
|
||||
$answer->getValue()
|
||||
);
|
||||
$this->bot->userStorage()->save([
|
||||
'path' => $path
|
||||
]);
|
||||
|
||||
$this->bot->ask($question, function ($answer) {
|
||||
switch ($answer->getValue()) {
|
||||
switch ($user_reponse) {
|
||||
case "yes":
|
||||
|
||||
// $this->say("Sure, How can I help you ");
|
||||
$this->bot->startConversation(new MainMenuConversation());
|
||||
break;
|
||||
case "no":
|
||||
// $user = $this->bot->getUser();
|
||||
// $userID = $user->getId();
|
||||
$dataBefore = $this->bot->userStorage()->all();
|
||||
// log_message('info','Before Deletion: ' . json_encode($dataBefore));
|
||||
|
||||
$this->bot->userStorage()->delete();
|
||||
$this->bot->userStorage()->save([]);
|
||||
|
||||
|
||||
// Cache::flush();
|
||||
|
||||
$dataAfter = $this->bot->userStorage()->all();
|
||||
// log_message('info','After Deletion: ' . json_encode($dataAfter));
|
||||
|
||||
|
||||
$this->say("Thank you for your time! If you need anything else, feel free to reach out. Goodbye!");
|
||||
break;
|
||||
default:
|
||||
|
||||
@ -11,7 +11,11 @@ use App\Helpers\ChatbotHelper;
|
||||
|
||||
class fourWheelerOptionsConversations extends Conversation
|
||||
{
|
||||
|
||||
protected $buttonsData = [
|
||||
"comp" => ["response_text" => "🔹 Comprehensive"],
|
||||
"3p" => ["response_text" => "🔹 Third-Party Only"],
|
||||
"go_back" => ["response_text" => "◀️ Go Back"],
|
||||
];
|
||||
|
||||
public function run()
|
||||
{
|
||||
@ -20,15 +24,36 @@ class fourWheelerOptionsConversations extends Conversation
|
||||
|
||||
protected function show4WOptions()
|
||||
{
|
||||
$question = Question::create("Choose Policy Type:")
|
||||
->addButtons([
|
||||
Button::create("🔹 Comprehensive")->value("comp"),
|
||||
Button::create("🔹 Third-Party Only")->value("3p"),
|
||||
Button::create("◀️ Go Back")->value("go_back"),
|
||||
]);
|
||||
$buttons = [];
|
||||
foreach ($this->buttonsData as $key => $data) {
|
||||
$buttons[] = Button::create($data['response_text'])->value($key);
|
||||
}
|
||||
// $this->bot->userStorage()->save([
|
||||
// 'path' => []
|
||||
// ]);
|
||||
$question = Question::create("Please choose an option:")->addButtons($buttons);
|
||||
$temp = $this->buttonsData;
|
||||
$this->bot->ask($question, function ($answer) use( $temp ){
|
||||
$user_reponse = $answer->getValue();
|
||||
if (isset($temp[$user_reponse])) {
|
||||
$message = "You've chosen " . $temp[$user_reponse]['response_text'];
|
||||
// $this->bot->say($message,,WebDriver::class);
|
||||
$this->bot->reply($message);
|
||||
}
|
||||
|
||||
$this->bot->ask($question, function ($answer) {
|
||||
switch ($answer->getValue()) {
|
||||
if (!$answer->isInteractiveMessageReply()) {
|
||||
$user_reponse = null;
|
||||
}
|
||||
$path = $this->bot->userStorage()->get('path');
|
||||
array_push($path,
|
||||
$answer->getValue()
|
||||
);
|
||||
$this->bot->userStorage()->save([
|
||||
'path' => $path
|
||||
]);
|
||||
$path = $this->bot->userStorage()->get('path');
|
||||
// $this->say(json_encode($path));
|
||||
switch ($user_reponse) {
|
||||
case "3p":
|
||||
// $cityName = $response->getText();
|
||||
$this->bot->startConversation(new commonPolicyOptionConversations());
|
||||
|
||||
@ -11,7 +11,11 @@ use App\Helpers\ChatbotHelper;
|
||||
|
||||
class hospitalPolicyConversation extends Conversation
|
||||
{
|
||||
|
||||
protected $buttonsData = [
|
||||
"individual" => ["response_text" => "🔹 Individual"],
|
||||
"floater" => ["response_text" => "🔹 Floater"],
|
||||
"go_back" => ["response_text" => "◀️ Go Back"],
|
||||
];
|
||||
|
||||
public function run()
|
||||
{
|
||||
@ -20,23 +24,42 @@ class hospitalPolicyConversation extends Conversation
|
||||
|
||||
protected function showMediclaimPolicyOptions()
|
||||
{
|
||||
$path = $this->bot->userStorage()->get('path');
|
||||
|
||||
if (in_array('individual',$path)){
|
||||
$text = 'Upload Policy Copy and Individual Details';
|
||||
$value = 'individual_upload';
|
||||
}else{
|
||||
$text = 'Upload Policy Copy and Family Details';
|
||||
$value = 'family_upload';
|
||||
}
|
||||
$question = Question::create("Choose Policy Type:")
|
||||
->addButtons([
|
||||
Button::create("🔹 Individual")->value("individual"),
|
||||
Button::create("🔹 Floater")->value("floater"),
|
||||
Button::create("🔹 ".$text)->value($value),
|
||||
Button::create("🔹 Talk to our Service Executive")->value("service_executive"),
|
||||
Button::create("◀️ Go Back")->value("go_back"),
|
||||
]);
|
||||
|
||||
$this->bot->ask($question, function ($answer) {
|
||||
$this->bot->ask($question, function ($answer) use ($value, $text){
|
||||
$path = $this->bot->userStorage()->get('path');
|
||||
array_push($path,
|
||||
$answer->getValue()
|
||||
);
|
||||
$this->bot->userStorage()->save([
|
||||
'path' => $path
|
||||
]);
|
||||
switch ($answer->getValue()) {
|
||||
case "individual":
|
||||
$this->bot->startConversation(new commonPolicyOptionConversations());
|
||||
case $value:
|
||||
$this->say("you have chosen ".$text);
|
||||
|
||||
$this->bot->startConversation(new medicalClaimFormConversations());
|
||||
break;
|
||||
case "floater":
|
||||
$this->bot->startConversation(new commonPolicyOptionConversations());
|
||||
case "service_executive":
|
||||
$this->say('You have chosen to speak with our Service Executive');
|
||||
$this->bot->startConversation(new serviceExecutiveConversation());
|
||||
break;
|
||||
case "go_back":
|
||||
$this->bot->startConversation(new MainMenuConversation());
|
||||
$this->bot->startConversation(new medicalClaimOptionConversations());
|
||||
break;
|
||||
default:
|
||||
$this->say("Invalid selection. Please choose an option.");
|
||||
|
||||
313
app/Controllers/Chatbot/medicalClaimFormConversations.php
Normal file
313
app/Controllers/Chatbot/medicalClaimFormConversations.php
Normal file
@ -0,0 +1,313 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Chatbot;
|
||||
|
||||
use App\Helpers\ChatbotHelper;
|
||||
use BotMan\BotMan\Messages\Outgoing\Question;
|
||||
use BotMan\BotMan\Messages\Outgoing\Actions\Button;
|
||||
use BotMan\BotMan\Messages\Conversations\Conversation;
|
||||
|
||||
class medicalClaimFormConversations extends Conversation
|
||||
{
|
||||
private $currentMemberData = [
|
||||
'name' => null,
|
||||
'dob' => null,
|
||||
'si' => null,
|
||||
'pre_existing_disease' => null
|
||||
];
|
||||
|
||||
public function run()
|
||||
{
|
||||
// Initialize state if not exists
|
||||
if (!$this->bot->userStorage()->get('claim_form_state')) {
|
||||
$this->bot->userStorage()->save([
|
||||
'claim_form_state' => [
|
||||
'dependency_count' => 0,
|
||||
'current_member' => 'primary',
|
||||
'dependencies' => [],
|
||||
'primary_insurer' => null
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
$state = $this->bot->userStorage()->get('claim_form_state');
|
||||
$memberType = ($state['current_member'] === 'primary') ? 'primary insured person' : 'dependency';
|
||||
|
||||
$this->askName($memberType);
|
||||
}
|
||||
|
||||
private function askName($memberType)
|
||||
{
|
||||
$this->ask("Enter the Name of the $memberType?", function($answer) {
|
||||
$name = $answer->getText();
|
||||
|
||||
if (empty($name)) {
|
||||
$this->say('Name Cannot be Empty');
|
||||
return $this->run();
|
||||
}
|
||||
|
||||
// Get existing state and update only the name
|
||||
$state = $this->bot->userStorage()->get('claim_form_state');
|
||||
if ($state['current_member'] === 'primary') {
|
||||
if (!isset($state['primary_insurer'])) {
|
||||
$state['primary_insurer'] = [];
|
||||
}
|
||||
$state['primary_insurer']['name'] = $name;
|
||||
} else {
|
||||
if (!isset($state['temp_dependency'])) {
|
||||
$state['temp_dependency'] = [];
|
||||
}
|
||||
$state['temp_dependency']['name'] = $name;
|
||||
}
|
||||
|
||||
$this->bot->userStorage()->save(['claim_form_state' => $state]);
|
||||
$this->askDOB();
|
||||
});
|
||||
}
|
||||
|
||||
private function askDOB()
|
||||
{
|
||||
$this->ask('Enter Date of Birth (DD/MM/YYYY)?', function($answer) {
|
||||
$dob = $answer->getText();
|
||||
|
||||
if (empty($dob)) {
|
||||
$this->say('Date of Birth Cannot be Empty');
|
||||
return $this->askDOB();
|
||||
}
|
||||
|
||||
// Get existing state and update only the DOB
|
||||
$state = $this->bot->userStorage()->get('claim_form_state');
|
||||
if ($state['current_member'] === 'primary') {
|
||||
$state['primary_insurer']['dob'] = $dob;
|
||||
} else {
|
||||
$state['temp_dependency']['dob'] = $dob;
|
||||
}
|
||||
|
||||
$this->bot->userStorage()->save(['claim_form_state' => $state]);
|
||||
$this->askSumInsured();
|
||||
});
|
||||
}
|
||||
|
||||
private function askSumInsured()
|
||||
{
|
||||
$this->ask('Enter Sum Insured Amount?', function($answer) {
|
||||
$sum_insured = $answer->getText();
|
||||
|
||||
if (empty($sum_insured)) {
|
||||
$this->say('Sum Insured Cannot be Empty');
|
||||
return $this->askSumInsured();
|
||||
}
|
||||
|
||||
// Get existing state and update only the sum insured
|
||||
$state = $this->bot->userStorage()->get('claim_form_state');
|
||||
if ($state['current_member'] === 'primary') {
|
||||
$state['primary_insurer']['si'] = $sum_insured;
|
||||
} else {
|
||||
$state['temp_dependency']['si'] = $sum_insured;
|
||||
}
|
||||
|
||||
$this->bot->userStorage()->save(['claim_form_state' => $state]);
|
||||
$this->askPreExistingDisease();
|
||||
});
|
||||
}
|
||||
|
||||
private function askPreExistingDisease()
|
||||
{
|
||||
$this->ask('Enter Pre-Existing Disease if any (type "none" if none)?', function($answer) {
|
||||
$pre_existing_disease = $answer->getText();
|
||||
|
||||
if (empty($pre_existing_disease)) {
|
||||
$this->say('Please enter none if no pre-existing conditions');
|
||||
return $this->askPreExistingDisease();
|
||||
}
|
||||
|
||||
// Get existing state and update the disease info
|
||||
$state = $this->bot->userStorage()->get('claim_form_state');
|
||||
if ($state['current_member'] === 'primary') {
|
||||
$state['primary_insurer']['pre_existing_disease'] = $pre_existing_disease;
|
||||
$state['primary_insurer']['type'] = 'primary';
|
||||
} else {
|
||||
$state['temp_dependency']['pre_existing_disease'] = $pre_existing_disease;
|
||||
$state['temp_dependency']['type'] = 'dependency';
|
||||
|
||||
// Move completed dependency to dependencies array
|
||||
if (!isset($state['dependencies'])) {
|
||||
$state['dependencies'] = [];
|
||||
}
|
||||
$state['dependencies'][] = $state['temp_dependency'];
|
||||
$state['temp_dependency'] = null; // Clear temporary dependency
|
||||
}
|
||||
|
||||
$this->bot->userStorage()->save(['claim_form_state' => $state]);
|
||||
|
||||
// For debugging
|
||||
log_message('debug', 'Final state after all data collection: ' . json_encode($state));
|
||||
|
||||
$this->saveMemberAndContinue();
|
||||
});
|
||||
}
|
||||
|
||||
private function saveMemberAndContinue()
|
||||
{
|
||||
$state = $this->bot->userStorage()->get('claim_form_state');
|
||||
$memberData = $state['current_member'] === 'primary'
|
||||
? $state['primary_insurer']
|
||||
: end($state['dependencies']);
|
||||
|
||||
// Show current member info
|
||||
$memberInfo = "👤 **" . ucfirst($memberData['type']) . " Member Details:**\n";
|
||||
$memberInfo .= "🔹 Name: " . $memberData['name'] . "\n";
|
||||
$memberInfo .= "🔹 Date of Birth: " . $memberData['dob'] . "\n";
|
||||
$memberInfo .= "🔹 Sum Insured: " . $memberData['si'] . "\n";
|
||||
$memberInfo .= "🔹 Pre Existing Disease: " . $memberData['pre_existing_disease'] . "\n";
|
||||
|
||||
$this->say($memberInfo);
|
||||
|
||||
$path = $this->bot->userStorage()->get('path');
|
||||
|
||||
if (in_array('floater', $path)) {
|
||||
$this->askAboutDependencies();
|
||||
} else {
|
||||
$this->showSummary();
|
||||
}
|
||||
}
|
||||
|
||||
private function askAboutDependencies()
|
||||
{
|
||||
$question = Question::create("Do you want to add a dependency? ")
|
||||
->addButtons([
|
||||
Button::create("✅ Yes")->value("yes"),
|
||||
Button::create("❌ No")->value("no"),
|
||||
Button::create("◀️ Go Back")->value("go_back"),
|
||||
]);
|
||||
|
||||
$this->ask($question, function($answer) {
|
||||
$state = $this->bot->userStorage()->get('claim_form_state');
|
||||
|
||||
switch ($answer->getValue()) {
|
||||
case "yes":
|
||||
$state['dependency_count']++;
|
||||
$state['current_member'] = 'dependency';
|
||||
$this->bot->userStorage()->save(['claim_form_state' => $state]);
|
||||
|
||||
// Reset currentMemberData for new dependency
|
||||
$this->currentMemberData = [
|
||||
'name' => null,
|
||||
'dob' => null,
|
||||
'si' => null,
|
||||
'pre_existing_disease' => null
|
||||
];
|
||||
|
||||
$this->run();
|
||||
break;
|
||||
|
||||
case "no":
|
||||
$this->showSummary();
|
||||
break;
|
||||
|
||||
case "go_back":
|
||||
$this->bot->startConversation(new hospitalPolicyConversation());
|
||||
break;
|
||||
|
||||
default:
|
||||
$this->say("Invalid selection. Please choose an option.");
|
||||
$this->askAboutDependencies();
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private function showSummary()
|
||||
{
|
||||
$state = $this->bot->userStorage()->get('claim_form_state');
|
||||
|
||||
$finalSummary = '<div style="font-family: Arial, sans-serif; font-size: 15px; margin: 0; padding: 2px;">';
|
||||
|
||||
// Primary Insurer
|
||||
if ($state['primary_insurer']) {
|
||||
$finalSummary .= '<div style="margin: 2px 0; padding-left: 5px;">Primary:<br>' .
|
||||
$this->formatSingleLineMemberInfo($state['primary_insurer']) .
|
||||
'</div>';
|
||||
}
|
||||
|
||||
// Dependencies
|
||||
if (!empty($state['dependencies'])) {
|
||||
foreach ($state['dependencies'] as $index => $dependency) {
|
||||
$finalSummary .= '<div style="margin: 2px 0; padding-left: 5px;">Dep ' . ($index + 1) . ':<br>' .
|
||||
$this->formatSingleLineMemberInfo($dependency) .
|
||||
'</div>';
|
||||
}
|
||||
}
|
||||
|
||||
$finalSummary .= '</div>';
|
||||
|
||||
$this->say($finalSummary);
|
||||
|
||||
$question = Question::create("Confirm all details:")
|
||||
->addButtons([
|
||||
Button::create("✅ Confirm")->value("confirm"),
|
||||
Button::create("❌ Start Over")->value("restart"),
|
||||
]);
|
||||
|
||||
$this->ask($question, function ($answer) use ($finalSummary) {
|
||||
switch ($answer->getValue()) {
|
||||
case "confirm":
|
||||
$sent_status = ChatbotHelper::sendQuotationRequestMail($finalSummary);
|
||||
if ($sent_status) {
|
||||
$this->say('Our Executive will contact you with the quotation soon.');
|
||||
$this->bot->startConversation(new doYouWantToContinueConversation());
|
||||
} else {
|
||||
$this->say("There was a problem while requesting for a quotation. Please try again later.");
|
||||
}
|
||||
break;
|
||||
case "restart":
|
||||
$this->bot->userStorage()->save([
|
||||
'claim_form_state' => [
|
||||
'dependency_count' => 0,
|
||||
'current_member' => 'primary',
|
||||
'dependencies' => [],
|
||||
'primary_insurer' => null
|
||||
]
|
||||
]);
|
||||
$this->run();
|
||||
break;
|
||||
default:
|
||||
$this->say("Invalid selection. Please choose an option.");
|
||||
$this->showSummary();
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private function formatSingleLineMemberInfo($member)
|
||||
{
|
||||
return '🔹 Name: ' . htmlspecialchars($member['name']) . '<br>' .
|
||||
'🔹 DOB: ' . htmlspecialchars($member['dob']) . '<br>' .
|
||||
'🔹 SI: ' . htmlspecialchars($member['si']) . '<br>' .
|
||||
'🔹 PED: ' . htmlspecialchars($member['pre_existing_disease']);
|
||||
}
|
||||
|
||||
|
||||
// private function formatMemberInfo($member)
|
||||
// {
|
||||
// // Format each piece of information with proper HTML
|
||||
// return '<div style="line-height: 1.6;">
|
||||
// <div style="margin-bottom: 5px;">
|
||||
// <span style="color: #2c3e50;">🔹 Name:</span>
|
||||
// <span style="color: #34495e; font-weight: 500;">' . htmlspecialchars($member['name']) . '</span>
|
||||
// </div>
|
||||
// <div style="margin-bottom: 5px;">
|
||||
// <span style="color: #2c3e50;">🔹 DOB:</span>
|
||||
// <span style="color: #34495e; font-weight: 500;">' . htmlspecialchars($member['dob']) . '</span>
|
||||
// </div>
|
||||
// <div style="margin-bottom: 5px;">
|
||||
// <span style="color: #2c3e50;">🔹 Sum Insured:</span>
|
||||
// <span style="color: #34495e; font-weight: 500;">' . htmlspecialchars($member['si']) . '</span>
|
||||
// </div>
|
||||
// <div style="margin-bottom: 5px;">
|
||||
// <span style="color: #2c3e50;">🔹 Pre-Existing Conditions:</span>
|
||||
// <span style="color: #34495e; font-weight: 500;">' . htmlspecialchars($member['pre_existing_disease']) . '</span>
|
||||
// </div>
|
||||
// </div>';
|
||||
// }
|
||||
}
|
||||
@ -12,6 +12,11 @@ use App\Helpers\ChatbotHelper;
|
||||
class medicalClaimOptionConversations extends Conversation
|
||||
{
|
||||
|
||||
protected $buttonsData = [
|
||||
"individual" => ["response_text" => "🔹 Individual"],
|
||||
"floater" => ["response_text" => "🔹 Floater"],
|
||||
"go_back" => ["response_text" => "◀️ Go Back"],
|
||||
];
|
||||
|
||||
public function run()
|
||||
{
|
||||
@ -20,21 +25,41 @@ class medicalClaimOptionConversations extends Conversation
|
||||
|
||||
protected function showMediclaimOptions()
|
||||
{
|
||||
$question = Question::create("Choose Policy Type:")
|
||||
->addButtons([
|
||||
Button::create("🔹 Individual")->value("individual"),
|
||||
Button::create("🔹 Floater")->value("floater"),
|
||||
Button::create("◀️ Go Back")->value("go_back"),
|
||||
$buttons = [];
|
||||
foreach ($this->buttonsData as $key => $data) {
|
||||
$buttons[] = Button::create($data['response_text'])->value($key);
|
||||
}
|
||||
// $this->bot->userStorage()->save([
|
||||
// 'path' => []
|
||||
// ]);
|
||||
$question = Question::create("Please choose an option:")->addButtons($buttons);
|
||||
$temp = $this->buttonsData;
|
||||
$this->bot->ask($question, function ($answer) use( $temp ){
|
||||
$user_reponse = $answer->getValue();
|
||||
if (isset($temp[$user_reponse])) {
|
||||
$message = "You've chosen " . $temp[$user_reponse]['response_text'];
|
||||
// $this->bot->say($message,,WebDriver::class);
|
||||
$this->bot->reply($message);
|
||||
}
|
||||
|
||||
if (!$answer->isInteractiveMessageReply()) {
|
||||
$user_reponse = null;
|
||||
}
|
||||
$path = $this->bot->userStorage()->get('path');
|
||||
array_push($path,
|
||||
$answer->getValue()
|
||||
);
|
||||
$this->bot->userStorage()->save([
|
||||
'path' => $path
|
||||
]);
|
||||
|
||||
$this->bot->ask($question, function ($answer) {
|
||||
switch ($answer->getValue()) {
|
||||
switch ($user_reponse) {
|
||||
case "individual":
|
||||
// $cityName = $response->getText();
|
||||
$this->bot->startConversation(new commonPolicyOptionConversations());
|
||||
$this->bot->startConversation(new hospitalPolicyConversation());
|
||||
break;
|
||||
case "floater":
|
||||
$this->bot->startConversation(new commonPolicyOptionConversations());
|
||||
$this->bot->startConversation(new hospitalPolicyConversation());
|
||||
break;
|
||||
case "go_back":
|
||||
$this->bot->startConversation(new MainMenuConversation());
|
||||
|
||||
@ -11,6 +11,12 @@ use App\Helpers\ChatbotHelper;
|
||||
|
||||
class policyConversation extends Conversation
|
||||
{
|
||||
protected $buttonsData = [
|
||||
"2_wheeler" => ["response_text" => "🏍️ 2 Wheeler"],
|
||||
"4_wheeler" => ["response_text" => "🚗 4 Wheeler"],
|
||||
"mediclaim" => ["response_text" => "🩺 Medical Claim"],
|
||||
"go_back" => ["response_text" => "◀️ Go Back"],
|
||||
];
|
||||
|
||||
|
||||
public function run()
|
||||
@ -20,16 +26,34 @@ class policyConversation extends Conversation
|
||||
|
||||
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"),
|
||||
]);
|
||||
$buttons = [];
|
||||
foreach ($this->buttonsData as $key => $data) {
|
||||
$buttons[] = Button::create($data['response_text'])->value($key);
|
||||
}
|
||||
// $this->bot->userStorage()->save([
|
||||
// 'path' => []
|
||||
// ]);
|
||||
$question = Question::create("Please choose an option:")->addButtons($buttons);
|
||||
$temp = $this->buttonsData;
|
||||
$this->bot->ask($question, function ($answer) use( $temp ){
|
||||
$user_reponse = $answer->getValue();
|
||||
if (isset($temp[$user_reponse])) {
|
||||
$message = "You've chosen " . $temp[$user_reponse]['response_text'];
|
||||
// $this->bot->say($message,,WebDriver::class);
|
||||
$this->bot->reply($message);
|
||||
}
|
||||
|
||||
$this->bot->ask($question, function ($answer) {
|
||||
switch ($answer->getValue()) {
|
||||
if (!$answer->isInteractiveMessageReply()) {
|
||||
$user_reponse = null;
|
||||
}
|
||||
$path = $this->bot->userStorage()->get('path');
|
||||
array_push($path,
|
||||
$answer->getValue()
|
||||
);
|
||||
$this->bot->userStorage()->save([
|
||||
'path' => $path
|
||||
]);
|
||||
switch ($user_reponse) {
|
||||
case "2_wheeler":
|
||||
// $cityName = $response->getText();
|
||||
$this->bot->startConversation(new twoWheelerOptionsConversations());
|
||||
|
||||
93
app/Controllers/Chatbot/selectInsurerConversations.php
Normal file
93
app/Controllers/Chatbot/selectInsurerConversations.php
Normal file
@ -0,0 +1,93 @@
|
||||
<?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 selectInsurerConversations extends Conversation
|
||||
{
|
||||
|
||||
|
||||
public function run()
|
||||
{
|
||||
$this->insurerOptions();
|
||||
}
|
||||
|
||||
protected function insurerOptions()
|
||||
{
|
||||
$question = Question::create("Choose Your Options:")
|
||||
->addButtons([
|
||||
Button::create("🔹 Select Insurers")->value("insurers"),
|
||||
Button::create("🔹 Talk to our Service Executive")->value("service_executive"),
|
||||
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
|
||||
]);
|
||||
switch ($answer->getValue()) {
|
||||
case "insurers":
|
||||
$data = ChatbotHelper::getInsurersList();
|
||||
log_message("error",'data: '.json_encode($data));
|
||||
$question = Question::create("Select an Insurer:");
|
||||
$page = $this->bot->userStorage()->get('insurer_page') ?? 0;
|
||||
$perPage = 5;
|
||||
$totalPages = ceil(count($data) / $perPage);
|
||||
$insurersToShow = array_slice($data, $page * $perPage, $perPage);
|
||||
|
||||
$buttons = [];
|
||||
foreach ($insurersToShow as $insurer) {
|
||||
$buttons[] = Button::create("🔹 " . $insurer['short_name'])->value($insurer['short_name']);
|
||||
}
|
||||
|
||||
// Add pagination buttons
|
||||
if ($page > 0) {
|
||||
$buttons[] = Button::create("⬅️ Previous")->value("previous_page");
|
||||
}
|
||||
if (($page + 1) < $totalPages) {
|
||||
$buttons[] = Button::create("➡️ Next")->value("next_page");
|
||||
}
|
||||
|
||||
$question = Question::create("Choose an Insurer:")
|
||||
->addButtons($buttons);
|
||||
|
||||
$this->bot->ask($question, function ($response) {
|
||||
$selected = $response->getValue();
|
||||
|
||||
if ($selected == "previous_page") {
|
||||
$this->bot->userStorage()->save(["insurer_page" => max(0, $this->bot->userStorage()->get('insurer_page') - 1)]);
|
||||
$this->insurerOptions();
|
||||
} elseif ($selected == "next_page") {
|
||||
$this->bot->userStorage()->save(["insurer_page" => $this->bot->userStorage()->get('insurer_page') + 1]);
|
||||
$this->insurerOptions();
|
||||
} else {
|
||||
$this->say("You selected: " . $selected);
|
||||
}
|
||||
});
|
||||
|
||||
break;
|
||||
case "service_executive":
|
||||
$this->bot->startConversation(new serviceExecutiveConversation());
|
||||
break;
|
||||
case "go_back":
|
||||
$this->bot->startConversation(new MainMenuConversation());
|
||||
break;
|
||||
default:
|
||||
$this->say("Invalid selection. Please choose an option.");
|
||||
$this->policyOptions();
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@ -18,7 +18,8 @@ class serviceExecutiveConversation extends Conversation
|
||||
|
||||
protected function askServiceExecutive()
|
||||
{
|
||||
$mobile = ChatbotHelper::getPhoneNumber(); // Assuming this fetches the user's phone number
|
||||
$chat_session_info = get_chatbot_session_info();
|
||||
$mobile = ChatbotHelper::getPhoneNumber($chat_session_info); // Assuming this fetches the user's phone number
|
||||
$question = Question::create("Is this Your Mobile Number: $mobile")
|
||||
->addButtons([
|
||||
Button::create("✅ Yes")->value("yes"),
|
||||
@ -27,6 +28,13 @@ class serviceExecutiveConversation extends Conversation
|
||||
]);
|
||||
|
||||
$this->bot->ask($question, function ($answer) {
|
||||
$path = $this->bot->userStorage()->get('path');
|
||||
array_push($path,
|
||||
$answer->getValue()
|
||||
);
|
||||
$this->bot->userStorage()->save([
|
||||
'path' => $path
|
||||
]);
|
||||
switch ($answer->getValue()) {
|
||||
case "yes":
|
||||
$this->say("Our executive will call you at the earliest.");
|
||||
|
||||
@ -11,6 +11,11 @@ use App\Helpers\ChatbotHelper;
|
||||
|
||||
class twoWheelerOptionsConversations extends Conversation
|
||||
{
|
||||
protected $buttonsData = [
|
||||
"3p" => ["response_text" => "🔹 Third-Party"],
|
||||
"comp" => ["response_text" => "🔹 Comprehensive"],
|
||||
"go_back" => ["response_text" => "◀️ Go Back"]
|
||||
];
|
||||
|
||||
|
||||
public function run()
|
||||
@ -20,15 +25,35 @@ class twoWheelerOptionsConversations extends Conversation
|
||||
|
||||
protected function show2WOptions()
|
||||
{
|
||||
$question = Question::create("Choose Policy Type:")
|
||||
->addButtons([
|
||||
Button::create("🔹 Third-Party")->value("3p"),
|
||||
Button::create("🔹 Comprehensive")->value("comp"),
|
||||
Button::create("◀️ Go Back")->value("go_back"),
|
||||
$buttons = [];
|
||||
foreach ($this->buttonsData as $key => $data) {
|
||||
$buttons[] = Button::create($data['response_text'])->value($key);
|
||||
}
|
||||
// $this->bot->userStorage()->save([
|
||||
// 'path' => []
|
||||
// ]);
|
||||
$question = Question::create("Please choose an option:")->addButtons($buttons);
|
||||
$temp = $this->buttonsData;
|
||||
$this->bot->ask($question, function ($answer) use( $temp ){
|
||||
$user_reponse = $answer->getValue();
|
||||
if (isset($temp[$user_reponse])) {
|
||||
$message = "You've chosen " . $temp[$user_reponse]['response_text'];
|
||||
// $this->bot->say($message,,WebDriver::class);
|
||||
$this->bot->reply($message);
|
||||
}
|
||||
|
||||
if (!$answer->isInteractiveMessageReply()) {
|
||||
$user_reponse = null;
|
||||
}
|
||||
$path = $this->bot->userStorage()->get('path');
|
||||
array_push($path,
|
||||
$answer->getValue()
|
||||
);
|
||||
$this->bot->userStorage()->save([
|
||||
'path' => $path
|
||||
]);
|
||||
|
||||
$this->bot->ask($question, function ($answer) {
|
||||
switch ($answer->getValue()) {
|
||||
switch ($user_reponse) {
|
||||
case "3p":
|
||||
// $cityName = $response->getText();
|
||||
$this->bot->startConversation(new commonPolicyOptionConversations());
|
||||
|
||||
@ -2,9 +2,10 @@
|
||||
|
||||
namespace App\Controllers\Chatbot;
|
||||
|
||||
use BotMan\BotMan\Messages\Conversations\Conversation;
|
||||
use App\Helpers\ChatbotHelper;
|
||||
use BotMan\BotMan\Messages\Outgoing\Question;
|
||||
use BotMan\BotMan\Messages\Outgoing\Actions\Button;
|
||||
use BotMan\BotMan\Messages\Conversations\Conversation;
|
||||
|
||||
class vehicleFormConversation extends Conversation
|
||||
{
|
||||
@ -12,10 +13,19 @@ class vehicleFormConversation extends Conversation
|
||||
protected $vehicleYOM;
|
||||
protected $vehicleEngineNo;
|
||||
protected $vehicleInvoiceNo;
|
||||
protected $userId;
|
||||
protected $complied_information;
|
||||
protected $fuelType;
|
||||
protected $seater;
|
||||
protected $chassisNumber;
|
||||
|
||||
public function run()
|
||||
{
|
||||
$this->askVehicleName();
|
||||
// Ensure $this->bot is properly initialized
|
||||
// $user = $this->bot->getUser();
|
||||
// $this->userId = $user->getId(); // Correctly store user ID
|
||||
|
||||
$this->askVehicleName(); // Start asking vehicle questions
|
||||
}
|
||||
|
||||
protected function askVehicleName()
|
||||
@ -26,6 +36,35 @@ class vehicleFormConversation extends Conversation
|
||||
$this->say('Vehicle Name Cannot be Empty');
|
||||
return $this->askVehicleName(); // Re-ask if empty
|
||||
}
|
||||
// $this->askVehicleYOM(); // Ask next question
|
||||
$path = $this->bot->userStorage()->get('path');
|
||||
|
||||
if (in_array('4_wheeler', $path)) {
|
||||
$this->askFuelType();
|
||||
} else {
|
||||
$this->askVehicleYOM(); // Ask next question
|
||||
}
|
||||
});
|
||||
}
|
||||
protected function askFuelType()
|
||||
{
|
||||
$this->ask('Enter Fuel Type of the Vehicle ?', function ($response) {
|
||||
$this->fuelType = $response->getText();
|
||||
if (empty($this->fuelType)) {
|
||||
$this->say('Vehicle Fuel Type Cannot be Empty');
|
||||
return $this->askFuelType(); // Re-ask if empty
|
||||
}
|
||||
$this->askSeating(); // Ask next question
|
||||
});
|
||||
}
|
||||
protected function askSeating()
|
||||
{
|
||||
$this->ask('Enter the seat count of the Vehicle ?', function ($response) {
|
||||
$this->seater = $response->getText();
|
||||
if (empty($this->seater)) {
|
||||
$this->say('Vehicle seat Cannot be Empty');
|
||||
return $this->askSeating(); // Re-ask if empty
|
||||
}
|
||||
$this->askVehicleYOM(); // Ask next question
|
||||
});
|
||||
}
|
||||
@ -50,6 +89,26 @@ class vehicleFormConversation extends Conversation
|
||||
$this->say('Vehicle Engine Number Cannot be Empty');
|
||||
return $this->askVehicleEngineNo(); // Re-ask if empty
|
||||
}
|
||||
|
||||
// Retrieve 'path' from storage
|
||||
$path = $this->bot->userStorage()->get('path');
|
||||
|
||||
if (in_array('4_wheeler', $path)) {
|
||||
$this->askChassisNumber();
|
||||
} else {
|
||||
$this->askVehicleInvoiceNo(); // Ask next question
|
||||
}
|
||||
// $this->askVehicleInvoiceNo();
|
||||
});
|
||||
}
|
||||
protected function askChassisNumber()
|
||||
{
|
||||
$this->ask('Enter Chassis Number of the Vehicle ?', function ($response) {
|
||||
$this->chassisNumber = $response->getText();
|
||||
if (empty($this->chassisNumber)) {
|
||||
$this->say('Vehicle Chassis Number Cannot be Empty');
|
||||
return $this->askChassisNumber(); // Re-ask if empty
|
||||
}
|
||||
$this->askVehicleInvoiceNo(); // Ask next question
|
||||
});
|
||||
}
|
||||
@ -68,16 +127,88 @@ class vehicleFormConversation extends Conversation
|
||||
|
||||
protected function storeVehicleData()
|
||||
{
|
||||
// Save all collected data to user storage
|
||||
$this->bot->userStorage()->save([
|
||||
// Retrieve 'path' from storage
|
||||
$path = $this->bot->userStorage()->get('path');
|
||||
// $this->say(json_encode($path));
|
||||
// Prepare vehicle details
|
||||
$vehicleDetails = [
|
||||
'vehicle_name' => $this->vehicleName,
|
||||
'vehicle_yom' => $this->vehicleYOM,
|
||||
'vehicle_engine_no' => $this->vehicleEngineNo,
|
||||
'vehicle_invoice_no' => $this->vehicleInvoiceNo
|
||||
]);
|
||||
$vehicleDetails['vehicle_invoice_no'] = $this->vehicleInvoiceNo
|
||||
|
||||
];
|
||||
|
||||
// Only store 'vehicle_invoice_no' if 'new_policy' is NOT in path
|
||||
if (in_array('4_wheeler', $path)) {
|
||||
$vehicleDetails['vehicle_fuelType'] = $this->fuelType;
|
||||
$vehicleDetails['vehicle_seater'] = $this->seater;
|
||||
$vehicleDetails['vehicle_chassisNo'] = $this->chassisNumber;
|
||||
}
|
||||
|
||||
// Save vehicle details
|
||||
$this->bot->userStorage()->save(['vehicle_details' => $vehicleDetails]);
|
||||
$alldata = $this->bot->userStorage()->all();
|
||||
$vehicle_details = $this->bot->userStorage()->get('vehicle_details');
|
||||
// Log stored data for debugging
|
||||
// log_message('error', 'All Details: ' . json_encode($alldata));
|
||||
|
||||
// log_message('error', 'Updated Vehicle Details: ' . json_encode($vehicle_details));
|
||||
|
||||
$this->say('Vehicle Information Saved!');
|
||||
$this->bot->startConversation(new doYouWantToContinueConversation());
|
||||
|
||||
$vehicleInfo = "🚗 **Vehicle Details:**<br>";
|
||||
$vehicleInfo .= "🔹 Name: " . $vehicle_details['vehicle_name'] . "<br>";
|
||||
$vehicleInfo .= "🔹 Year of Manufacture: " . $vehicle_details['vehicle_yom'] . "<br>";
|
||||
$vehicleInfo .= "🔹 Engine No: " . $vehicle_details['vehicle_engine_no'] . "<br>";
|
||||
|
||||
if (isset($vehicle_details['vehicle_fuelType'])) {
|
||||
$vehicleInfo .= "🔹 Fuel Type: " . $vehicle_details['vehicle_fuelType'] . "<br>";
|
||||
$vehicleInfo .= "🔹 Seater: " . $vehicle_details['vehicle_seater'] . "<br>";
|
||||
$vehicleInfo .= "🔹 Chassis Number: " . $vehicle_details['vehicle_chassisNo'] . "<br>";
|
||||
}
|
||||
$this->complied_information = $vehicleInfo;
|
||||
// Send the message with vehicle details
|
||||
$this->say($vehicleInfo);
|
||||
$this->confirmVehicleDate($vehicleInfo);
|
||||
|
||||
|
||||
// $this->bot->startConversation(new selectInsurerConversations());
|
||||
}
|
||||
|
||||
protected function confirmVehicleDate($vehicle_info){
|
||||
$question = Question::create("Confim your Details:")
|
||||
->addButtons([
|
||||
Button::create("✅ Confirm")->value("confirm"),
|
||||
Button::create("❌ No")->value("no"),
|
||||
]);
|
||||
$this->bot->ask($question, function ($answer) use($vehicle_info) {
|
||||
$path = $this->bot->userStorage()->get('path');
|
||||
array_push($path,
|
||||
$answer->getValue()
|
||||
);
|
||||
$this->bot->userStorage()->save([
|
||||
'path' => $path
|
||||
]);
|
||||
switch ($answer->getValue()) {
|
||||
case "confirm":
|
||||
// $cityName = $response->getText();
|
||||
$sent_staus = ChatbotHelper::sendQuotationRequestMail($vehicle_info);
|
||||
if ($sent_staus){
|
||||
$this->say('Our Executive will contact you with the quotation soon.');
|
||||
$this->bot->startConversation(new doYouWantToContinueConversation());
|
||||
}else{
|
||||
$this->say("There was a problem while requesting for a quotation please try again later.");
|
||||
}
|
||||
break;
|
||||
case "no":
|
||||
$this->askVehicleName();
|
||||
break;
|
||||
default:
|
||||
$this->say("Invalid selection. Please choose an option.");
|
||||
$this->showHospitalMenu();
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,6 +9,10 @@ use App\Models\EmployeePolicyModel;
|
||||
use App\Models\TPAModel;
|
||||
|
||||
use App\Helpers\MailHelper;
|
||||
use App\Models\InsurerModel;
|
||||
use App\Models\TicketMasterModel;
|
||||
|
||||
use App\Controllers\TicketController;
|
||||
|
||||
class ChatbotHelper
|
||||
{
|
||||
@ -28,7 +32,7 @@ class ChatbotHelper
|
||||
$client_branch_id = $chat_session_info['client_branch_id'];
|
||||
// $relationship ='Father';
|
||||
$EmployeeModel = new EmployeeModel();
|
||||
return $EmployeeModel->getEmpFamilybyEmpCode(emp_code: $emp_code,client_id: $client_id,emp_status: ['draft'],policy_status:['draft'],client_branch_id:[ $client_branch_id ])//,relationship:[$relationship];
|
||||
return $EmployeeModel->getEmpFamilybyEmpCode(emp_code: $emp_code,client_id: $client_id,emp_status: ['draft'],policy_status:['draft'],client_branch_id:[ $client_branch_id ]);//,relationship:[$relationship];
|
||||
}
|
||||
|
||||
public static function getHospitalLink($client_policy_id){
|
||||
@ -40,41 +44,20 @@ class ChatbotHelper
|
||||
return is_array($res) && count($res) ? $res[0]['network_hospitals'] : null;
|
||||
}
|
||||
|
||||
public static function getPhoneNumber(){
|
||||
$emp_id = 12288;
|
||||
public static function getPhoneNumber($chat_session_info){
|
||||
$emp_id = $chat_session_info['emp_id'];
|
||||
$EmployeeModel = new EmployeeModel();
|
||||
return $EmployeeModel->select('mobile')->where('id',$emp_id)->first()['mobile'];
|
||||
}
|
||||
|
||||
public static function get_payload_data(string $key = null)
|
||||
public static function sendReimbursementProcessOverMail($chat_session_info)
|
||||
{
|
||||
// Get the request object using the service helper
|
||||
$request = service('request');
|
||||
|
||||
// Get the raw input (JSON or other data)
|
||||
$rawInput = $request->getBody();
|
||||
|
||||
// Check if the raw input is valid JSON
|
||||
$payload = json_decode($rawInput, true);
|
||||
|
||||
if (json_last_error() === JSON_ERROR_NONE) {
|
||||
// JSON is valid, return the requested key or the entire payload
|
||||
return $key ? ($payload[$key] ?? null) : $payload;
|
||||
} else {
|
||||
// JSON is invalid, fallback to raw input or POST data
|
||||
$payload = $request->getRawInput() ?: $request->getPost();
|
||||
return $key ? ($payload[$key] ?? null) : $payload;
|
||||
}
|
||||
}
|
||||
|
||||
public static function sendReimbursementProcessOverMail()
|
||||
{
|
||||
$emp_id = 12288;
|
||||
$emp_code = 'HTL-007';
|
||||
$client_id = 159;
|
||||
$policy_id = 0;
|
||||
$client_branch_id = 126;
|
||||
$relationship ='Father';
|
||||
$emp_id = $chat_session_info['emp_id'];
|
||||
$emp_code = $chat_session_info['emp_code'];
|
||||
$client_id = $chat_session_info['client_id'];
|
||||
$client_branch_id = $chat_session_info['client_branch_id'];
|
||||
// $policy_id = 0;
|
||||
// $relationship ='Father';
|
||||
$EmployeeModel = new EmployeeModel();
|
||||
$data = $EmployeeModel->find($emp_id);
|
||||
if(isset($data) && isset($data['email_corporate']))
|
||||
@ -207,6 +190,68 @@ class ChatbotHelper
|
||||
return $template;
|
||||
}
|
||||
|
||||
public static function getInsurersList(){
|
||||
$insurer = new InsurerModel();
|
||||
$data = $insurer->select('short_name,name')->where('category','general')->where('is_active',1)->findAll();
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function sendQuotationRequestMail($data){
|
||||
|
||||
$message = SELF::quotationRequestMailTemplate($data);
|
||||
|
||||
$common = ['mail_type'=>'request_quotation_bot'];
|
||||
$email_id = 'no-reply-otp@nhanceindia.in';
|
||||
$res = MailHelper::send_email(['mail' => $email_id, 'subject' => 'Quotation Request Received from bot.', 'message' => $message,'common'=>$common]);
|
||||
|
||||
$res = json_decode($res);
|
||||
log_message('error','res: '.json_encode($res));
|
||||
if($res->status == 'success')
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static function quotationRequestMailTemplate($data){
|
||||
$message = 'A customer has requested for a quotation using bot,Here are all the details for it:
|
||||
'.$data;
|
||||
return $message;
|
||||
}
|
||||
|
||||
public static function getReimbursementClaimStatus($chat_session_info){
|
||||
$emp_id = $chat_session_info['emp_id'];
|
||||
$emp_code = $chat_session_info['emp_code'];
|
||||
$client_id = $chat_session_info['client_id'];
|
||||
$client_branch_id = $chat_session_info['client_branch_id'];
|
||||
|
||||
$ticketMaster = new TicketMasterModel();
|
||||
$data = $ticketMaster->select('tcs.claim_status,ticket_master.claim_number,ticket_master.id')
|
||||
// ->join('client_policy cp',"cp.client_id = {$client_id} and cp.client_branch_id = {$client_branch_id} and cp.policy_id = {$policy_id} and cp.is_active = 1")
|
||||
->join('ticket_claim_status tcs',"ticket_master.claim_status_id = tcs.id and tcs.is_active = 1")
|
||||
->where('ticket_master.emp_id',$emp_id)
|
||||
->where('ticket_master.emp_code',$emp_code)
|
||||
->where('ticket_master.is_active',1)
|
||||
->orderBy('ticket_master.created_at', 'DESC')
|
||||
->first();
|
||||
|
||||
$ticket_controller = new TicketController();
|
||||
|
||||
if (!empty($data)){
|
||||
$ticket_id = $data['id'];
|
||||
$mail_content = $ticket_controller->constructMailContent($ticket_id);
|
||||
$mail_response = $ticket_controller->sendTrigger($mail_content);
|
||||
return $data;
|
||||
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -826,7 +826,7 @@ class sendMailNotification
|
||||
$mail_content = str_replace(["[[member_name]]", "{{member_name}}"], $full_name , $mail_content);
|
||||
|
||||
$wholeData[] = ['mail' => $value['email'], 'subject' => $subject,'message'=> $mail_content, 'reply_to' => $client_data['reply_to'], 'common' => $common];
|
||||
// $wholeData[] = ['mail' => $value['email'], 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails']];
|
||||
// $wholeData[] = ['mail' => $value['email'], 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails'}};
|
||||
}
|
||||
return $wholeData;
|
||||
}
|
||||
@ -1125,7 +1125,7 @@ class sendMailNotification
|
||||
$wholeData = [];
|
||||
foreach ($mail_array as $key => $value) {
|
||||
$wholeData[] = ['mail' => $value, 'subject' => $subject,'message'=> $mail_content, 'reply_to' => $client_data['reply_to'], 'common' => $common];
|
||||
// $wholeData[] = ['mail' => $value, 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails']];
|
||||
// $wholeData[] = ['mail' => $value, 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails'}};
|
||||
}
|
||||
|
||||
return $wholeData;
|
||||
|
||||
@ -194,6 +194,8 @@ if (!function_exists('get_chatbot_session_info')) {
|
||||
'emp_code' => $session->get('CHATBOT_EMP_CODE'),
|
||||
'client_id' => $session->get('CHATBOT_CLIENT_ID'),
|
||||
'chatbot_random_user_id' => $session->get('CHATBOT_RANDOM_USER_ID'),
|
||||
'client_branch_id' => $session->get('CHATBOT_CLIENT_BRANCH_ID'),
|
||||
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@ -1747,11 +1747,11 @@ class EmployeePolicyModel extends Model
|
||||
}
|
||||
|
||||
public function getHospitalLinkByPolicyandEmp($client_policy_id){
|
||||
$data = $this->db->table('employee_polices')
|
||||
$data = $this->db->table('client_policy')
|
||||
->select('tpa.network_hospitals')
|
||||
->where('client_policy_id', $client_policy_id)
|
||||
->where('employee_polices.is_active', 1)
|
||||
->join('tpa', 'tpa.id = employee_polices.tpa_id AND tpa.is_active = 1')
|
||||
->where('client_policy.id', $client_policy_id)
|
||||
// ->where('employee_polices.is_active', 1)
|
||||
->join('tpa', 'tpa.id = client_policy.tpa_id AND tpa.is_active = 1')
|
||||
// ->join('employees', 'employees.id = employee_polices.employee_id AND employees.id = ' . (int) $emp_id)
|
||||
->get()->getResultArray();
|
||||
|
||||
|
||||
59
phpqueue.sh
59
phpqueue.sh
@ -1,56 +1,7 @@
|
||||
!/bin/bash
|
||||
#!/bin/bash
|
||||
|
||||
while true; do
|
||||
echo "Running job at $(date)"
|
||||
/usr/bin/php /opt/lampp/htdocs/nhance/public/index.php cli/processjob
|
||||
!/bin/bash
|
||||
!/bin/bash
|
||||
|
||||
# Read the Job_Queue variable from the temporary file
|
||||
#!/bin/bash
|
||||
|
||||
#!/bin/bash
|
||||
|
||||
#!/bin/bash
|
||||
|
||||
# Define the root directory for the project and PID file path
|
||||
#!/bin/bash
|
||||
|
||||
# Define paths
|
||||
# ROOT_DIR=$(dirname "$(realpath "$0")")
|
||||
# JOB_QUEUE_FILE="$ROOT_DIR/job_queue"
|
||||
# PID_FILE="$ROOT_DIR/phpqueue.pid"
|
||||
|
||||
|
||||
# # Check if the script is already running
|
||||
# if [[ -f "$PID_FILE" ]] && kill -0 "$(cat $PID_FILE)" 2>/dev/null; then
|
||||
# echo "phpqueue.sh is already running. Exiting."
|
||||
# exit 1
|
||||
# fi
|
||||
|
||||
# # Write the current process ID (PID) to the PID file
|
||||
# echo $$ > "$PID_FILE"
|
||||
|
||||
# # Ensure the PID file is removed on script exit
|
||||
# trap "rm -f $PID_FILE" EXIT
|
||||
|
||||
# # Main loop
|
||||
# while true; do
|
||||
# # Check if the Job_Queue file exists
|
||||
# if [[ ! -f "$JOB_QUEUE_FILE" ]]; then
|
||||
# echo "Job Queue file not found."
|
||||
# exit 1
|
||||
# fi
|
||||
|
||||
# # Read the value of Job_Queue from the file
|
||||
# Job_Queue=$(cat "$JOB_QUEUE_FILE")
|
||||
|
||||
# if [[ "$Job_Queue" -eq 1 ]]; then
|
||||
# /usr/bin/php /opt/lampp/htdocs/nhance/public/index.php cli/processjob
|
||||
# else
|
||||
# echo "No job to process."
|
||||
# fi
|
||||
|
||||
# # Sleep for 1 second before the next iteration
|
||||
# sleep 1
|
||||
# done
|
||||
|
||||
/usr/bin/php /var/www/nhance/zenith/public/index.php cli/processjob
|
||||
sleep 1 # Optional: Add a sleep to avoid CPU overload
|
||||
done
|
||||
|
||||
11
writable/cache/.gitkeep
vendored
11
writable/cache/.gitkeep
vendored
@ -1,11 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Reference in New Issue
Block a user