boot(); $client = $container->get(TelegramClient::class); // Configuration $webhookUrl = 'https://your-domain.com/webhooks/telegram'; $secretToken = bin2hex(random_bytes(16)); // Generate random secret token echo "๐Ÿ“‹ Configuration:\n"; echo " Webhook URL: {$webhookUrl}\n"; echo " Secret Token: {$secretToken}\n\n"; echo "โš ๏ธ IMPORTANT: Add this to your .env file:\n"; echo " TELEGRAM_WEBHOOK_SECRET={$secretToken}\n\n"; try { // Step 1: Delete existing webhook (if any) echo "๐Ÿ—‘๏ธ Deleting existing webhook...\n"; $client->deleteWebhook(); echo " โœ… Existing webhook deleted\n\n"; // Step 2: Set new webhook echo "๐Ÿ”— Setting new webhook...\n"; $success = $client->setWebhook( url: $webhookUrl, secretToken: $secretToken, allowedUpdates: ['message', 'callback_query', 'edited_message'] ); if ($success) { echo " โœ… Webhook configured successfully!\n\n"; echo "๐Ÿ“ Next steps:\n"; echo " 1. Add TELEGRAM_WEBHOOK_SECRET to your .env file\n"; echo " 2. Make sure your webhook URL is publicly accessible via HTTPS\n"; echo " 3. Test by sending a message to your bot or clicking an inline keyboard button\n\n"; echo "๐Ÿงช To test callback buttons, run:\n"; echo " php tests/debug/test-telegram-webhook-buttons.php\n\n"; } else { echo " โŒ Failed to set webhook\n"; exit(1); } } catch (\Exception $e) { echo "โŒ Error: {$e->getMessage()}\n"; echo "\n๐Ÿ“‹ Details:\n"; echo $e->getTraceAsString() . "\n"; exit(1); } echo "โœจ Setup complete!\n";