Back to docs

Guide

Chat History & Returning Visitors

When a visitor comes back to your website, the chat widget reopens their previous conversation and reloads earlier messages — so they can pick up right where they left off.

How returning visitors are remembered

The widget gives each visitor an anonymous ID that it stores in their browser. The next time they open the chat on the same browser, Sonny uses that ID to find their conversation and load its message history automatically — no sign-in required.

Durable by default

The visitor's ID is saved in two places — local storage and a first-party cookie — and each one restores the other if it goes missing. This keeps history visible even when a site clears one of them (for example on logout).

Self-healing sessions

If a visitor leaves the widget open for a long time, its secure session refreshes automatically in the background so history keeps loading without a page reload. If a load ever fails, the widget shows a Try again button instead of an empty screen.

When previous messages don't show up

Because anonymous history lives in the visitor's browser, it won't appear in a few situations:

A different browser or device

History is tied to the browser it was started in. Opening the same site in a different browser, on a phone vs a laptop, or in a private/incognito window starts a fresh conversation.

Cleared browsing data

If the visitor clears cookies and site data, the widget can no longer recognize them and previous messages won't load.

A site that wipes storage on logout

Some websites clear all browser storage when a user logs out. Sonny keeps a backup copy in both local storage and a first-party cookie, which recovers history in most of these cases — but a site that clears both will reset the widget.

Make history follow people across devices

If your website has its own login, you can tie chat history to a person rather than a single browser. With the Widget Identify API, Sonny securely recognizes a logged-in user, so their conversations follow them when they switch from laptop to phone or sign in on a new device. This is the recommended setup for products where customers have accounts.