Hide welcome message for repeating visitors

The first question in the chatbot can be set as the welcome message of the chatbot. This is helpful to catch the attention of the users and make the chatbot more interactive.

Below example, the first question is a Multi Choice Type and we see the question and the options as the welcome message.

Click 'const initWidget = () => {
        const iframeEl = window.parent.document.querySelector('iframe[data-form-id]');
        if (!iframeEl) return console.error('⚠️ ~ Widget preview: Missing parent...'

If you don't want repeating visitors to see the same welcome message again, you can do so by adding an extra piece of code. You just need to make sure that this extra code is added at the same place where you added the original code snippet for the chatbot.

Additional code

<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/js-cookie/2.2.1/js.cookie.min.js"></script>
<script> var collectchat = window.collectchat || {};
 collectchat.ready = function() {
    if(Cookies.get('collect_chat_closed')) {
       collectchat.config({
          welcomeMessage: -1
       });
    }
 }
</script>

The above code, reads the cookie, "collect_chat_closed" and if it is set, then turns off welcome message by changing the config settings.



Still need help?

Contact us

Customize