How to Add a Clear Session Option to the Live Chat Widget
This guide shows how to add a Clear Session item to the chat widget’s More Options menu. When clicked, it resets the chat session by clearing the widget’s cache.
Requirement: For this to work, the JavaScript code shown in one of the steps below must be added inside the Live Chat widget’s Custom JS setting (not on your website pages). The navigation path is illustrated below.
Use Cases
- Let customers start a fresh chat session when troubleshooting issues.
- Clear cached chat data to resolve widget-related problems.
- Reset conversations before sharing a device with another user.
- Allow visitors to quickly restart chats without refreshing the page.
- Improve support experiences by starting new conversations with a clean session.
- Give customers self-service control through a Clear Session option in the chat widget menu.
- Reduce confusion caused by outdated chat history or cached information.
Prerequisites
- A Live Chat widget you can Edit (or permission to Add Widget).
- To add a clear session option to the live chat widget, an Agent’s role must have the permission to Manage settings.
Where to Add the Code (Custom JS is Required)
-
Go to Admin → Chat → Live Chat
-
Open a widget
In the Live Chat list, either Edit an existing widget (⋮ → Edit) or click Add Widget to create a new one.
 -
Appearance → Advanced Customization → Custom JS → Add Custom JS
 -
Paste the code and click Add
 -
Click Update to save the widget

JavaScript to Add in Custom JS
// Initialize $boldChat as an empty array if not already defined
window.$boldChat = window.$boldChat || [];
/**
* Adds the "Clear Session" option to the chat widget's More Options menu.
*/
window.$boldChat.push(["do:addOption", "Clear Session"]);
/**
* Registers an event listener for custom option clicks.
* If "Clear Session" is clicked, it clears the chat session by clearing the cache.
*/
window.$boldChat.push(["on:moreOptionClick", onMoreOptionClick]);
function onMoreOptionClick(item) {
// Check if the clicked option is "Clear Session"
if (item.name === "Clear Session") {
// Clear the chat session
window.$boldChat.push(["do:clearSession"]);
}
}
Command reference
do:addOption— Adds Clear Session to the More Options menu.on:moreOptionClick— Listens for selections of custom options.do:clearSession— Clears cache and resets the chat session.
Result in the Customer Portal
Frequently Asked Questions
-
Where do I add the code so “Clear Session” appears in the customer-facing widget?
Add the code in the widget editor: Admin → Chat → Live Chat → (Edit/Add Widget) → Appearance → Advanced Customization → Custom JS → Add Custom JS, then click Update. -
What code adds the “Clear Session” option in the customer‑facing Live Chat widget?
window.$boldChat = window.$boldChat || []; window.$boldChat.push(["do:addOption", "Clear Session"]); window.$boldChat.push(["on:moreOptionClick", onMoreOptionClick]); function onMoreOptionClick(item){ if (item.name === "Clear Session") { window.$boldChat.push(["do:clearSession"]); } } -
What does
do:addOptiondo?
do:addOptionadds a custom menu item (in this guide, Clear Session) to the widget’s More Options menu. -
How does the widget detect that the visitor clicked Clear Session?
The widget calls the callback registered viaon:moreOptionClick, and the code checksitem.name === "Clear Session". -
What does
do:clearSessiondo?
do:clearSessionclears the widget cache and resets the chat session. -
What permission is required to configure this?
The agent role must have Manage Settings enabled in the admin module.