all(); // Solo procesar mensajes de texto if (! isset($update['message']['text'])) { return response()->json(['ok' => true]); } $chatId = (string) $update['message']['chat']['id']; $text = $update['message']['text']; $nombre = trim( ($update['message']['from']['first_name'] ?? '') . ' ' . ($update['message']['from']['last_name'] ?? '') ); $engine = new ChatBotEngine(); $replies = $engine->handle('telegram', $chatId, $text, $nombre); foreach ($replies as $reply) { $engine->enviarTelegram($chatId, $reply); } return response()->json(['ok' => true]); } }