Skip to main content

Overview

This example demonstrates a complete chat application that remembers user preferences, context, and conversations using Satori.

Features

  • Persistent memory across sessions
  • Automatic information extraction
  • Semantic context retrieval
  • Natural conversation flow

Complete Implementation

API Route

app/api/chat/route.ts

Chat Interface

app/chat/page.tsx

Example Conversations

Conversation 1: Building Context

User: “Hi! My name is Alex and I’m a software engineer at Acme Corp.”Assistant: “Nice to meet you, Alex! It’s great to connect with a software engineer. What kind of projects do you work on at Acme Corp?”Behind the scenes: Saves “User’s name is Alex and works as a software engineer at Acme Corp”
User: “I really prefer TypeScript over JavaScript. The type safety is just so much better.”Assistant: “I completely understand! TypeScript’s type safety does make a huge difference in catching bugs early and improving code maintainability. Do you use TypeScript for all your projects?”Behind the scenes: Saves “User prefers TypeScript over JavaScript for type safety”
User: “In my free time, I love hiking and photography. I try to get out into nature every weekend.”Assistant: “That’s a wonderful combination! Photography and hiking complement each other perfectly. Do you have a favorite hiking spot where you like to take photos?”Behind the scenes: Saves “User enjoys hiking and photography, tries to go every weekend”

Conversation 2: Recalling Context (New Session)

User: “Hey, what’s up?”Assistant: “Hey Alex! How’s it going? Did you get a chance to go hiking this weekend?”Behind the scenes: Retrieved memories about name and hiking hobby
User: “I’m looking for a new side project to work on.”Assistant: “Since you love TypeScript and photography, have you thought about building a photo management app? You could use TypeScript with Next.js for the frontend and maybe add some AI features for automatic tagging. It would combine your technical preferences with your hobby!”Behind the scenes: Retrieved memories about TypeScript preference and photography hobby
User: “What do you remember about me?”Assistant: “Let me see… I know that your name is Alex and you work as a software engineer at Acme Corp. You prefer TypeScript over JavaScript because of the type safety. In your free time, you enjoy hiking and photography, and you try to get out into nature every weekend. Is there anything else you’d like me to remember?”Behind the scenes: Retrieved all relevant memories

Conversation 3: Updating Information

User: “Actually, I just started a new job at TechCo!”Assistant: “Congratulations on the new position at TechCo! That’s exciting. What will you be working on there?”Behind the scenes: Saves “User now works at TechCo” (new memory)
User: “Can you forget that I work at TechCo? I’d rather not share work details.”Assistant: “Of course, I’ve removed that information. Your privacy is important.”Behind the scenes: Searches for and deletes work-related memories

Key Features Demonstrated

Automatic Extraction

The LLM automatically identifies and saves important information without explicit commands

Semantic Retrieval

Context is retrieved based on meaning, not just keywords

Natural Flow

Memory operations happen transparently without disrupting conversation

User Control

Users can ask what’s remembered and request deletions

Customization Ideas

Next Steps

User Preferences Example

See how to store and use preferences

Next.js Integration

Build a complete app

API Reference

Explore all memory operations

Troubleshooting

Fix common issues