Skip to main content

Clear Session Storage (Script Tab)

Use the Script tab in the bot configuration page to run custom JavaScript when the ai12z-bot web control loads. The example below removes the first session storage entry that matches the ai12z-botState key pattern.

🛠️ Step 1: Open the Script tab

In the bot configuration page, go to Script and paste the following snippet into Custom JS.

🛠️ Step 2: Add the session storage cleanup script

const chatbot = document.querySelector("ai12z-bot");

if (chatbot) {
chatbot.componentOnReady().then(() => {
for (let i = 0; i < sessionStorage.length; i++) {
const key = sessionStorage.key(i);
if (key && key.includes("ai12z-botState")) {
sessionStorage.removeItem(key);
break;
}
}
});
}

🛠️ Step 3: Save and test

Click Save, refresh the page, and verify the bot loads with a cleared session state.

Common issues

  • Script does not run: Confirm the Script tab is enabled for the bot and the control is rendered on the page.
  • State still persists: Ensure no other script rewrites the same ai12z-botState key after removal.