Search code examples
smooch

How to clear web messenger chat history for anonymous users


I am using the web messenger SDK and I need a way to clear the users chat history. I am unable to authenticate the user and therefore can't see a way to use the api. Is there a prefered way to do this with any built in methods or should I set something up to delete local storage?

Just to clarify I can't authorise the user or set a JWT. I only have any information I can obtain from the web messenger SKD.


Solution

  • To clear an anonymous (not logged in with a JWT) users' conversation history you can call the delete all messages API. This must be done as a server-to-server call; it can't be done from the browser alone.

    If that's not an option you certainly could clear keys from local storage, however this won't actually result in the user's messages being deleted server side. This option means the user is effectively establishing a new session as a new user with a blank new conversation.