exec(" -- Tabla para registrar interacciones con el bot CREATE TABLE IF NOT EXISTS telegram_bot_interactions ( id INT AUTO_INCREMENT PRIMARY KEY, user_id BIGINT NOT NULL, username VARCHAR(255), first_name VARCHAR(255), last_name VARCHAR(255), interaction_type VARCHAR(50) NOT NULL, interaction_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY unique_interaction (user_id, interaction_type) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- Tabla para la configuración del mensaje del bot CREATE TABLE IF NOT EXISTS telegram_bot_messages ( id INT AUTO_INCREMENT PRIMARY KEY, message_text TEXT NOT NULL, button_text VARCHAR(50) DEFAULT '¡Únete a nuestro grupo!', group_invite_link VARCHAR(255) DEFAULT 'https://t.me/+Hzh0G-1-BY41ZDNj', is_active BOOLEAN NOT NULL DEFAULT TRUE, register_users BOOLEAN NOT NULL DEFAULT TRUE, updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- Insertar configuración por defecto si no existe INSERT IGNORE INTO telegram_bot_messages (message_text, button_text, group_invite_link, is_active, register_users) VALUES ( '¡Hola {user_name}! 👋\n\nGracias por interactuar con nuestro bot. Únete a nuestro grupo principal para mantenerte actualizado con nuestras novedades.', '¡Únete a nuestro grupo!', 'https://t.me/+Hzh0G-1-BY41ZDNj', TRUE, TRUE ); "); } catch (PDOException $e) { die("Error al crear las tablas: " . $e->getMessage()); } // Manejar el envío del formulario if ($_SERVER['REQUEST_METHOD'] === 'POST') { $messageText = $_POST['message_text'] ?? ''; $buttonText = $_POST['button_text'] ?? '¡Únete a nuestro grupo!'; $groupInviteLink = $_POST['group_invite_link'] ?? 'https://t.me/+Hzh0G-1-BY41ZDNj'; $isActive = isset($_POST['is_active']) ? 1 : 0; $registerUsers = isset($_POST['register_users']) ? 1 : 0; try { $pdo->beginTransaction(); // Actualizar la configuración $stmt = $pdo->prepare(" UPDATE telegram_bot_messages SET message_text = ?, button_text = ?, group_invite_link = ?, is_active = ?, register_users = ? WHERE id = 1 "); $stmt->execute([ $messageText, $buttonText, $groupInviteLink, $isActive, $registerUsers ]); $pdo->commit(); $successMessage = "¡Configuración guardada con éxito!"; } catch (PDOException $e) { $pdo->rollBack(); $errorMessage = "Error al guardar la configuración: " . $e->getMessage(); } } // Obtener la configuración actual try { $stmt = $pdo->query("SELECT * FROM telegram_bot_messages WHERE id = 1"); $config = $stmt->fetch(PDO::FETCH_ASSOC); if (!$config) { throw new Exception("No se encontró la configuración del mensaje del bot"); } } catch (Exception $e) { $errorMessage = "Error al cargar la configuración: " . $e->getMessage(); $config = [ 'message_text' => '¡Hola {user_name}! 👋\n\nGracias por interactuar con nuestro bot. Únete a nuestro grupo principal para mantenerte actualizado con nuestras novedades.', 'button_text' => '¡Únete a nuestro grupo!', 'group_invite_link' => 'https://t.me/+Hzh0G-1-BY41ZDNj', 'is_active' => true, 'register_users' => true ]; } // Obtener estadísticas de interacciones try { $statsStmt = $pdo->query(" SELECT COUNT(*) as total_interactions, COUNT(DISTINCT user_id) as unique_users FROM telegram_bot_interactions "); $stats = $statsStmt->fetch(PDO::FETCH_ASSOC); } catch (PDOException $e) { $errorMessage = "Error al cargar las estadísticas: " . $e->getMessage(); $stats = []; } $pageTitle = 'Interacciones del Bot de Telegram'; require_once __DIR__ . '/../../templates/header.php'; ?>

Interacciones del Bot de Telegram

Configura el mensaje que se enviará cuando los usuarios interactúen con tu bot.

Configuración del Mensaje del Bot
Puedes usar los siguientes placeholders que serán reemplazados automáticamente:
  • {user_name} - El nombre del usuario que interactúa con el bot.
  • {group_link} - El enlace al grupo principal.
>
>
Configuración de Webhook
Webhook Unificado

Este único webhook maneja tanto las interacciones directas con el bot como los mensajes de bienvenida a nuevos miembros en un grupo.

Comando de Configuración con cURL

Usa este comando en tu terminal para configurar el webhook en Telegram. Solo necesitas hacerlo una vez.

Este es el único webhook que necesitas configurar.
Vista Previa
Bot
Bot de Interacción
Estadísticas
Usuarios únicos registrados:
Total de interacciones: