What is Storage?
The WhatsApp Client SDK includes a powerful storage system that automatically persists incoming and outgoing messages to a database. This enables you to:- ๐ Query conversation history - Retrieve past messages and conversations
- ๐ Search messages - Full-text search across all messages
- ๐ Analytics - Track conversation metrics and patterns
- ๐พ Data retention - Automatic cleanup of old messages
- ๐งต Thread tracking - Follow message reply chains
Key Features
Automatic Persistence
Messages are automatically saved to your database without additional code
Full-Text Search
Search through all messages with powerful query capabilities
Conversation Analytics
Track message counts, response rates, and engagement metrics
Data Export
Export conversations in JSON or CSV format for analysis
Thread Tracking
Automatically track message replies and conversation threads
Flexible Retention
Configure automatic deletion of old messages based on your needs
How It Works
1. Enable Storage
Configure storage when initializing the WhatsApp client:2. Messages Are Saved Automatically
Once storage is enabled, all messages are automatically persisted:3. Query Your Data
Use the built-in query methods:Storage Providers
Supabase (Recommended)
Supabase is the primary storage provider with full support for all features:- โ PostgreSQL-backed
- โ Real-time subscriptions
- โ Built-in authentication
- โ Auto-generated APIs
- โ Free tier available
Supabase Integration Guide
Complete setup guide for Supabase storage
Custom Adapters
You can implement your own storage adapter for other databases:Custom Storage Adapters
Learn how to create custom storage adapters
Storage Configuration
Feature Flags
Control what data is persisted:Data Retention
Automatically clean up old messages:Use Cases
Customer Support
Track support conversations and response times:E-commerce
Search order-related messages:Compliance & Auditing
Maintain message records for compliance:Performance Considerations
Indexing
Storage providers automatically create indexes on:- Phone numbers
- Message timestamps
- Message types
- Status fields
Pagination
Always use pagination for large datasets:Caching
Implement caching for frequently accessed data:Security
Access Control
- Use service role keys only in backend code
- Never expose database credentials in frontend
- Implement Row Level Security (RLS) in Supabase
Data Privacy
- Hash or encrypt sensitive message content
- Implement data retention policies
- Provide user data export/deletion capabilities
Storage Best Practices
Learn security and performance best practices