The chat component store now starts empty by default when embedded in applications. Sample conversation data is only injected in demo environments for testing and demonstration purposes.
Contains the sample conversation data that was previously hard-coded in the store. This module exports:
sampleConversations- Array of demo conversation objectssampleActiveConversationId- Default active conversation IDsampleCurrentUserId- Default current user IDgetDemoInitialState()- Helper function that returns complete demo state
The Zustand store now initializes with empty state:
conversations: [],
activeConversationId: null,
currentUserId: null,Loads sample data on mount using a useEffect hook:
useEffect(() => {
const demoData = getDemoInitialState();
useChatStore.getState().loadConversations(demoData);
}, []);Injects sample data via inline script after the component bundle loads:
const sampleData = { /* ... sample conversations ... */ };
ChatComponent.useChatStore.getState().loadConversations(sampleData);When embedding the component in your application, the store starts empty. You should:
- Load conversation data from your backend API
- Use
loadConversations()orloadConversationMetadata()to populate the store - Set the
currentUserIdprop to identify the current user
Example:
import ChatComponent from '@mieweb/chat-component';
import { useChatStore } from '@mieweb/chat-component';
// Fetch your data
const conversationData = await fetchConversations();
// Load into store
useChatStore.getState().loadConversations({
conversations: conversationData,
activeConversationId: conversationData[0]?.id,
currentUserId: currentUser.id
});
// Render component
<ChatComponent
onMessageSent={handleMessage}
currentUserId={currentUser.id}
/>When creating new conversations, you can optionally provide a reference_id to link to external systems:
const newConversation = useChatStore.getState().createConversation(
'Patient Follow-up',
'CASE-2025-123' // optional reference_id
);The reference_id field is useful for:
- Linking conversations to external case management systems
- Tracking related documents or appointments
- Integration with third-party systems
- Maintaining cross-reference identifiers
- Clean embeddings: No demo data pollutes production applications
- Smaller initial bundle: Sample data only loaded when needed
- Flexible demos: Easy to modify demo data without touching store logic
- Single source of truth: Sample data defined in one place (
sample-data.js)