Overview
This example shows how to use Satori to store and retrieve user preferences, enabling personalized experiences across your application.Use Case
Build an AI assistant that remembers user preferences for:- UI settings (theme, language, layout)
- Content preferences (topics, formats, difficulty)
- Communication style (formal vs casual, verbosity)
- Notification preferences
Implementation
Saving Preferences
app/api/preferences/route.ts
Retrieving Preferences
app/api/preferences/get/route.ts
Preferences UI Component
components/PreferencesPanel.tsx
Preference Categories
UI Preferences
Content Preferences
Communication Preferences
Using Preferences in Chat
app/api/chat/route.ts
Example Interactions
Setting UI preferences
Setting UI preferences
User: “I prefer dark mode and a compact layout”Assistant: “Got it! I’ll remember that you prefer dark mode and a compact layout. Your interface should reflect these preferences.”Saves: “User prefers dark mode” and “User prefers compact layout”
Content recommendations
Content recommendations
User: “Show me some tutorials”Assistant: “Based on your preferences for advanced technical content in video format, here are some great video tutorials on AI and machine learning…”Uses preferences to personalize recommendations
Communication adaptation
Communication adaptation
User: “Explain how embeddings work”Assistant: “Sure! Here’s a concise explanation with code:Embeddings capture semantic meaning in numbers that computers can compare.”Adapts to preference for concise responses with code examples
Advanced Patterns
Preference Conflicts
Preference Hierarchy
Preference Expiration
Best Practices
Use clear, specific preference statements
Use clear, specific preference statements
Organize with metadata
Organize with metadata
Allow preference updates
Allow preference updates