feat: Telegram transactional flows + role pricing + services slider

- New TelegramBotService: full OTP auth, registration, main menu with
  inline keyboards, buy plans, buy promos, recharge (MP + Bre-B),
  credentials, history, profile, agent transfer, photo receipt analysis
- TelegramWebhookController: now handles text, callback_query and photo
- Role-based pricing: tarifas filtered by user rol_id in both web chat
  and Telegram; Preferencial price overrides base tarifa valor
- Services and promos now render as horizontal scroll slider
  (cards_slider tipo_ui) instead of stacked individual cards

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Lizandro
2026-07-14 04:36:03 +00:00
co-authored by Claude Sonnet 4.6
parent a3bd91c204
commit 2fc2aba8a3
4 changed files with 1262 additions and 59 deletions
@@ -2,7 +2,7 @@
namespace App\Http\Controllers;
use App\Services\ChatBotEngine;
use App\Services\TelegramBotService;
use Illuminate\Http\Request;
class TelegramWebhookController extends Controller
@@ -10,24 +10,35 @@ class TelegramWebhookController extends Controller
public function handle(Request $request)
{
$update = $request->all();
$bot = new TelegramBotService();
// Solo procesar mensajes de texto
if (! isset($update['message']['text'])) {
// Inline keyboard button taps
if (isset($update['callback_query'])) {
$cq = $update['callback_query'];
$chatId = (string) $cq['message']['chat']['id'];
$bot->handleCallback($chatId, $cq['id'], $cq['data'] ?? '');
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'] ?? '')
);
// Photos (payment receipts)
if (isset($update['message']['photo'])) {
$chatId = (string) $update['message']['chat']['id'];
$photos = $update['message']['photo'];
$fileId = end($photos)['file_id'];
$bot->handlePhoto($chatId, $fileId);
return response()->json(['ok' => true]);
}
$engine = new ChatBotEngine();
$replies = $engine->handle('telegram', $chatId, $text, $nombre);
foreach ($replies as $reply) {
$engine->enviarTelegram($chatId, $reply);
// Text messages
if (isset($update['message']['text'])) {
$chatId = (string) $update['message']['chat']['id'];
$text = $update['message']['text'];
$nombre = trim(
($update['message']['from']['first_name'] ?? '') . ' ' .
($update['message']['from']['last_name'] ?? '')
);
$bot->handleText($chatId, $text, $nombre);
return response()->json(['ok' => true]);
}
return response()->json(['ok' => true]);