feat: web chat con IA, validación de pagos y OTP por correo
- Chat público en /chat con flujos de compra, recarga y credenciales - Verificación de identidad por código OTP enviado al correo registrado - Botones enriquecidos: cards, links, credenciales, validación de comprobante - Gemini IA para detección de intención en texto libre - Gemini Vision para extraer datos de foto de comprobante - Validador de pagos cruzando IA con correos IMAP (Bancolombia) - MercadoPago como pasarela de pago (reemplaza Wompi en el chat) - Migraciones: payload en chat_messages, user_id en chat_contacts - Config admin: API key Gemini, toggles IA y validación de foto Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
a56a69dccb
commit
536377363c
File diff suppressed because it is too large
Load Diff
@@ -10,30 +10,61 @@ class ShowConfiguracionChat extends Component
|
||||
{
|
||||
use LivewireAlert;
|
||||
|
||||
// ── Chat general ──────────────────────────────────────────
|
||||
public string $telegram_token = '';
|
||||
public string $mensaje_bienvenida = '';
|
||||
public string $mensaje_transferencia = '';
|
||||
public string $webhookResult = '';
|
||||
|
||||
// ── Gemini IA ─────────────────────────────────────────────
|
||||
public string $gemini_api_key = '';
|
||||
public string $gemini_habilitado = '0';
|
||||
public string $gemini_prompt_extra = '';
|
||||
|
||||
// ── Validación de pago por foto + correo ──────────────────
|
||||
public string $validacion_foto_habilitada = '0';
|
||||
public string $validacion_accion_auto = 'solo_notificar'; // recargar_saldo | solo_notificar
|
||||
public string $validacion_monto_tolerancia = '0';
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
$this->telegram_token = ChatConfig::get('telegram_token', '');
|
||||
$this->mensaje_bienvenida = ChatConfig::get('mensaje_bienvenida', 'Hola 👋 Bienvenido. Escribe tu consulta.');
|
||||
$this->mensaje_transferencia = ChatConfig::get('mensaje_transferencia', 'Un agente se comunicará contigo en breve. Por favor espera.');
|
||||
$keys = [
|
||||
'telegram_token', 'mensaje_bienvenida', 'mensaje_transferencia',
|
||||
'gemini_api_key', 'gemini_habilitado', 'gemini_prompt_extra',
|
||||
'validacion_foto_habilitada', 'validacion_accion_auto', 'validacion_monto_tolerancia',
|
||||
];
|
||||
|
||||
$defaults = [
|
||||
'mensaje_bienvenida' => 'Hola! Bienvenido. Escribe tu consulta.',
|
||||
'mensaje_transferencia' => 'Un agente se comunicara contigo en breve. Por favor espera.',
|
||||
'validacion_accion_auto' => 'solo_notificar',
|
||||
'validacion_monto_tolerancia' => '0',
|
||||
];
|
||||
|
||||
foreach ($keys as $key) {
|
||||
$this->{$key} = ChatConfig::get($key, $defaults[$key] ?? '');
|
||||
}
|
||||
}
|
||||
|
||||
public function guardar(): void
|
||||
{
|
||||
$this->validate([
|
||||
'mensaje_bienvenida' => 'required|string|max:500',
|
||||
'mensaje_transferencia' => 'required|string|max:500',
|
||||
'mensaje_bienvenida' => 'required|string|max:500',
|
||||
'mensaje_transferencia' => 'required|string|max:500',
|
||||
'validacion_monto_tolerancia' => 'nullable|integer|min:0',
|
||||
]);
|
||||
|
||||
ChatConfig::set('telegram_token', $this->telegram_token);
|
||||
ChatConfig::set('mensaje_bienvenida', $this->mensaje_bienvenida);
|
||||
ChatConfig::set('mensaje_transferencia', $this->mensaje_transferencia);
|
||||
$keys = [
|
||||
'telegram_token', 'mensaje_bienvenida', 'mensaje_transferencia',
|
||||
'gemini_api_key', 'gemini_habilitado', 'gemini_prompt_extra',
|
||||
'validacion_foto_habilitada', 'validacion_accion_auto', 'validacion_monto_tolerancia',
|
||||
];
|
||||
|
||||
$this->alert('success', 'Configuración guardada correctamente.');
|
||||
foreach ($keys as $key) {
|
||||
ChatConfig::set($key, $this->{$key});
|
||||
}
|
||||
|
||||
$this->alert('success', 'Configuracion guardada correctamente.');
|
||||
}
|
||||
|
||||
public function registrarWebhook(): void
|
||||
@@ -41,11 +72,10 @@ class ShowConfiguracionChat extends Component
|
||||
$token = trim($this->telegram_token);
|
||||
|
||||
if (! $token) {
|
||||
$this->webhookResult = '⚠️ El token de Telegram está vacío.';
|
||||
$this->webhookResult = 'El token de Telegram esta vacio.';
|
||||
return;
|
||||
}
|
||||
|
||||
// Guardar el token antes de registrar
|
||||
ChatConfig::set('telegram_token', $token);
|
||||
|
||||
$webhookUrl = url('/chat/webhook/telegram');
|
||||
@@ -63,14 +93,14 @@ class ShowConfiguracionChat extends Component
|
||||
$result = @file_get_contents($apiUrl, false, $context);
|
||||
|
||||
if ($result === false) {
|
||||
$this->webhookResult = '❌ Error de conexión con la API de Telegram.';
|
||||
$this->webhookResult = 'Error de conexion con la API de Telegram.';
|
||||
return;
|
||||
}
|
||||
|
||||
$data = json_decode($result, true);
|
||||
$this->webhookResult = ($data['ok'] ?? false)
|
||||
? '✅ Webhook registrado correctamente: ' . ($data['description'] ?? 'OK')
|
||||
: '❌ Error: ' . ($data['description'] ?? 'respuesta desconocida');
|
||||
? 'Webhook registrado: ' . ($data['description'] ?? 'OK')
|
||||
: 'Error: ' . ($data['description'] ?? 'respuesta desconocida');
|
||||
}
|
||||
|
||||
public function render()
|
||||
|
||||
Reference in New Issue
Block a user