Category / Section
Add a Custom Option in the More Options Menu of the Live Chat Widget
Published:
Mar 27, 2025
New
The More Options menu in the BoldChat widget allows users to add custom labels and functionalities tailored to their needs. This guide explains how to add a “Clear Session” option to reset the chat session.
Adding the “Clear Session” Option
Use the following JavaScript snippet to add a custom “Clear Session” option in the More Options menu of the chat widget.
<script type="text/javascript" >
// 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"]);
}
}
</script>
do:addOption
– Adds a new custom option to the More Options menu.onMoreOptionClick
- Event listener that called when a user selects a custom option.do:clearSession
- Clears the chat session by clearing the cache, effectively resetting the chat window for a new conversation.
Example Usage
By adding the Clear Session option, users can erase the ongoing conversation and start fresh by clearing the session data stored in the cache.
This customization enhances user control by allowing them to reset the chat session when needed.
See also
Did not find the solution
Contact Support