Conversational Search
The widget supports a conversational search mode that maintains context between successive searches, allowing natural refinement of results.
Activation
Conversational search requires enabling the AI assistant:
NeuroonWidget.init({
container: '#neuroon-search',
token: 'YOUR_TOKEN',
features: {
aiAssistant: true, // Enables conversational mode
},
});
Plan required
The AI assistant is available on Growth plans and above.
How it works
Session context
The widget maintains a conversation history during the session:
User: "running shoes"
→ Results: athletic shoes
User: "Nike only"
→ Context: shoes + Nike
→ Results: Nike running shoes
User: "under $100"
→ Context: shoes + Nike + price < $100
→ Refined results
Conversation turns
Each interaction generates a turn with user and assistant information:
interface ConversationTurn {
id: string;
role: 'user' | 'assistant';
content: string;
timestamp: Date;
products?: Product[]; // Suggested products
suggestedFilters?: SearchFilters; // Inferred filters
confidence?: number; // 0-1, interpretation confidence
}
Chat Interface
Open chat panel
widget.openChat();
Or via the chat icon in the widget interface.
Send messages
// Programmatically
await widget.sendMessage('I need a lightweight laptop for work');
// Users can also type directly in chat
Conversation history
// Get full history
const history = widget.conversationHistory;
history.forEach(turn => {
console.log(`[${turn.role}] ${turn.content}`);
if (turn.products?.length) {
console.log(` → ${turn.products.length} suggested products`);
}
});
Clear history
// Reset conversation
widget.clearHistory();
Session Persistence
History is persisted in sessionStorage during the browser session:
// Automatically saved with key:
// neuroon_chat_{shopId}
// History is restored on page reload
// Cleared when browser closes
Configure persistence
NeuroonWidget.init({
features: {
aiAssistant: true,
},
// Disable persistence if preferred
persistence: {
chat: false, // Default: true
},
});
Inferred Filters
The assistant analyzes queries and extracts filters automatically:
| Query | Inferred filters |
|---|---|
| "cheap Nike shoes" | brands: ['Nike'], priceMax: inferred |
| "gaming laptop" | categories: ['gaming'], tags: ['gaming'] |
| "red dress size M" | tags: ['red'], size: 'M' |
| "under 50 dollars" | priceMax: 50 |
// Listen for inferred filters
widget.on('chat:message', ({ turn }) => {
if (turn.suggestedFilters) {
console.log('Suggested filters:', turn.suggestedFilters);
// { brands: ['Nike'], priceMax: 100 }
}
});
Confidence Indicator
Each response includes a confidence level:
widget.on('chat:message', ({ turn }) => {
if (turn.confidence !== undefined) {
if (turn.confidence > 0.8) {
// High confidence - apply filters automatically
widget.setFilters(turn.suggestedFilters);
} else {
// Low confidence - show options to user
showFilterOptions(turn.suggestedFilters);
}
}
});
| Range | Meaning |
|---|---|
| 0.9 - 1.0 | Very high - Clear interpretation |
| 0.7 - 0.9 | High - Good inference |
| 0.5 - 0.7 | Medium - May need confirmation |
| 0.0 - 0.5 | Low - Ambiguous query |
Chat Events
| Event | Payload | Description |
|---|---|---|
chat:open | {} | Chat panel opened |
chat:close | {} | Chat panel closed |
chat:message | { turn } | New message (user or assistant) |
chat:typing | { isTyping } | Typing indicator |
chat:error | { error } | Chat error |
widget.on('chat:typing', ({ isTyping }) => {
if (isTyping) {
showTypingIndicator();
} else {
hideTypingIndicator();
}
});
Best Practices
- Limited context: History is limited to the last 10 interactions for relevance
- Periodic cleanup: Consider clearing history when changing sections or categories
- Fallback: If assistant doesn't understand, offer manual filter options
- Visual indicators: Show when assistant is "thinking"
- Optional persistence: Disable if context shouldn't persist between reloads
Next steps
- AI Assistant - More about guided filters
- JavaScript API - Programmatic chat control
- Callbacks - Chat events