JavaScript Embed Features

Session History

Enable users to view and resume past chat sessions, with automatic visitor isolation across devices and users.

Overview

Session History allows end users to view and resume their past conversations with your chatbot. Sessions are automatically isolated per visitor — each user or device only sees their own chat history. This feature can be toggled on or off from the chatbot Features tab in the dashboard.

How It Works

When Session History is enabled, a list icon appears in the chat header. Clicking it shows a panel of past sessions with timestamps, message counts, and status badges. Users can select any session to load its full message history and continue the conversation (if the session is still active).

Visitor Isolation

Sessions are automatically isolated per visitor using a dual strategy. If your application passes user information (email or user ID) via the "user" prop, sessions are linked to that identity — the same user sees the same sessions across all devices. If no user info is provided (anonymous visitors), a unique device ID is generated and stored in localStorage, so each browser/device only sees its own sessions. This means Machine A and Machine B will have separate session histories unless they share the same authenticated user identity.

Authenticated Users

For logged-in users on your platform, pass user identity so sessions are shared across devices. There are three ways to do this: Script tag: <script src="..." data-api-key="dcml_pk_..." data-user-email="user@example.com" data-user-name="John" async></script> JavaScript SDK: DocimalChatbot.mountChatbot("#container", { apiKey: "dcml_pk_...", user: { email: "user@example.com", name: "John" } }); iFrame: <iframe src="https://cdn.docimal.site/embed.html?key=dcml_pk_...&userEmail=user@example.com&userName=John"></iframe> When email or id is provided, sessions are tied to that identity. The same user logging in from a different device will see all their previous sessions.

Anonymous Visitors

When no user information is passed (e.g. public-facing chatbot without login), the widget automatically generates a unique device ID (UUID) and stores it in localStorage under the key "docimal_device_id". This ID persists across page reloads and navigations on the same browser. Each browser/device gets its own isolated session history. If localStorage is cleared or the user switches browsers, they start fresh with no previous sessions visible.

Visitor ID Priority

The visitor identifier is determined in this order: 1) user.email — if provided in the user prop, 2) user.id — if email is not available but ID is, 3) Device ID — auto-generated UUID stored in localStorage. This means authenticated users always get user-based isolation (shared across devices), while anonymous visitors get device-based isolation (separate per browser).

Enable or Disable

Session History is enabled by default. To disable it, go to your chatbot settings in the Docimal dashboard, open the Features tab, and toggle off "Session History". When disabled, the history icon is hidden from the chat widget and users only see their current session. The feature flag is available at config.features.sessionHistory and follows the convention: if undefined or true, the feature is enabled; if explicitly set to false, it is disabled.