0

I'm using SalesForce Lightning Chat ESW version 5.0

When a user logs out from our site we want to clear all active chat sessions for that user.

Our implementation is basically:

  1. When the user logs out, the page is reloaded and we set a cookie called RememberToClearTheChat
  2. we initialize our chat by loading a Salesforce-script myOrganizationDomain/embeddedservice/5.0/esw.min.js and then we set up some config stuff like embedded_svc.settings.displayHelpButton = true; and then we do a call to embedded_svc.init with a bunch of params.
  3. Once embedded_svc.liveAgentAPI has been loaded, we check if the user has a cookie called RememberToClearTheChat and in that case we do embedded_svc.liveAgentAPI.endChat(); embedded_svc.liveAgentAPI.clearSession();

It works sometimes for some users - but in some cases it randomly throws errors.

The errors are thrown during clearSession(). They are thrown by the a script called aura_prod.js which salesforce loads internally. An example error is Uncaught Error: deleteSessionData requires two non-null arguments (domain, keys). Seems like the data is cleared halfway, and we end up in a semi broken state.

The desired result would be that the chat should be 'reset' to the default state, which is a minimized button that basically just says "start chat".

But the actual result is that the user sees an expanded chat window with an input field, but without a connected agent. So you can write messages that no one will see. And there's no UI avaiable to 'end chat' to get out of this faulty state.

Screenshot below: In this image you just see the default-label "Agent" - that's incorrect. In a functioning chat you should either be shown a "you have spot X in our queue" or you should see the name & avatar of a real agent.

Question: Should we clear the chat using a different method?

or do we need to wait for some specific event before running clearSession() ?

screenshot

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.