From 892879d5373efa8e82b8f8b83cda89f25efe410c Mon Sep 17 00:00:00 2001 From: velz Date: Sat, 2 Aug 2025 11:22:00 +0530 Subject: [PATCH 1/4] FIX_CHATBOT_LOG_COOKIE --- app/Controllers/Chatbot/EcardDownloadConversation.php | 2 +- app/Controllers/ChatbotControllerNew.php | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/Controllers/Chatbot/EcardDownloadConversation.php b/app/Controllers/Chatbot/EcardDownloadConversation.php index c38d6977..1f303c13 100644 --- a/app/Controllers/Chatbot/EcardDownloadConversation.php +++ b/app/Controllers/Chatbot/EcardDownloadConversation.php @@ -23,7 +23,7 @@ class EcardDownloadConversation extends Conversation $policy_list = ChatbotHelper::getListOfPolicies($chat_session_info); $buttons = []; $question = 'Choose Policy to Download Ecard:'; - log_message('error', ('policy_list : ' . json_encode($policy_list))); + // log_message('error', ('policy_list : ' . json_encode($policy_list))); if(is_array($policy_list) && count($policy_list)) { diff --git a/app/Controllers/ChatbotControllerNew.php b/app/Controllers/ChatbotControllerNew.php index dc38a3c9..e4ff0d15 100644 --- a/app/Controllers/ChatbotControllerNew.php +++ b/app/Controllers/ChatbotControllerNew.php @@ -25,9 +25,13 @@ class ChatbotControllerNew extends BaseController public function __construct() { set_session_context('CHATBOT CON'); + $this->myLogger = \Config\Services::mylogger(); $this->session = \Config\Services::session(); + $sessionID = session_id(); + $this->myLogger->logme('error', 'COOKIE - ' . $sessionID); + // $this->myLogger->logme('error', 'CALLED'); // Load BotMan driver @@ -51,6 +55,9 @@ class ChatbotControllerNew extends BaseController // $this->myLogger->logme('error', $method); if (isset($extras) && $method == 'widget') { + $request = \Config\Services::request(); + $cookieHeader = $request->getHeaderLine('Cookie'); + $extras = $extras->parameters; $this->session->set('CHATBOT_EMP_ID', $extras->employee_id); $this->session->set('CHATBOT_ORIGIN', $extras->origin); @@ -107,7 +114,7 @@ class ChatbotControllerNew extends BaseController sleep(0.5); // Delay }); // Start the Main Menu when user says "hi" or "start" - $this->botman->hears('start|hi|hello', function (BotMan $bot) { + $this->botman->hears('start|hi|hello|help|help me', function (BotMan $bot) { if ($this->isMemberLoggedIn){ $bot->reply('Hi how can i assist?'); $bot->startConversation(new MainMenuConversation()); From aea9753da0ced82c08f4549fa484c8f37d880278 Mon Sep 17 00:00:00 2001 From: velz Date: Sat, 2 Aug 2025 11:58:04 +0530 Subject: [PATCH 2/4] FIX_CHATBOT_MOBILE_VIEW --- app/Config/Routes.php | 1 + app/Controllers/ChatbotControllerNew.php | 7 +- app/Views/chatbot.php | 616 ++++++++++++++++++++--- app/Views/chatbottest.php | 84 ++++ 4 files changed, 642 insertions(+), 66 deletions(-) create mode 100644 app/Views/chatbottest.php diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 6e3e0e30..d35f2951 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -8,6 +8,7 @@ use CodeIgniter\Router\RouteCollection; */ $routes->post('/chat', 'ChatbotControllerNew::index'); $routes->get('/widget', 'ChatbotControllerNew::widget'); +$routes->get('/chatbottest', 'ChatbotControllerNew::chatbotest'); $routes->get('/chatbot', 'ChatbotControllerNew::chatbot'); $routes->get('/swagger', 'SwaggerController::index', ['filter' => 'authMVC']); diff --git a/app/Controllers/ChatbotControllerNew.php b/app/Controllers/ChatbotControllerNew.php index e4ff0d15..e60e74ef 100644 --- a/app/Controllers/ChatbotControllerNew.php +++ b/app/Controllers/ChatbotControllerNew.php @@ -146,9 +146,14 @@ class ChatbotControllerNew extends BaseController // } + public function chatbotest() + { + $this->loadLayout('chatbottest.php'); + } + public function chatbot() { - $this->loadLayout('chatbot.php'); + echo view('chatbot.php'); } public function widget() diff --git a/app/Views/chatbot.php b/app/Views/chatbot.php index 95bf5cde..4bd3db4b 100644 --- a/app/Views/chatbot.php +++ b/app/Views/chatbot.php @@ -4,81 +4,567 @@ Insurance ChatBot - - -

