Conversations
Conversation Sessions
Manage cross-page continuity, browser tab synchronization, storage mechanisms, and session expiration timeouts.
Overview
A conversation session maintains continuity as visitors browse across different URLs on your website. Without session persistence, navigating from /pricing to /checkout would reset the assistant and lose prior context.
Cross-Page Persistence
By default, the SDK stores an encrypted session token in sessionStorage and cookies scoped to your root domain:
- Same-Origin Navigation: When a user clicks an internal link, the SDK re-attaches to the active conversation within 15ms.
- Page Context Updates: When the route changes, the SDK automatically transmits a
page_viewevent so the assistant knows the visitor's current location without interrupting the chat.
// Listen for route changes in Next.js / React Router
router.events.on("routeChangeComplete", (url) => {
Asiyst.pageView({ path: url, title: document.title });
});
Multi-Tab Synchronization
If a visitor opens your website in multiple browser tabs, Asiyst keeps all tabs in sync using the native BroadcastChannel API:
- Messages sent in Tab A immediately reflect in Tab B.
- If the avatar is dismissed in Tab A, it smoothly minimizes in Tab B.
- Token streams are rendered across all active windows concurrently.
Session Timeout & Cleanup
| Event | Trigger | Outcome |
|---|---|---|
| Inactivity Warning | 25 minutes of zero interaction | Emits session:idle_warning event |
| Session Invalidation | 30 minutes of zero interaction | Marks conversation completed, clears token |
| Explicit Logout | Asiyst.logout() called | Immediately destroys credentials & memory |
| Tab Close | All tabs closed | sessionStorage clears automatically |
Configuring Session Storage
You can adjust storage policies during initialization:
Asiyst.init({
projectId: "proj_9f8a2b3c4d",
publicKey: "pk_live_8e7d6c5b4a3f2e1d",
session: {
storage: "localStorage", // 'sessionStorage' (default) | 'localStorage' | 'memory'
idleTimeoutMinutes: 30,
syncAcrossTabs: true,
},
});