Skip to main content

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

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”
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
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

Next Steps

Chat Example

See memory in conversations

Direct Client

Learn the MemoryClient API

API Reference

Explore search options

Metadata Guide

Learn about metadata