HTML help!!! PLEASE
# 🤝help
j
Hello, I am not a coder and got gpt to generate this code so that my bot pops up when a user clicks on the website. However it re-pops up everytime the user clicks on a different page on the website. Can someone please edit it that it only pops up once in one session and doesn't automatically pop up again if the user clicks off it. Thanks document.addEventListener('DOMContentLoaded', function () { // Wait for the DOM to be fully loaded setTimeout(function () { // Check if the device width is less than or equal to 767px (adjust the threshold as needed) if (window.innerWidth <= 767) { // Do nothing or apply different logic for mobile devices console.log('On a mobile device. Chatbot won\'t auto-open.'); } else { // Open the chat and start the conversation window.botpressWebChat.sendEvent({ type: 'show' }); window.botpressWebChat.sendEvent({ type: 'proactive-trigger' }); } }, 1000); // Adjust the delay (in milliseconds) as needed });
l
You can set a cookie on first load/interaction that will prevent it from triggering again - https://github.com/js-cookie/js-cookie
j
Thanks for the reply Ryan, really appreciate it. Could you please explain it a little more
l
Hi there, the page I linked gives you the info you need to work it out, or you could just ask GPT to rework your original code to include the cookie.js to set a cookie on page load & make it if cookie exists do X, else do Y.
j
Thanks!
4 Views