(function() { const styleTag = document.createElement('style'); styleTag.innerHTML = ` @import url('https://fonts.googleapis.com/css2?family=Manrope:wght@200..800&display=swap'); @import url('https://fonts.googleapis.com/css2?family=Abril+Fatface&family=Alfa+Slab+One&family=Anton&family=Arima:wght@100..700&family=Baloo+Bhaina+2:wght@400..800&family=Cabin:ital,wght@0,400..700;1,400..700&family=Catamaran:wght@100..900&family=Coiny&family=Concert+One&family=Cormorant+Garamond:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300;1,400;1,500;1,600;1,700&family=Dosis:wght@200..800&family=Exo+2:ital,wght@0,100..900;1,100..900&family=Fjalla+One&family=Fredoka:wght@300..700&family=Glass+Antiqua&family=Josefin+Sans:ital,wght@0,100..700;1,100..700&family=Josefin+Slab:ital,wght@0,100..700;1,100..700&family=Lato:ital,wght@0,100;0,300;0,400;0,700;0,900;1,100;1,300;1,400;1,700;1,900&family=Lobster+Two:ital,wght@0,400;0,700;1,400;1,700&family=Merriweather:ital,wght@0,300;0,400;0,700;0,900;1,300;1,400;1,700;1,900&family=Montserrat+Alternates:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&family=Oswald:wght@200..700&family=Overpass:ital,wght@0,100..900;1,100..900&family=Oxygen:wght@300;400;700&family=Passion+One:wght@400;700;900&family=Patrick+Hand&family=Permanent+Marker&family=Raleway:ital,wght@0,100..900;1,100..900&family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&family=Rock+Salt&family=Rubik:ital,wght@0,300..900;1,300..900&family=Rufina:wght@400;700&family=Source+Code+Pro:ital,wght@0,200..900;1,200..900&family=Ubuntu:ital,wght@0,300;0,400;0,500;0,700;1,300;1,400;1,500;1,700&family=Varela+Round&family=Vollkorn:ital,wght@0,400..900;1,400..900&display=swap'); :root { --widget-white-color: #ffffff; --widget-secondary-color: #585C66; /* widget primary color */ --widget-color: #cc0000; --widget-heading-color: #172A51; /* widget question text color */ --widget-questions-text-color: #000000; /* widget ans text color */ --widget-ans-text-color: #444d54; --widget-border: #ECE8FB; /* widget button color */ --widget-btn-color: #990000; /* widget button bordor color */ --widget-btn-border: #0ed8d2; /* widget button text color */ --widget-btn-text-color: #ffffff; --widget-primary-gradient: linear-gradient(180deg, #1BEAE4 0%, var(--primary-color) 100%); --widget-transition: all 0.3s; --widget-font: "Roboto", sans-serif; --widget-font-style: normal } .wg_chat_widgets_wrap { z-index: 9999; position: fixed; font-family: var(--widget-font); font-style: var(--widget-font-style); font-size: 14px; line-height: 1.5; } .wg_chat_widgets_wrap.top_right { top: 30px; right: 30px; } .wg_chat_widgets_wrap.top_left { top: 30px; left: 30px; } .wg_chat_widgets_wrap.btm_right { right: 30px; bottom: 30px; } .wg_chat_widgets_wrap.btm_left { bottom: 30px; left: 30px; } .wg_chat_toggle { padding: 15px 20px; border-radius: 60px; background: var(--widget-btn-color); box-shadow: 0 0 40px rgba(0, 0, 0, .1); color: var(--widget-btn-text-color); display: flex; align-items: center; justify-content: center; font-size: 16px; position: relative; cursor: pointer; -webkit-animation: wg_tgl_ani 2s ease-out infinite; -moz-animation: wg_tgl_ani 2s ease-out infinite; animation: wg_tgl_ani 2s ease-out infinite; } .wg_toggle_text { font-size: 16px; margin: 0 5px 0 0; color: var(--widget-btn-text-color); font-style: var(--widget-font-style); } .wg_chat_bubble_arrow { content: ""; position: absolute; display: block; border-top: 20px solid transparent; border-bottom: 0 solid transparent; border-right: 20px solid var(--widget-btn-color); -webkit-transform: rotate(-25deg); -moz-transform: rotate(-25deg); transform: rotate(-25deg); left: -8px; bottom: 0; } .widget-open .wg_chat_toggleImg, .widget-open .wg_toggle_text { display: none; } .widget-open .wg_chat_toggle:after, .widget-open .wg_chat_toggle:before { opacity: 1; } .widget-open .wg_chat_toggle { padding: 27px 27px; } .wg_chat_toggle:after, .wg_chat_toggle:before { position: absolute; top: 0; left: 0; right: 0; bottom: 0; width: 2px; height: 13px; content: ""; background: var(--widget-white-color); margin: auto; opacity: 0; } .wg_chat_toggle:after { transform: rotate(45deg); } .wg_chat_toggle:before { transform: rotate(-45deg); } .wg_chat_box_wrapper { position: absolute; width: 400px; display: none; -webkit-animation: wg_box_ani .5s; -moz-animation: wg_box_ani .5s; animation: wg_box_ani .5s; display: none; }.wg_chat_text { color: var(--widget-questions-text-color); margin: 0; font-size: 13px; font-weight: 700; background: #ededed; border-radius: 10px 10px 10px 0px; padding: 7px 10px; font-style: var(--widget-font-style); position: relative; } .btm_right .wg_chat_box_wrapper { bottom: 100%; right: 0; margin-bottom: 20px; } .btm_left .wg_chat_box_wrapper { bottom: 100%; left: 0; margin-bottom: 20px; } .top_left .wg_chat_box_wrapper { top: 100%; left: 0; margin-top: 20px; } .top_right .wg_chat_box_wrapper { top: 100%; right: 0; margin-top: 20px; } .wg_chat_toggleImg { display: inline-flex; } .wg_chat_toggleImg > img { width: 20px; height: 20px; } .widget-open .wg_chat_box_wrapper { display: block; } .wg_chat_box_inner { background-color: var(--widget-white-color); box-shadow: 0 0 40px rgba(0, 0, 0, .1); border-radius: 5px; position: relative; overflow: hidden; } .wg_cb_header { padding: 15px 14px 14px; position: relative; background-color: var(--widget-color); min-height: 20px; } .wg_cb_title { display: flex; align-items: center; justify-content: end; } .wg_cb_title>h3 { margin: 0; font-size: 14px; font-weight: 600; color: var(--widget-white-color); } .wg_cb_close_chat { width: 15px; height: 15px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; vertical-align: middle; } .wg_logout_btn { display: inline-block; color: var(--widget-white-color); border: none; box-shadow: none; cursor: pointer; outline: 0; background: transparent; font-weight: 600; font-family: var(--widget-font); } .wg_cb_close_chat>span { width: 12px; height: 3px; background-color: var(--widget-white-color); border-radius: 5px; position: absolute; -webkit-transform: rotate(45deg); -moz-transform: rotate(45deg); transform: rotate(45deg); } .wg_cb_close_chat>span:last-child { -webkit-transform: rotate(-45deg); -moz-transform: rotate(-45deg); transform: rotate(-45deg); } .wg_login_box { padding: 15px 25px; -webkit-animation: wg_box_ani .5s; -moz-animation: wg_box_ani .5s; animation: wg_box_ani .5s; } .wg_body_ttl { margin: 0; margin-bottom: 5px; font-size: 16px; font-weight: 600; color: var(--widget-heading-color); font-style: var(--widget-font-style); } .wg_body_Sttl { margin: 0; margin-bottom: 20px; font-size: 13px; font-weight: 400; color: var(--widget-secondary-color); font-style: var(--widget-font-style); } .wg_input_label { color: var(--heading-color); font-size: 14px; font-weight: 500; margin-bottom: 5px; display: block; font-style: var(--widget-font-style); } .aisw_input_error { color: #ff0000; font-size: 14px; } .wg_input_wrapper { margin-bottom: 10px; } .wg_input { background: var(--widget-white-color); border: 1px solid var(--widget-border); border-radius: 6px; width: 100%; padding: 10px; font-size: 14px; font-weight: 400; color: var(--widget-secondary-color); outline: 0; font-style: var(--widget-font-style); } .wg_input::placeholder { color: #BFC7D3; } .wg_btn { background: var(--widget-color); border-width: 1px; border-color: var(--widget-color); border-style: solid; border-radius: 6px; display: flex; justify-content: center; align-items: center; color: var(--widget-btn-text-color); font-size: 15px; position: relative; z-index: 0; padding: 10px 20px; font-weight: 600; cursor: pointer; font-family: var(--widget-font); font-style: var(--widget-font-style); } .wg_btn:hover { background: var(--widget-color); border-color: var(--widget-color); color: var(--widget-btn-text-color); } .wg_chat_wrap { -webkit-animation: wg_box_ani .5s; -moz-animation: wg_box_ani .5s; animation: wg_box_ani .5s; } .wg_chat_header { display: flex; border-bottom: 1px solid #f1f1f1; align-items: center; padding: 5px 0px 10px 15px; } .wg_chat_h_title { color: var(--widget-heading-color); margin: 0; font-size: 13px; font-weight: 700; } .wg_chat_back { margin: 0 8px 0 0; width: 22px; height: 22px; border-radius: 50px; background-color: var(--widget-color); display: flex; align-items: center; justify-content: center; cursor: pointer; flex: none; } .wg_chat_avtar { margin-right: 10px; border: 2px solid var(--widget-color); border-radius: 50%; width: 30px; height: 30px; flex: none; overflow: hidden; } .wg_chat_avtar img { width: 100%; height: 100%; object-fit: cover; } .wg_receiver .wg_chat_text { border-radius: 15px 15px 0px 15px; } .wg_chat_body { padding: 15px 10px; max-height: 600px; max-height: calc(100vh - 200px); overflow: auto; min-height:200px } .wg_chat_box { margin-bottom: 10px; max-width: 90%; width: fit-content; display: flex; align-items: flex-start; } /* width */ .wg_custom_scroll::-webkit-scrollbar { width: 4px; } /* Track */ .wg_custom_scroll::-webkit-scrollbar-track { background: #f1f1f1; } /* Handle */ .wg_custom_scroll::-webkit-scrollbar-thumb { background: var(--widget-color); } .wg_receiver { margin-left: auto; } .wg_chat_btn { padding: 0; margin: 5px 0 0 0; list-style: none; } .wg_chat_btn>li { margin-bottom: 5px; } .wg_ans_btn { border-radius: 10px; color: var(--widget-white-color); cursor: pointer; display: block; padding: 10px 10px; font-weight: 500; background: var(--widget-color); font-style: var(--widget-font-style); } @-webkit-keyframes wg_box_ani { 0% { transform: translateY(15px); opacity: 0 } 50% { transform: translateY(-10px); opacity: 0.8 } 100% { transform: translateY(0); } } @-moz-keyframes wg_box_ani { 0% { transform: translateY(15px); opacity: 0 } 50% { transform: translateY(-10px); opacity: 0.8 } 100% { transform: translateY(0); opacity: 1 } } @keyframes wg_box_ani { 0% { transform: translateY(15px); opacity: 0 } 50% { transform: translateY(-10px); opacity: 0.8 } 100% { transform: translateY(0); opacity: 1 } } @-webkit-keyframes wg_tgl_ani { 0% { transform: scale(1, 1); } 50% { transform: scale(1.5, 1.5); } 100% { transform: scale(1, 1); } } @-moz-keyframes wg_tgl_ani { 0% { transform: scale(1, 1); } 50% { transform: scale(0.9, 0.9); } 100% { transform: scale(1, 1); } } @keyframes wg_tgl_ani { 0% { transform: scale(1, 1); } 50% { transform: scale(0.9, 0.9); } 100% { transform: scale(1, 1); } } .wg_wellcome_box { padding: 20px; text-align: center; display: flex; flex-direction: column; color: var(--widget-heading-color); } .wg_wellcome_ttl { font-size: 16px; margin: 0 0 20px; color: var(--widget-heading-color); } .wg_wellcome_box .wg_btn { margin: auto; } .wg_wc_avtar { overflow: hidden; border-radius: 50%; width: 100px; height: 100px; margin: auto auto 10px; background: #eee; } .wg_wc_avtar>img { width: 100%; height: 100%; object-fit: cover; } .wg_chat_typing { align-items: center; display: flex; height: 17px; } .wg_chat_dot { animation: widget_chat_effect 1.8s infinite ease-in-out; background-color: var(--widget-questions-text-color); border-radius: 50%; height: 6px; margin-right: 4px; vertical-align: middle; width: 6px; display: inline-block; } .wg_chat_dot:last-child { margin-right: 0px; } @keyframes widget_chat_effect { 0% { transform: translateY(0px); } 28% { transform: translateY(-7px); } 44% { transform: translateY(0px); } } .wg_chat_dot:nth-child(1) { animation-delay: 200ms; } .wg_chat_dot:nth-child(2) { animation-delay: 300ms; } .wg_chat_dot:nth-child(3) { animation-delay: 400ms; } .widget_single .wg_chat_toggle, .widget_single .wg_cb_close_chat { display: none; } .widget_single.wg_chat_widgets_wrap { display: flex; justify-content: center; align-items: center; position: fixed; top: 0; bottom: 0; left: 0; right: 0; } .widget_single .wg_chat_box_wrapper { display: block; position: inherit; right: auto; margin: 0; left: auto; top: auto; bottom: auto; } .widget_single .wg_wellcome_box { padding: 100px 20px; } .wg_chat_vector { display: none; } .wg_chat_click, .wg_chat_click:hover { color: var(--widget-color); } /* variation design -2 */ .widgets_variation2 .wg_chat_text{ position: relative; border-radius: 10px; background: #2C4059; } .widgets_variation2 .wg_chat_vector, .widgets_variation9 .wg_chat_vector{ position: absolute; left: -9px; top: 5px; display: block; } .widgets_variation2 .wg_chat_avtar { margin-right: 10px; } .widgets_variation2 .wg_receiver .wg_chat_vector, .widgets_variation9 .wg_receiver .wg_chat_vector { position: absolute; right: -8px; left: auto; transform: rotate(87deg); } .widgets_variation2 .wg_receiver { margin-left: auto; margin-right: 2px; } .widgets_variation2 .wg_chat_avtar, .widgets_variation3 .wg_chat_avtar, .widgets_variation4 .wg_chat_avtar, .widgets_variation5 .wg_chat_avtar, .widgets_variation6 .wg_chat_avtar, .widgets_variation7 .wg_chat_avtar, .widgets_variation8 .wg_chat_avtar, .widgets_variation11 .wg_chat_avtar{ margin-right: 10px; border: 2px solid var(--widget-color); border-radius: 50%; width: 30px; height: 30px; } /* variation design -2 */ /* / coupon code / */ .wg_couponCodeWrap { display: flex; grid-gap: 10px; max-width: 480px; width: 100%; margin-top: 10px; } /* / coupon code / */ /* variation design -3 */ .widgets_variation3 .wg_chat_text { background: #F0F2F4; border-radius: 10px; border: 1px solid #E7E9EC; } .widgets_variation3 .wg_chat_btn { background: #F0F2F4; border-radius: 10px; border: 1px solid #E7E9EC; padding: 10px; } .widgets_variation3 .wg_qusBox .wg_chat_text { background: #2C4059; color: #fff; } .widgets_variation3 .wg_receiver .wg_chat_text { border-radius: 10px; background: #2C4059; color: #fff; } /* variation design -4 */ .widgets_variation4 .wg_chat_text { background: #F7EDFF; } .widgets_variation4 .wg_qusBox .wg_chat_text, .widgets_variation4 .wg_receiver .wg_chat_text { background: var(--widget-color); color: #fff; } .widgets_variation4 .wg_ans_btn { border-radius: 10px 10px 10px 0; color: var(--widget-heading-color); background: #FFEED3; } .widgets_variation4 .wg_chat_btn > li:nth-child(02) .wg_ans_btn { background: #CCE7FF; } .widgets_variation4 .wg_chat_btn > li:nth-child(03) .wg_ans_btn { background: #FFD3F8; } .widgets_variation4 .wg_chat_btn > li:nth-child(04) .wg_ans_btn { background: #ffd3d3; } /* variation design -5 */ .widgets_variation5 .wg_chat_text { border-radius: 10px 0px 10px 0px; background: #F0F2F4; } .widgets_variation5 .wg_chat_text { box-shadow: -4px 4px 0px 0px rgb(0 0 0 / 25%); } .widgets_variation5 .wg_qusBox .wg_chat_text { background: #1B2C44; color: #fff; box-shadow: -4px 4px 0px 0px #0E1724; } .widgets_variation5 .wg_receiver .wg_chat_text { background: #1B2C44; color: #fff; border-radius: 0 10px 0px 10px; box-shadow: -4px 4px 0px 0px #0E1724; } .widgets_variation5 .wg_ans_btn { border-radius: 10px 0px 10px 0px; } .widgets_variation5 .wg_chat_btn { margin: 10px 0 0 0; } /* variation design -6 */ .widgets_variation6 .wg_chat_text, .widgets_variation6 .wg_ans_btn { background: #ECEEED; border: 1px solid #E2E2E2; border-radius: 40px; color:var(--widget-questions-text-color); padding: 15px 20px; } .widgets_variation6 .wg_qusBox .wg_chat_text, .widgets_variation6 .wg_receiver .wg_chat_text { background: var(--widget-color); color: #fff; border-radius: 10px; } /* variation design -7 */ .widgets_variation7 .wg_chat_text { border-radius: 0 5px 5px 5px; position: relative; color:#3A2A46; } .widgets_variation7 .wg_chat_dot{ background:#3A2A46; } .widgets_variation7 .wg_chat_text:after { content: ""; position: absolute; left: 0; bottom: 0; border-left: 10px solid red; border-top: 10px solid green; border-right: 10px solid black; border-bottom: 10px solid brown; } .widgets_variation7 .wg_chat_text:after { content: ""; position: absolute; left: -7px; top: 0px; border-left: 7px solid transparent; border-top: 7px solid #ededed; border-right: 7px solid #ededed; border-bottom: 7px solid transparent; bottom: auto; right: auto; } .widgets_variation7 .wg_receiver .wg_chat_text:after { left: auto; top: auto; bottom: 0; right: -7px; border-left: 7px solid #ededed; border-top: 7px solid transparent; border-right: 7px solid transparent; border-bottom: 7px solid #ededed; } .widgets_variation7 .wg_receiver .wg_chat_text { border-radius: 5px 5px 0px 5px; background: var(--widget-color); color:var(--widget-questions-text-color); } .widgets_variation7 .wg_receiver .wg_chat_text:after { left: auto; } .widgets_variation7 .wg_qusBox .wg_chat_text { background: var(--widget-color); color: var(--widget-questions-text-color); } .widgets_variation7 .wg_qusBox .wg_chat_text:after { border-top-color: var(--widget-color); border-right-color: var(--widget-color); } .widgets_variation7 .wg_receiver .wg_chat_text:after { border-left-color: var(--widget-color); border-bottom-color: var(--widget-color); } .widgets_variation7 .wg_ans_btn { color: #3A2A46; background: #ededed; box-shadow: -3px 0px 0px 0px var(--widget-color); } /* variation design -8 */ .widgets_variation8 .wg_chat_text { background: #ECEEED; border-radius: 0; } .widgets_variation8 .wg_receiver .wg_chat_text { background: var(--widget-color); color: #ffffff; } .widgets_variation8 .wg_ans_btn { background: #1B2C44; border-radius: 0; } /* variation design -9 */ .widgets_variation9 .wg_chat_text { background: #2C4059; border-radius: 10px; } .widgets_variation9 .wg_chat_avtar { display: none; } .widgets_variation9 .wg_chat_des { margin-left: 10px; } .widgets_variation9 .wg_receiver .wg_chat_des { margin: 0 10px 0 0; } /* variation design -10 */ .widgets_variation10 .wg_chat_text { background: #DFEDFF; border-radius: 10px; border: 1px solid #2C4059; } .widgets_variation10 .wg_ans_btn { background: transparent; color: var(--widget-color); border: 1px solid var(--widget-color); } .widgets_variation10 .wg_chat_avtar { display: none; } /* variation design -11 */ .widgets_variation11 .wg_chat_text { background: #ECEEED; border-radius: 0px 20px 20px 20px ; color:#3A2A46; } .widgets_variation11 .wg_chat_text:after { content: ""; position: absolute; left: -7px; top: 0px; border-left: 7px solid transparent; border-top: 7px solid #ededed; border-right: 7px solid #ededed; border-bottom: 7px solid transparent; bottom: auto; right: auto; } .widgets_variation11 .wg_receiver .wg_chat_text:after { left: auto; top: auto; bottom: 0; right: -7px; border-left: 7px solid #ededed; border-top: 7px solid transparent; border-right: 7px solid transparent; border-bottom: 7px solid #ededed; } .widgets_variation11 .wg_receiver .wg_chat_text:after { left: auto; } .widgets_variation11 .wg_receiver .wg_chat_text:after { border-left-color: var(--widget-color); border-bottom-color: var(--widget-color); } .widgets_variation11 .wg_receiver .wg_chat_text { border-radius: 20px 20px 0px 20px; background: var(--widget-color); color: var(--widget-questions-text-color); } .widgets_variation11 .wg_chat_btn { background: #ECEEED; padding: 10px; border-radius: 10px; } .widgets_variation11 .wg_ans_btn { box-shadow: 0px 2px 4px 0px rgb(0 0 0 / 10%); color: #3A2A46; background: #ffffff; } `; document.head.appendChild(styleTag); const widgetContainer = document.createElement('div'); widgetContainer.className = 'widget-container'; widgetContainer.innerHTML = `

Click Here

\"image\" AiSalesConverter
\"image\"/

Hello, I\'m Mike, and I\'ll help you find the best product based on your requirements

`; document.body.appendChild(widgetContainer); const scriptTag = document.createElement('script'); scriptTag.innerHTML = ` console.log( 'dom loaded' ) let wdg_cur_staip = 0; let _wgd_current_questn = 0; const wdg_chat_delay = 1000; const wdg_all_staips = ["welcome","questionnaire"]; const arr1 = [{ role: 'system', type: 'greeting', status: 'show', conversation: 'Hello' }, { role: 'system', type: 'greeting', status: 'show', conversation: "Answer few questions and you\'ll the best match possible." } ]; const arr2 = [{"role":"system","type":"ai_question","status":"hide","conversation":"What type of content do you prefer to share on Facebook?","options":["Text posts","Images","Videos","Clickable graphics"],"answer":""},{"role":"system","type":"question_resp","status":"hide","conversation":"Your choice of *[option]* is a smart one! Many find it very helpful in achieving their goals."},{"role":"system","type":"ai_question","status":"hide","conversation":"How important is it for you to redirect your audience to external websites?","options":["Not important","Somewhat important","Important","Very important"],"answer":""},{"role":"system","type":"question_resp","status":"hide","conversation":"With *[option]* as your choice, the results could be very rewarding. Let\u2019s dive into details if you'd like."},{"role":"system","type":"ai_question","status":"hide","conversation":"Have you ever faced restrictions in sharing links on Facebook?","options":["Yes, frequently","Occasionally","Rarely","Never"],"answer":""},{"role":"system","type":"question_resp","status":"hide","conversation":"Your choice of *[option]* reflects a trending approach. It\u2019s a strong direction to take."},{"role":"system","type":"ai_question","status":"hide","conversation":"What is your primary goal for posting on social media?","options":["Engagement","Driving traffic","Brand awareness","Sales conversion"],"answer":""},{"role":"system","type":"question_resp","status":"hide","conversation":"Great to see you went with *[option]*. This choice has a lot of potential."},{"role":"system","type":"ai_question","status":"hide","conversation":"How visually appealing do you find clickable graphics compared to other content types?","options":["Not appealing","Somewhat appealing","Appealing","Very appealing"],"answer":""},{"role":"system","type":"question_resp","status":"hide","conversation":"Getting the perfect match for you..."}]; const wdg_questionnaire_record = arr1.concat(arr2); const wdg_post_data = new FormData(); wdg_post_data.append('camp_id', 128); wdg_post_data.append('csrf_aisales', '80002b48eda09165cde859e06966e47a'); wdg_post_data.append('preview', ''); const getQuestions = (_this, selectd_optn = '') => { let html = ''; if( _this.role == 'system' ){ if( _this.type == 'greeting' ){ html = '
image

'+_this.conversation +'

'; }else if( _this.type == 'question_resp' ){ html = '
image

'+ _this.conversation.replace('[option]', selectd_optn) +'

'; } else if( _this.type == 'ai_question' ){ let options_html = '', indx = 1; _this.options.forEach(element => { options_html += '
  • '+element+'
  • '; indx ++; }); html = '
    image

    '+ _this.conversation +'

    '; } }else if( _this.role == 'user' ){ if( _this.type == 'choosen'){ html = '

    '+_this.conversation +'

    '; } } return html; } function getTypingIndicator() { return '
    image
    '; } function manageQuestionnaire(indx, selectd_optn = '', user_side = false){ const questionnire_container = document.getElementById('wgd_questionnaire_container'); if(user_side){ questionnire_container.innerHTML += getQuestions({ role: 'user', type: 'choosen', status: 'show', conversation: selectd_optn }, selectd_optn); return false; } _wgd_current_questn = indx; if( wdg_questionnaire_record[indx] != undefined ){ questionnire_container.innerHTML += getTypingIndicator(); setTimeout(() => { document.getElementById('wbd_typing_indicator').remove(); questionnire_container.innerHTML += getQuestions(wdg_questionnaire_record[indx], selectd_optn); const popup_container = document.querySelector('#wgd_questionnaire_container'); wgdScrollToBottom(popup_container); }, 500); // on last question generate ai response if( _wgd_current_questn == wdg_questionnaire_record.length-1 ){ if( checkCurrentStepCompleted() ){ return false; } const cur_step_name = wdg_all_staips[wdg_cur_staip]; if( cur_step_name == 'questionnaire' ){ wdg_cur_staip = 0; document.querySelector('.next_step').click(); } } } else _wgd_current_questn--; const popup_container = document.querySelector('#wgd_questionnaire_container'); wgdScrollToBottom(popup_container); } const wgdDelay = (ms) => { return new Promise(resolve => setTimeout(resolve, ms)); } async function wgdDelayedLoop() { for (let i = 0; i < 3; i++) { manageQuestionnaire(i); await wgdDelay(wdg_chat_delay); // Delay of 1 second } } const wgdScrollToBottom = (div) => { div.scrollTo({ top: div.scrollHeight, behavior: 'smooth' }); } const isValidEmailWGD = (email) => { return /^[^\\s@]+@[^\\s@]+\.[^\\s@]+$/.test(email); } const checkCurrentStepCompleted = () => { let errors = 0; if( wdg_all_staips[wdg_cur_staip] != undefined ){ const stepName = wdg_all_staips[wdg_cur_staip]; if( stepName == 'optinform' ){ const optin_u_name = document.getElementById('bot_user_name'); const optin_u_email = document.getElementById('bot_user_email'); if( !optin_u_name.value.trim().length ){ optin_u_name.setAttribute('style', 'border-color: red;'); if( !document.querySelectorAll('.name_aid_error_msg').length ){ optin_u_name.insertAdjacentHTML('afterend', 'Please enter your name'); } errors++; }else{ document.querySelectorAll('.name_aid_error_msg').forEach(element => element.remove()); } if( !optin_u_email.value.trim().length ){ optin_u_email.setAttribute('style', 'border-color: red;'); if( !document.querySelectorAll('.email_aid_error_msg').length ){ optin_u_email.insertAdjacentHTML('afterend', 'Please enter your email'); } errors++; }else{ document.querySelectorAll('.email_aid_error_msg').forEach(element => element.remove()); } if( !isValidEmailWGD(optin_u_email.value) ){ optin_u_email.setAttribute('style', 'border-color: red;'); if( !errors && !document.querySelectorAll('.email_aid_error_msg').length && !document.querySelectorAll('.email_valid_aid_error_msg').length ){ optin_u_email.insertAdjacentHTML('afterend', 'Please enter valid email'); } errors++; }else{ document.querySelectorAll('.email_valid_aid_error_msg').forEach(element => element.remove()); } if( !errors ){ // wdg_post_data[stepName] = {u_name: optin_u_name.value, u_email: optin_u_email.value }; wdg_post_data.append(stepName, JSON.stringify({u_name: optin_u_name.value, u_email: optin_u_email.value }) ); } } else if( stepName == 'questionnaire' ){ const answerIds = []; for (let index = 0; index < 5; index++) { const checkedOptions = document.querySelectorAll('.wgd_options.wgd_active'); const checkedAnswers = document.querySelectorAll('.wgd_options.wgd_active'); let getIndx = checkedOptions[index] !== undefined && checkedAnswers[index] !== undefined ? parseInt(checkedAnswers[index].getAttribute('data-index')) : 0; answerIds.push(getIndx); if( getIndx == 0 ){ errors++; console.log('complete all questions'); } } if( !errors ){ // wdg_post_data[stepName] = answerIds; wdg_post_data.append(stepName, answerIds); } } } return errors; } document.querySelector('.widgetToggleButton').addEventListener('click', function() { const parentDiv = document.querySelector('.widgetToggleParent'); parentDiv.classList.toggle('widget-open'); }); document.querySelector('.widgetCloseButton').addEventListener('click', function() { const parentDiv = document.querySelector('.widgetToggleParent'); parentDiv.classList.toggle('widget-open'); }); document.addEventListener('click', function(e) { // Options clicked if(e.target.classList.contains('wgd_options')){ const closestQuestion = e.target.closest('.wg_chat_des').querySelector('.wgd_question'); if (closestQuestion && !closestQuestion.classList.contains('wgd_answered')) { closestQuestion.classList.add('wgd_answered'); e.target.classList.add('wgd_active'); const selectd_optn = e.target.textContent; // show response of selected option manageQuestionnaire(0, selectd_optn, true); manageQuestionnaire(++_wgd_current_questn, selectd_optn); // show next option in seconds setTimeout(() => { manageQuestionnaire(++_wgd_current_questn); }, wdg_chat_delay); } } // Next step button click if (e.target.classList.contains('next_step')) { if( checkCurrentStepCompleted() ){ return false; } wdg_cur_staip++; if( wdg_all_staips[wdg_cur_staip] != undefined ){ const greeting_questions = document.querySelector('.wg_chat_box.wgd_greet_msg'); document.querySelectorAll('.wgd_sections').forEach(element => { element.style.display = 'none'; }); if( wdg_all_staips[wdg_cur_staip] == 'questionnaire' && !greeting_questions ){ wgdDelayedLoop(); } document.getElementById( wdg_all_staips[wdg_cur_staip]).style.display = 'block'; // is last step if( wdg_cur_staip == wdg_all_staips.length -1 ){ if( checkCurrentStepCompleted() ){ return false; } const popup_container = document.querySelector('#wgd_questionnaire_container'); wgdScrollToBottom(popup_container); fetch('https://aisalesconverter.com/AiRequests/generateairesponse' , { method: "POST", body: wdg_post_data }) .then(response => response.json()) .then(data => { console.log(data); if( data.status == 'success' ){ const questionnire_container = document.getElementById('wgd_questionnaire_container'); questionnire_container.innerHTML += getQuestions({ role: 'system', type: 'greeting', status: 'show', conversation: data.response } ); if( data?.response_arr?.coupon_html ){ questionnire_container.innerHTML += data?.response_arr?.coupon_html; } const popup_container = document.querySelector('#wgd_questionnaire_container'); wgdScrollToBottom(popup_container); }else{ const questionnire_container = document.getElementById('wgd_questionnaire_container'); questionnire_container.innerHTML += getQuestions({ role: 'system', type: 'greeting', status: 'show', conversation: data?.response_status } ); } }) .catch(error => { console.error("Error:", error); }); } }else{ wdg_cur_staip--; } } if(event.target.id == 'wbd_prod_link'){ if( localStorage.getItem('wbdUserConversion_128') != 'true' ){ localStorage.setItem('wbdUserConversion_128', true); wdg_post_data.append('t_achieved', true); wdg_post_data.append('t_id', event.target.getAttribute('data-prod-id')); fetch('https://aisalesconverter.com/AiRequests/saveanalytics' , { method: "POST", body: wdg_post_data }); } } }); document.getElementById('getstarted').addEventListener('click', function() { if( localStorage.getItem('wbdUserVisit_128') != 'true' ){ localStorage.setItem('wbdUserVisit_128', true); fetch('https://aisalesconverter.com/AiRequests/saveanalytics' , { method: "POST", body: wdg_post_data }); } }); function copyAiSalesText(text) { // Create a temporary textarea element const textarea = document.createElement("textarea"); textarea.value = text; // Prevent it from being visible and affecting layout textarea.style.position = "absolute"; textarea.style.left = "-9999px"; // Append it to the body document.body.appendChild(textarea); // Select the text textarea.select(); textarea.setSelectionRange(0, text.length); // For mobile devices // Copy the text try { document.execCommand("copy"); console.log("Text copied to clipboard!"); document.getElementById('aiw_coupon_txt_btn').innerText = 'Copied'; } catch (err) { console.error("Failed to copy text: ", err); } // Remove the textarea from the document document.body.removeChild(textarea); } `; document.head.appendChild(scriptTag); })();