nhance/app/Views/chatbot.php
2025-03-01 10:33:53 +05:30

85 lines
3.1 KiB
PHP

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Insurance ChatBot</title>
</head>
<style type="text/css">
</style>
<body>
<h1>Welcome to Insurance ChatBot </h1>
<script>
// var botmanWidget = {
// frameEndpoint: 'https://localhost/PHP828APPS/ruc/nhance/chat', // This should match your CI4 route
// introMessage: "Hi! I am your Insurance Bot. How can I assist you today?",
// placeholderText: "Type your message here...",
// title: "Insurance Bot",
// mainColor: "#5C6BC0",
// bubbleBackground: "#673AB7"
// };
var emp_name = 'Kumar';
var uid = Math.floor(100000 + Math.random() * 900000);
console.log('CURRENT_USER' + uid);
var botmanWidget = {
chatServer: `<?=base_url('chat')?>`, // Make sure this URL is correct
frameEndpoint: `<?=base_url('widget')?>`, // This should match your CI4
title: "Ask ILA",
introMessage: "",
bubbleBackground: "#007bff",
mainColor: "#007bff",
placeholderText: "Type your message here...",
aboutText: "Insurance Assistant ILA",
enableAttachments: false,
// Add extra parameters
parameters: {
employee_id: '12288', //PK of emp
session_id: "XYZ789", // token
origin: "mobile", // origin
emp_code:"HTL-007",
client_id:159,
client_branch_id:125
}
};
// Send a first load request when the chat widget opens
// window.addEventListener("load", function () {
// setTimeout(function () {
// fetch("https://localhost/PHP828APPS/ruc/nhance/chat", {
// method: "POST",
// headers: { "Content-Type": "application/json" },
// body: JSON.stringify({ first_load: "true", user_id: "12345" })
// });
// }, 2000); // Slight delay to ensure the widget is ready
// });
window.addEventListener("load", function () {
setTimeout(function () {
if (window.botmanWidget) {
botmanChatWidget.open();
setTimeout(function(){
botmanChatWidget.sayAsBot('Hi '+ (typeof emp_name !== "undefined" && emp_name !== null && emp_name !== "" ? emp_name : "Guest User") +',This is ILA your Insurance Assistant, plz choose the following options')
botmanChatWidget.whisper('Hi');
},3000);
}
}, 2000); // Delay to ensure widget is initialized
});
</script>
<!-- <script src="https://cdn.jsdelivr.net/npm/botman-web-widget@latest"></script> -->
<!-- <script id="botmanWidget" src='https://cdn.jsdelivr.net/npm/botman-web-widget@0/build/js/chat.js'></script> -->
<!-- <script src='https://cdn.jsdelivr.net/npm/botman-web-widget@0/build/js/widget.js'></script> -->
<script src='https://cdn.jsdelivr.net/npm/botman-web-widget@0/build/js/widget.js'></script>
</body>
</html>