# Conversation Management

### Get Conversation State

```typescript
const state = whatsapp.getConversationState('1234567890');

console.log(state);
// {
//   id: '1234567890',
//   state: 'active',
//   lastActivity: Date,
//   messageCount: 42,
//   displayName: 'John Doe',
//   metadata: {},
//   currentStep: 'waiting_for_response',
//   context: {}
// }
```

### Update Conversation Context

```typescript
// Store custom data for conversation
whatsapp.updateConversationContext('1234567890', {
  userName: 'John',
  preferredLanguage: 'en',
  orderInProgress: true,
  cartItems: ['item1', 'item2']
});
```

### Conversation State Structure

```typescript
interface ConversationState {
  id: string;                    // Conversation ID (phone number)
  state: 'active' | 'waiting' | 'completed' | 'archived';
  lastActivity: Date;            // Last message timestamp
  messageCount: number;          // Total messages
  displayName: string;           // User's display name
  metadata: Record<string, any>; // System metadata
  currentStep?: string;          // Current conversation step
  context: Record<string, any>;  // Custom context data
}
```

---