When and How to Reset Visitor Context
Last updated: October 26, 2026
resetContext() clears the visitor details waiting in the browser, so the next conversation starts with nothing carried over. Reach for it whenever the person at the keyboard might not be the person the stored context describes.
When should you reset visitor context?
Call resetContext() when:
A visitor logs out.
Someone else might use the same browser, such as on a shared or kiosk machine.
Account, company or entitlement data you sent earlier is no longer accurate.
A form is cancelled and its values should not be reused.
Your single-page app moves the visitor into a journey that needs different context.
You do not need to reset after a successful conversation. Docket clears the pending payload once the backend confirms the conversation was created.
How do you reset the pending context?
const result = await window.AISeller.resetContext();
if (!result.success) {
console.warn("Docket context was not reset:", result.message);
}On success the result reads { success: true, message: "Context reset successfully" }. The method stores an empty object in place of the old payload, so the next conversation is created without the previous values.
How do you switch to a different visitor?
Reset first, then set the complete context for the new person.
const resetResult = await window.AISeller.resetContext();
if (resetResult.success) {
const setResult = await window.AISeller.setContext({
name: "Morgan",
company: "Contoso Research"
});
if (setResult.success) {
window.AISeller.showAndConnect();
}
}Strictly speaking setContext() already replaces the whole payload, so the reset is belt and braces. It is worth keeping when identity changes, because it makes the intent obvious and leaves nothing behind if the second call fails.
How do you check that the reset worked?
Set test context and start a conversation.
End the conversation.
Call
resetContext()and confirmsuccessistrue.Start another conversation without setting new context.
Confirm the agent does not reuse the earlier values.
Frequently asked questions
Does resetting affect a conversation that is already open?
No. A running conversation keeps the context it started with. The reset applies to the next one.
Do I need to reset after every conversation?
No. The pending payload is cleared automatically once Docket confirms the conversation. Reset when identity changes, not routinely.
Is resetContext() enough before a different person uses the same browser?
It clears the pending context Docket holds. It does not sign anyone out of your own application or clear your own cookies, so pair it with your normal logout handling.
What is the difference between resetContext() and just calling setContext() again?
setContext() replaces the whole payload, so it also removes old fields. Use resetContext() when you want to clear values without having new ones to send.
Is there an automatic reset anywhere?
Yes, on a standalone or embedded agent page. Loading it with no ctx_ parameters clears context left from an earlier visit. See Passing Context via URL Parameters to Marketing Agents.