jQuery(document).ready(function(){
var chatstate = 1 ;
var start = 1;
var asst_id = 'asst_HOzHdv0uWtGv5RdD98E1TQi5';
var icon_option = 'only_icon' ;
var starters = ``;
$('body').delegate('.chat_close_b','click', async function(){
// var back_btn_text = 'Back';
if ( chatstate === 1 ) {
if ( icon_option != 'sidebar_icon') {
jQuery('.btntext').hide();
var src = 'https://catcheverycallai.com/chat_assets/images/cross-button.png';
jQuery(this).find('img').attr('src',src);
}
chatstate = 0;
jQuery('.insideChat').slideDown(500);
await delay(1300).then(function(){
jQuery('.chat_landing1').slideUp(1000);
jQuery('.chat_box').slideDown(1000);
});
}else{
if ( icon_option != 'sidebar_icon') {
var src = 'https://catcheverycallai.com/chat_assets/images/bot-icon.svg';
jQuery(this).find('img').attr('src',src);
}
chatstate = 1;
jQuery('.insideChat').slideUp();
await delay(300).then(function(){
jQuery('.chat_box').hide();
jQuery('.chat_landing1').show();
});
if ( icon_option != 'sidebar_icon' && icon_option != 'only_icon') {
jQuery('.btntext').show();
}
}
if (start == 1) {
start = 0;
await delay(1300).then(async function(){
startBot();
});
}
});
$("body").delegate('.bot_close_btn',"click", async function(event){
if ( icon_option != 'sidebar_icon') {
var src = 'https://catcheverycallai.com/chat_assets/images/bot-icon.svg';
jQuery('.chat_close_b').find('img').attr('src',src);
}
chatstate = 1;
jQuery('.insideChat').slideUp();
await delay(300).then(function(){
jQuery('.chat_box').hide();
jQuery('.chat_landing1').show();
});
if ( icon_option != 'sidebar_icon' && icon_option != 'only_icon') {
jQuery('.btntext').show();
}
});
async function delay(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
function startBot(){
printMsg(`Hello! I'm really sorry we missed your call earlier. How can I assist you today? I'd love to help with anything you need!
`+starters,'bot');
}
async function printMsg(msg, user, mode = 1) {
jQuery('#textbox').prop('disabled', true);
jQuery('#textbox').val('');
//jQuery('.backbtn').hide();
var currentDate = new Date();
var monthNames = [ "Jan", "Feb", "Mar", "Apr", "May", "Jun","Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
var day = currentDate.getDate();
var month = monthNames[currentDate.getMonth()];
var hour = currentDate.getHours();
var minute = currentDate.getMinutes();
var ampm = hour >= 12 ? 'pm' : 'am';
hour = hour % 12;
hour = hour ? hour : 12;
formattedTime = day + " " + month + " " + hour + ":" + (minute < 10 ? "0" + minute : minute) + " " + ampm;
const randomNum = Math.floor(Math.random() * 900000) + 100000;
let logo, MsElement;
var back_img = 'https://catcheverycallai.com/chat_assets/images/undo.png';
if (user == 'bot') {
MsElement = '