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
});