diff --git a/admin/DashboardController.php b/admin/DashboardController.php
index 493affb..9b08981 100644
--- a/admin/DashboardController.php
+++ b/admin/DashboardController.php
@@ -1604,6 +1604,7 @@ HTML;
⏳ Pendientes
💬 Chat
🏢 Empresas
+ 🤖 Bot Config
⚙️ Configuración
🔄 Sincronizar
📨 Procesar Cola
@@ -1914,4 +1915,463 @@ HTML;
jsonResponse(200, ['status' => 'sent']);
}
+
+ // ─── GET /admin/bot-config ──────────────────────────────────────────────
+
+ public static function botConfig(): void
+ {
+ SessionAuth::require();
+ $user = SessionAuth::user();
+ $userName = self::h($user['name'] ?? 'Admin');
+ $companyId = (int)($_GET['id'] ?? 0);
+ $companies = CompanyRepository::findAll();
+ $company = null;
+ $config = ['commands' => [], 'menus' => [], 'flows' => [], 'ai_prompt' => '', 'fallback' => '', 'greeting' => ''];
+ $msg = $_GET['msg'] ?? '';
+ $toastHtml = $msg === 'saved' ? '
Configuración guardada exitosamente.
' : '';
+
+ if ($companyId > 0) {
+ $company = CompanyRepository::findById($companyId);
+ if ($company) {
+ $cj = $company['config_json'] ?? '';
+ if ($cj) {
+ $parsed = json_decode($cj, true);
+ if (is_array($parsed)) $config = $parsed;
+ }
+ }
+ }
+
+ $configJson = self::h(json_encode($config, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE));
+
+ http_response_code(200);
+ header('Content-Type: text/html; charset=utf-8');
+ echo <<
+
+
+
+ {$toastHtml}
+
+
+
';
+
+ if (!$company) {
+ echo '
Selecciona una empresa para configurar su bot.
';
+ echo '
';
+ exit;
+ }
+
+ $c = $company;
+ $cId = (int)$c['id'];
+ $cName = self::h($c['name'] ?? '');
+
+ // Pre-fill form values from config
+ $greetingVal = self::h($config['greeting'] ?? '');
+ $fallbackVal = self::h($config['fallback'] ?? '');
+ $aiPromptVal = self::h($config['ai_prompt'] ?? '');
+ $aiModelVal = self::h($config['ai_model'] ?? 'gpt-4o-mini');
+ $aiTempVal = self::h((string)($config['ai_temperature'] ?? 0.7));
+ $aiProviderVal = self::h($config['ai_provider'] ?? '');
+ $approvalWebhookVal = self::h($config['approval_webhook'] ?? '');
+ $ignoreVal = self::h(implode("\n", $config['ignore_prefixes'] ?? []));
+ $commands = $config['commands'] ?? [];
+ $menus = $config['menus'] ?? [];
+ $flows = $config['flows'] ?? [];
+ $aiProviderOpenai = $aiProviderVal === 'openai' ? ' selected' : '';
+ $aiProviderMock = $aiProviderVal === 'mock' ? ' selected' : '';
+ $aiModelMini = $aiModelVal === 'gpt-4o-mini' ? ' selected' : '';
+ $aiModel4o = $aiModelVal === 'gpt-4o' ? ' selected' : '';
+ $aiModel35 = $aiModelVal === 'gpt-3.5-turbo' ? ' selected' : '';
+
+ echo <<
+
+
📋 Comandos
+
Palabras clave que el usuario escribe para ejecutar acciones. Ej: "menu", "info", "contacto"
+
+
+
+
+
+