false, 'error' => 'Contact name and phone are required.']); exit; } $stmt = $pdo->prepare("INSERT INTO conversations (contact_name, phone, channel, created_at) VALUES (?, ?, ?, NOW())"); $stmt->execute([$contactName, $phone, $channel]); $conversationId = (int)$pdo->lastInsertId(); echo json_encode(['success' => true, 'conversation_id' => $conversationId]); exit; } $rows = $pdo->query("SELECT * FROM conversations ORDER BY created_at DESC")->fetchAll(); echo json_encode(['success' => true, 'conversations' => $rows]);