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