diff --git a/app/Controllers/Chatbot/EcardDownloadConversation.php b/app/Controllers/Chatbot/EcardDownloadConversation.php index 1f303c13..a0a644a0 100644 --- a/app/Controllers/Chatbot/EcardDownloadConversation.php +++ b/app/Controllers/Chatbot/EcardDownloadConversation.php @@ -10,8 +10,11 @@ use App\Helpers\ChatbotHelper; class EcardDownloadConversation extends Conversation { + protected $buttonsData = []; public function run() { + $this->bot->types(); + sleep(0.5); $this->showEcardMenu(); } @@ -22,6 +25,7 @@ class EcardDownloadConversation extends Conversation $chat_session_info = get_chatbot_session_info(); $policy_list = ChatbotHelper::getListOfPolicies($chat_session_info); $buttons = []; + $question = 'Choose Policy to Download Ecard:'; // log_message('error', ('policy_list : ' . json_encode($policy_list))); @@ -34,20 +38,24 @@ class EcardDownloadConversation extends Conversation // Button::create("🔹 $policy['policy_name']")->value("$policy['emp_policy_id']"), // Button::create("◀️ Go Back")->value("go_back"), // ]); - $buttons[] = Button::create("🔹 {$policy['policy_name']}")->value($policy['emp_policy_id'].'#'.$policy['rand_string']); + $this->buttonsData[$policy['emp_policy_id'].'#'.$policy['rand_string']] = ['response_text' => "🔹 {$policy['policy_name']}"] ; + $buttons[] = Button::create("{$policy['policy_name']}")->value($policy['emp_policy_id'].'#'.$policy['rand_string']); } } else { $question = 'No policy found'; } + $this->buttonsData['go_back'] = ['response_text' => '◀️ Go Back'] ; $buttons = array_merge($buttons,[Button::create("◀️ Go Back")->value("go_back")]); $question = Question::create($question) ->addButtons($buttons); - - $this->bot->ask($question, function ($answer) { + $temp = $this->buttonsData; + $this->bot->ask($question, function ($answer) use ($temp) { + log_message('error', 'showEcardMenu answer received'); + log_message('error', ($answer)); $selectedOption = $answer->getText(); - $this->say("You have selected {$selectedOption}"); + $this->say("You have selected {$temp[$selectedOption]['response_text']}"); switch ($answer->getValue()) { case "go_back": $this->bot->startConversation(new MainMenuConversation()); diff --git a/app/Views/chatbot.php b/app/Views/chatbot.php index b6e09688..39bb88c4 100644 --- a/app/Views/chatbot.php +++ b/app/Views/chatbot.php @@ -2,7 +2,7 @@ - + Insurance ChatBot @@ -12,8 +12,8 @@ margin: 0; } - body { - background-color: rgba(0, 0, 0, 0.3); /* 30% transparent black */ + /* body { + background-color: rgba(0, 0, 0, 0.3); display: flex; justify-content: center; align-items: center; @@ -31,15 +31,72 @@ 50% { color: green; } 75% { color: blue; } 100% { color: violet; } - } + }*/ + + + + -

Loading...

- - + + +
+
+ + Loading... + +
+
+ + + + + + \ No newline at end of file