Welcome to Insurance ChatBot

- +

Loading...Please wait

+ + - - - - - + \ No newline at end of file diff --git a/app/Views/chatbottest.php b/app/Views/chatbottest.php new file mode 100644 index 00000000..95bf5cde --- /dev/null +++ b/app/Views/chatbottest.php @@ -0,0 +1,84 @@ + + + + + + Insurance ChatBot + + + + +

Welcome to Insurance ChatBot

+ + + + + + + + + + From f56b2afc8d7f9e6a9b14bdf7b7c1e58e5b60829f Mon Sep 17 00:00:00 2001 From: velz Date: Sat, 2 Aug 2025 12:15:08 +0530 Subject: [PATCH 3/4] FIX_CHATBOT_URL --- app/Views/chatbot.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Views/chatbot.php b/app/Views/chatbot.php index 4bd3db4b..cfcaae2e 100644 --- a/app/Views/chatbot.php +++ b/app/Views/chatbot.php @@ -27,8 +27,8 @@ var botmanWidget = { // chatServer: 'https://venbait.in/nhance/chatbot/chat', // frameEndpoint: 'https://venbait.in/nhance/chatbot/widget', - chatServer: 'https://localhost/PHP828APPS/ruc/nhance/chat', - frameEndpoint: 'https://localhost/PHP828APPS/ruc/nhance/widget', + chatServer: ``, + frameEndpoint: ``, title: "Ask ILA", placeholderText: "Type your message here...", aboutText: "Insurance Assistant ILA", From fd56103835086df95ece19cf232cf2d24db35c18 Mon Sep 17 00:00:00 2001 From: velz Date: Sat, 2 Aug 2025 12:41:59 +0530 Subject: [PATCH 4/4] FIX_CHATBOT_SW&URL --- app/Controllers/ChatbotControllerNew.php | 2 +- app/Views/chatbot.php | 2 +- service-worker.js | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/Controllers/ChatbotControllerNew.php b/app/Controllers/ChatbotControllerNew.php index e60e74ef..544c40d4 100644 --- a/app/Controllers/ChatbotControllerNew.php +++ b/app/Controllers/ChatbotControllerNew.php @@ -111,7 +111,7 @@ class ChatbotControllerNew extends BaseController log_message("error","Inside Bot Type Function"); $bot->types(); // Typing indicator for the first message - sleep(0.5); // Delay + sleep(0.1); // Delay }); // Start the Main Menu when user says "hi" or "start" $this->botman->hears('start|hi|hello|help|help me', function (BotMan $bot) { diff --git a/app/Views/chatbot.php b/app/Views/chatbot.php index cfcaae2e..5fd18fae 100644 --- a/app/Views/chatbot.php +++ b/app/Views/chatbot.php @@ -28,7 +28,7 @@ // chatServer: 'https://venbait.in/nhance/chatbot/chat', // frameEndpoint: 'https://venbait.in/nhance/chatbot/widget', chatServer: ``, - frameEndpoint: ``, + frameEndpoint: ``, title: "Ask ILA", placeholderText: "Type your message here...", aboutText: "Insurance Assistant ILA", diff --git a/service-worker.js b/service-worker.js index 349308f7..aa3577ae 100755 --- a/service-worker.js +++ b/service-worker.js @@ -12,10 +12,11 @@ self.addEventListener('activate', function(event) { // Fetch event self.addEventListener('fetch', function(event) { - // console.log('Fetching:', event.request.url); event.respondWith( - fetch(event.request).catch(function() { - return caches.match(event.request); + caches.match(event.request).then(function(response) { + // Respond with cached version or fetch from network + return response || fetch(event.request); }) ); }); +