# Storage & History

### Get Conversation History

```typescript
// Get last 50 messages
const messages = await whatsapp.getConversationHistory('1234567890');

// With pagination
const messages = await whatsapp.getConversationHistory('1234567890', 20, 0);
```

### Search Messages

```typescript
// Search in all conversations
const results = await whatsapp.searchMessages('hello');

// Search in specific conversation
const results = await whatsapp.searchMessages('hello', '1234567890');
```

### Stored Message Structure

```typescript
interface StoredMessage {
  id: string;                  // Internal message ID
  whatsappId?: string;         // WhatsApp message ID
  conversationId: string;      // Phone number
  direction: 'incoming' | 'outgoing';
  type: string;               // Message type
  content: any;               // Message content
  timestamp: number;          // Unix timestamp
  status: MessageStatus;      // Message status
  media?: {                   // Media info (if applicable)
    id?: string;
    url?: string;
    mimeType: string;
    fileName?: string;
    fileSize?: number;
  };
  error?: {                   // Error info (if failed)
    code: number;
    message: string;
    details?: any;
  };
}
```

---