Genesys Cloud - Main

 View Only

Sign Up

  Thread closed by the administrator, not accepting new replies.
  • 1.  Web Messenger - Clear conversation/History

    Posted 10-07-2024 09:52
    No replies, thread closed.

    Hi!

    We need to clear the session conversation/history every time we close the browser.
    When we use the chat widget on public devices, we need to grant that the next user dont see the previous conversation.

    I know that we have the "Clear Conversation" option on messenger cfg but we need an automatic way of do it in case the user forgot to use the bin icon.

    Can we add some code to load script to force a new session without previous history?
    How can this be done?

    Thks in advanced!


    #DigitalChannels


  • 2.  RE: Web Messenger - Clear conversation/History

    Posted 10-07-2024 10:26
    No replies, thread closed.

    Found a solution. Adding this script to the webpage:

    <script>
      // Function to clear local storage and specific cookies
      function clearSessionData() {
        // Clear local storage
        localStorage.clear();

        // Clear specific cookie
                    document.cookie = "messenger-session=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
      }

            // Call the function on page load to reset session data
      window.onload = function() {
            clearSessionData();
      }
    </script>  




  • 3.  RE: Web Messenger - Clear conversation/History

    Posted 10-07-2024 12:17
    No replies, thread closed.

    Hi Rui,

    Glad you found a solution and thank you for sharing it with the community



    ------------------------------
    Sam Jillard
    Online Community Manager/Moderator
    Genesys - Employees
    ------------------------------



  • 4.  RE: Web Messenger - Clear conversation/History
    Best Answer

    Posted 10-08-2024 03:12
    No replies, thread closed.

    Hello @Rui Tomás - please avoid clearing localStorage directly, but rather use our native Messenger command to clear the necessary browser storage entries, using Messenger.clear command: this is a safer approach, so that if we were to change storage location in future, we can guarantee backward compatibility. Additionally, this will limit clearing only Genesys related entries, without disrupting other localStorage variables that may be needed for your website.



    ------------------------------
    Angelo Cicchitto
    Genesys - Employees
    ------------------------------



  • 5.  RE: Web Messenger - Clear conversation/History

    Posted 10-08-2024 04:16
    No replies, thread closed.

    Thank you for clarifying that @Angelo Cicchitto



    ------------------------------
    Sam Jillard
    Online Community Manager/Moderator
    Genesys - Employees
    ------------------------------



  • 6.  RE: Web Messenger - Clear conversation/History

    Posted 10-08-2024 10:39
    No replies, thread closed.

    Hi Angelo.

    Thks for your solution, but i'm tying to use Messenger.clear command without success.

    Where should i put the command to clear all previous conversations on page load?