Let Mem0 auto-categorize support data so teams retrieve the right facts fast.
When you have large volumes of memory data, sorting it during post-processing becomes difficult. What if your memory store understood the importance of creating tags and buckets without a lot of effort?Mem0 handles this for you by providing the flexibility to organize memories with custom categories. This cookbook shows you how to tag and organize memories for a customer support platform.
from mem0 import MemoryClientclient = MemoryClient(api_key="your-api-key")
Define custom categories at the project level with client.project.update() before adding memories. Categories apply to all future memories—Mem0 auto-assigns them based on content semantics.
Without categories, all memories sit in one undifferentiated bucket. Support agents waste time searching through everything to find billing issues, account details, or past tickets.Let’s see what happens without organization:
Copy
Ask AI
# Joseph (support agent) stores various customer interactionsclient.add( "Maria called about her account password reset", user_id="maria",)client.add( "Maria was charged twice for last month's subscription", user_id="maria",)client.add( "Maria wants to upgrade to the premium plan", user_id="maria",)# Now try to find just billing issuesall_memories = client.get_all(filters={"user_id": "maria"})print(f"Total memories: {len(all_memories['results'])}")for memory in all_memories['results']: print(f"- {memory['memory']}")
Output:
Copy
Ask AI
Total memories: 3- Maria called about her account password reset- Maria was charged twice for last month's subscription- Maria wants to upgrade to the premium plan
Without categories, agents waste time reading through everything. For a customer with 100 memories, finding one billing issue means scanning all 100. Categories let you filter to exactly what you need—billing issues only, no password resets or feedback mixed in.
Everything is mixed together. Support agents have to read through all memories to find what they need.
Define categories that match how your support team thinks about customer issues:
Copy
Ask AI
custom_categories = [ {"support_tickets": "Customer issues and resolutions"}, {"account_info": "Account details and preferences"}, {"billing": "Payment history and billing questions"}, {"product_feedback": "Feature requests and feedback"},]client.project.update(custom_categories=custom_categories)
Start with 3-5 clear categories that match how your team thinks. Too many categories dilute auto-tagging accuracy. Add more later if needed—it’s easier to expand than to fix over-complicated classification.
These categories are now available project-wide. Every memory can be tagged with one or more categories.
Once categories are defined at the project level, Mem0 automatically assigns them based on content:
Copy
Ask AI
# Billing issue - automatically tagged as "billing"client.add( "Maria was charged twice for last month's subscription", user_id="maria", metadata={"priority": "high", "source": "phone_call"})# Account update - automatically tagged as "account_info"client.add( "Maria changed her email to [email protected]", user_id="maria", metadata={"source": "web_portal"})# Product feedback - automatically tagged as "product_feedback"client.add( "Maria requested a dark mode feature for the dashboard", user_id="maria", metadata={"source": "chat"})
Mem0 reads the content and intelligently assigns the appropriate categories. You don’t manually tag - the platform does it for you based on the category definitions.
Filter memories by category to find exactly what you need:
Copy
Ask AI
# Joseph needs to pull all billing issues for auditbilling_issues = client.get_all( filters={ "AND": [ {"user_id": "maria"}, {"categories": {"in": ["billing"]}} ] })print("Billing issues:")for memory in billing_issues['results']: print(f"- {memory['memory']}")
Output:
Copy
Ask AI
Billing issues:- Maria was charged twice for last month's subscription
Expected output: Only the billing issue returned—no password reset, no upgrade request. Category filtering worked. Joseph can audit billing without reading through unrelated support tickets.
Only billing-related memories are returned. No need to filter through account updates or feedback.You can also retrieve multiple categories:
Copy
Ask AI
# Get both account info and billingaccount_and_billing = client.get_all( filters={ "AND": [ {"user_id": "maria"}, {"categories": {"in": ["account_info", "billing"]}} ] })for memory in account_and_billing['results']: print(f"[{memory['categories'][0]}] {memory['memory']}")
Output:
Copy
Ask AI
[account_info] Maria changed her email to [email protected][billing] Maria was charged twice for last month's subscription
Categories are automatically assigned based on content. To trigger re-categorization, update the memory content:
Copy
Ask AI
# Find memories that need re-categorizationneeds_update = client.get_all( filters={ "AND": [ {"user_id": "maria"}, {"categories": {"in": ["misc"]}} ] })# Update memory content to trigger re-categorizationfor memory in needs_update['results']: client.update( memory_id=memory['id'], data=memory['memory'] # Re-process with current category definitions )
When you update a memory, Mem0 re-analyzes it against your current category definitions. This is useful when you introduce new categories or refine category descriptions.
Categories make retrieval faster and compliance easier. Define 3-5 clear categories with client.project.update(), let Mem0 auto-assign them based on content, then filter with categories: {in: [...]} to pull exactly what you need.Instead of searching through everything, agents jump directly to the information type they need—billing issues, account details, or support tickets.
Control Memory Ingestion
Keep categories meaningful by filtering noise before it lands in storage.
Export Tagged Memories
Use categories to drive audits, migrations, and compliance reports.