Chat Widget

Reset Chat History on Logout

Start a completely new Octocom browser session when a customer logs out or changes identity.

If multiple people can use your website in the same browser, reset Octocom when the signed-in customer logs out. This prevents the next person from seeing the previous customer's chat history.

Dispatch the clearOctocomHistory event from your logout flow:

window.dispatchEvent(new CustomEvent("clearOctocomHistory"));

Clear any identity or authentication data that your site passes to Octocom first, then dispatch the event:

function onCustomerLogout() {
  // Remove or replace customer-specific data managed by your website.
  localStorage.removeItem("octocom:data:sessionToken");
  localStorage.removeItem("octocom:data:customerId");

  // Disconnect Octocom from the previous browser session immediately.
  window.dispatchEvent(new CustomEvent("clearOctocomHistory"));
}

Use the custom-data key names from your own integration. Octocom does not automatically remove octocom:data:* values because those values are owned and managed by your website.

What the reset does

The widget immediately:

  • Removes the persisted Octocom browser-session ID.
  • Discards visible and in-memory conversation history, including any response currently streaming.
  • Clears cached conversation data so it cannot repopulate the widget.
  • Applies the same reset to other open tabs on the same website.
  • Starts a completely new browser session if the widget is open. If it is closed, a new session starts the next time it opens.

Server-side cleanup of the previous session is also attempted, but the browser reset does not wait for that request. The old history is removed from the widget even if the network is offline or the API call fails.

You can safely dispatch the event when the widget is open or closed. Dispatch it once for each confirmed logout or account change, after your site has cleared the old customer's identity data.

On this page