feat: menu navegable con submenus y descarga de reportes via api_report
- NormalBot: nueva funcion api_report para descargar PDF/Excel del ERP y enviarlo por WhatsApp - NormalBot: resolveMenu() para referenciar menus por nombre en los flujos - WhatsAppSender: uploadMedia() y sendDocument() para envio de documentos - BotRouter: guarda respuestas en conversations para visibilidad en el chat - Script apply-menus.php con estructura completa de menus y endpoints
This commit is contained in:
@@ -143,6 +143,26 @@ class BotRouter
|
||||
$stmt = db()->prepare("INSERT INTO outbound_queue (company_id, to_number, message_type, payload) VALUES (?, ?, ?, ?)");
|
||||
$stmt->execute([$company['id'], $to, $type, $payload]);
|
||||
self::log("Bot encoló respuesta {$type} para {$to}");
|
||||
|
||||
$messageId = 'bot_out_' . $company['id'] . '_' . time() . '_' . bin2hex(random_bytes(4));
|
||||
$content = $payload;
|
||||
if ($type !== 'text') {
|
||||
$decoded = json_decode($payload, true);
|
||||
$content = $decoded['caption'] ?? $decoded['body'] ?? $decoded['text'] ?? $payload;
|
||||
}
|
||||
$stmt2 = db()->prepare("
|
||||
INSERT IGNORE INTO conversations
|
||||
(company_id, message_id, phone_number, direction, message_type, content, timestamp)
|
||||
VALUES (?, ?, ?, 'outbound', ?, ?, ?)
|
||||
");
|
||||
$stmt2->execute([
|
||||
$company['id'],
|
||||
$messageId,
|
||||
$to,
|
||||
$type,
|
||||
mb_substr($content, 0, 1000),
|
||||
time(),
|
||||
]);
|
||||
} catch (\PDOException $e) {
|
||||
self::log('ERROR encolando respuesta: ' . $e->getMessage());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user