Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev
This commit is contained in:
commit
009caf04c5
@ -6,56 +6,64 @@ use App\Helpers\ChatbotHelper;
|
||||
use BotMan\BotMan\Messages\Conversations\Conversation;
|
||||
use BotMan\BotMan\Messages\Outgoing\Question;
|
||||
use BotMan\BotMan\Messages\Outgoing\Actions\Button;
|
||||
use BotMan\Drivers\Web\WebDriver;
|
||||
|
||||
class MainMenuConversation extends Conversation
|
||||
{
|
||||
protected $buttonsData = [
|
||||
"ecard_download" => ["response_text" => "📄 Ecard Download"],
|
||||
"network_hospital" => ["response_text" => "🏥 Network Hospital"],
|
||||
"reimbursement_claim" => ["response_text" => "💰 Reimbursement Claim Process"],
|
||||
"reimbursement_status" => ["response_text" => "📑 Reimbursement Claim Status"],
|
||||
"new_policy" => ["response_text" => "🆕 New Policy"],
|
||||
"renew_policy" => ["response_text" => "🔄 Renew Policy"],
|
||||
];
|
||||
|
||||
public function run()
|
||||
{
|
||||
|
||||
$this->bot->types(); // Typing indicator for the first message
|
||||
sleep(0.5); // Delay
|
||||
sleep(0.5); // Delay
|
||||
$this->showMainMenu();
|
||||
}
|
||||
|
||||
protected function showMainMenu()
|
||||
{
|
||||
$question = Question::create("Please choose")
|
||||
->addButtons([
|
||||
Button::create("📄 Ecard Download")->value("ecard_download"),
|
||||
Button::create("🏥 Network Hospital")->value("network_hospital"),
|
||||
Button::create("💰 Reimbursement Claim Process")->value("reimbursement_claim"),
|
||||
Button::create("📑 Reimbursement Claim Status")->value("reimbursement_status"),
|
||||
Button::create("🆕 New Policy")->value("new_policy"),
|
||||
Button::create("🔄 Renew Policy")->value("renew_policy"),
|
||||
]);
|
||||
$buttons = [];
|
||||
foreach ($this->buttonsData as $key => $data) {
|
||||
$buttons[] = Button::create($data['response_text'])->value($key);
|
||||
}
|
||||
|
||||
$this->bot->ask($question, function ($answer) {
|
||||
switch ($answer->getValue()) {
|
||||
$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;
|
||||
}
|
||||
|
||||
switch ($user_reponse) {
|
||||
case "ecard_download":
|
||||
|
||||
// $message = ChatbotHelper::get_payload_data();
|
||||
// $this->say($message);
|
||||
// $this->say("📄 Ecard Download Menu:");
|
||||
$this->bot->startConversation(new EcardDownloadConversation());
|
||||
break;
|
||||
case "network_hospital":
|
||||
$this->say("🏥 Network Hospital Menu:");log_message('error','Network Hospital clicked');
|
||||
log_message('error', 'Network Hospital clicked');
|
||||
$this->bot->startConversation(new NetworkHospitalConversation());
|
||||
break;
|
||||
case "reimbursement_claim":
|
||||
// $this->say("Reimbursement Claim Process selected. (Dummy Response)");
|
||||
$this->bot->startConversation(new ReimbursementClaimProcessConversation());
|
||||
break;
|
||||
case "reimbursement_status":
|
||||
$this->say("Reimbursement Claim Status selected. (Dummy Response)");
|
||||
$this->bot->startConversation(new ReimbursementClaimStatusConversation());
|
||||
|
||||
break;
|
||||
case "new_policy":
|
||||
$this->bot->startConversation(new policyConversation());
|
||||
break;
|
||||
case "renew_policy":
|
||||
$this->bot->startConversation(new policyConversation());
|
||||
$this->bot->startConversation(new PolicyConversation());
|
||||
break;
|
||||
default:
|
||||
$this->say("Invalid selection. Please choose an option.");
|
||||
@ -63,6 +71,7 @@ class MainMenuConversation extends Conversation
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,7 +22,8 @@ class NetworkHospitalConversation extends Conversation
|
||||
|
||||
protected function showHospitalMenu()
|
||||
{
|
||||
$policy_list = ChatbotHelper::getListOfPolicies();
|
||||
$chat_session_info = get_chatbot_session_info();
|
||||
$policy_list = ChatbotHelper::getListOfPolicies($chat_session_info);
|
||||
$buttons = [];
|
||||
$question = 'Choose Policy:';
|
||||
if(is_array($policy_list) && count($policy_list))
|
||||
|
||||
@ -26,7 +26,7 @@ class ChatbotControllerNew extends BaseController
|
||||
$this->myLogger = \Config\Services::mylogger();
|
||||
$this->session = \Config\Services::session();
|
||||
|
||||
$this->myLogger->logme('error', 'CALLED');
|
||||
// $this->myLogger->logme('error', 'CALLED');
|
||||
|
||||
// Load BotMan driver
|
||||
DriverManager::loadDriver(WebDriver::class);
|
||||
@ -46,22 +46,53 @@ class ChatbotControllerNew extends BaseController
|
||||
$extras = json_decode($extras);
|
||||
$router = service('router');
|
||||
$method = $router->methodName();
|
||||
$this->myLogger->logme('error', $method);
|
||||
// $this->myLogger->logme('error', $method);
|
||||
|
||||
if (isset($extras) && $method == 'widget') {
|
||||
$extras = $extras->parameters;
|
||||
$this->session->set('CHATBOT_USER_ID', $extras->employee_id);
|
||||
$this->session->set('CHATBOT_EMP_ID', $extras->employee_id);
|
||||
$this->session->set('CHATBOT_ORIGIN', $extras->origin);
|
||||
$this->session->set('CHATBOT_EMP_CODE', $extras->emp_code);
|
||||
$this->session->set('CHATBOT_CLIENT_ID', $extras->client_id);
|
||||
$this->session->set('CHATBOT_CLIENT_BRANCH_ID', $extras->client_branch_id);
|
||||
if($this->session->get('CHATBOT_RANDOM_USER_ID') == '')
|
||||
{
|
||||
$this->session->set('CHATBOT_RANDOM_USER_ID', '-');
|
||||
}
|
||||
}
|
||||
$log_message = [
|
||||
'CHATBOT_EMP_ID' => $this->session->get('CHATBOT_EMP_ID'),
|
||||
'CHATBOT_ORIGIN' => $this->session->get('CHATBOT_ORIGIN'),
|
||||
'CHATBOT_EMP_CODE' => $this->session->get('CHATBOT_EMP_CODE'),
|
||||
'CHATBOT_CLIENT_ID' => $this->session->get('CHATBOT_CLIENT_ID'),
|
||||
'CHATBOT_CLIENT_BRANCH_ID' => $this->session->get('CHATBOT_CLIENT_BRANCH_ID'),
|
||||
'CHATBOT_RANDOM_USER_ID' => $this->session->get('CHATBOT_RANDOM_USER_ID')
|
||||
];
|
||||
|
||||
$this->myLogger->logme('error', $this->session->get('CHATBOT_USER_ID'));
|
||||
$log_message = implode(' | ', array_map(
|
||||
fn($key, $value) => "{$key}: {$value}",
|
||||
array_keys($log_message),
|
||||
$log_message
|
||||
));
|
||||
|
||||
$this->myLogger->logme('error', $log_message);
|
||||
|
||||
// print_rr(ChatbotHelper::getListOfPolicies());die();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
if($this->session->get('CHATBOT_RANDOM_USER_ID') == '-' || $this->session->get('CHATBOT_RANDOM_USER_ID') == '')
|
||||
{
|
||||
|
||||
$user = $this->botman->getUser();
|
||||
$id = $user->getId();
|
||||
// $this->myLogger->logme('error', ('TEST' . $id));
|
||||
$this->session->set('CHATBOT_RANDOM_USER_ID', $id);
|
||||
}
|
||||
|
||||
$this->botman->hears('.*', function ($bot) {
|
||||
|
||||
$bot->types(); // Typing indicator for the first message
|
||||
sleep(0.5); // Delay
|
||||
});
|
||||
|
||||
@ -12,18 +12,23 @@ use App\Helpers\MailHelper;
|
||||
|
||||
class ChatbotHelper
|
||||
{
|
||||
|
||||
//get list of policies againest an employee_id
|
||||
public static function getListOfPolicies()
|
||||
public static function getListOfPolicies($chat_session_info)
|
||||
{
|
||||
|
||||
$emp_id = 12288;
|
||||
$emp_code = 'HTL-007';
|
||||
$client_id = 159;
|
||||
$policy_id = 0;
|
||||
$client_branch_id = 126;
|
||||
$relationship ='Father';
|
||||
// $emp_id = 12288;
|
||||
// $emp_code = 'HTL-007';
|
||||
// $client_id = 159;
|
||||
// $policy_id = 0;
|
||||
// $client_branch_id = 126;
|
||||
$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'];
|
||||
// $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){
|
||||
|
||||
@ -183,6 +183,21 @@ if (!function_exists('user_team')) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('get_chatbot_session_info')) {
|
||||
function get_chatbot_session_info()
|
||||
{
|
||||
// $CI =& get_instance();
|
||||
$session = \Config\Services::session();
|
||||
return [
|
||||
'emp_id' => $session->get('CHATBOT_EMP_ID'),
|
||||
'origin' => $session->get('CHATBOT_ORIGIN'),
|
||||
'emp_code' => $session->get('CHATBOT_EMP_CODE'),
|
||||
'client_id' => $session->get('CHATBOT_CLIENT_ID'),
|
||||
'chatbot_random_user_id' => $session->get('CHATBOT_RANDOM_USER_ID'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -21,6 +21,7 @@
|
||||
// mainColor: "#5C6BC0",
|
||||
// bubbleBackground: "#673AB7"
|
||||
// };
|
||||
var emp_name = 'Kumar';
|
||||
var uid = Math.floor(100000 + Math.random() * 900000);
|
||||
console.log('CURRENT_USER' + uid);
|
||||
var botmanWidget = {
|
||||
@ -35,12 +36,12 @@
|
||||
enableAttachments: false,
|
||||
// Add extra parameters
|
||||
parameters: {
|
||||
employee_id: '1234655', //PK of emp
|
||||
employee_id: '12288', //PK of emp
|
||||
session_id: "XYZ789", // token
|
||||
origin: "mobile", // origin
|
||||
emp_code:"EMP001",
|
||||
client_id:10,
|
||||
client_branch_id:12
|
||||
emp_code:"HTL-007",
|
||||
client_id:159,
|
||||
client_branch_id:125
|
||||
}
|
||||
};
|
||||
|
||||
@ -62,12 +63,12 @@
|
||||
if (window.botmanWidget) {
|
||||
botmanChatWidget.open();
|
||||
setTimeout(function(){
|
||||
botmanChatWidget.sayAsBot('Hi user '+ uid +' ,This is ILA your Insurance AI Assistant, plz choose the following options')
|
||||
botmanChatWidget.whisper('hi');
|
||||
},2000);
|
||||
botmanChatWidget.sayAsBot('Hi '+ emp_name +',This is ILA your Insurance Assistant, plz choose the following options')
|
||||
botmanChatWidget.whisper('Hi');
|
||||
},3000);
|
||||
|
||||
}
|
||||
}, 3000); // Delay to ensure widget is initialized
|
||||
}, 2000); // Delay to ensure widget is initialized
|
||||
});
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user