query( "SELECT MAX(created_at) as last_message FROM conversations WHERE user_id = 2 AND direction = 'incoming' AND created_at >= DATE_SUB(NOW(), INTERVAL 24 HOUR)" ); $result = $stmt->fetch(); if (!$result || !$result['last_message']) { // Insertar mensaje entrante para habilitar ventana de 24h $db->query( "INSERT INTO conversations (user_id, content, direction, message_type, status, created_at) VALUES (2, 'Hola, necesito información sobre sus servicios', 'incoming', 'text', 'received', DATE_SUB(NOW(), INTERVAL 1 HOUR))" ); echo "✅ Ventana de 24h habilitada para 573168950803\n"; } else { echo "✅ Usuario ya tiene ventana de 24h activa desde: " . $result['last_message'] . "\n"; } echo "📱 LISTO: Ahora puedes enviar mensajes de texto libre a 573168950803\n"; ?>