' +
'
' +
' ID: ' +
+ ' 🧠NLU:' +
+ ' ' +
' ' +
'
' +
'
' +
diff --git a/admin/v1/WpWebhook.php b/admin/v1/WpWebhook.php
index 7ae675a..7a8ab81 100644
--- a/admin/v1/WpWebhook.php
+++ b/admin/v1/WpWebhook.php
@@ -480,6 +480,8 @@ class WpWebhook
$isNew = self::saveConversation($ctx, $preview, $mediaId);
self::forwardToCompany($ctx, $preview, $mediaId);
if ($isNew && self::$currentCompany !== null) {
+ // media_id in context so BotRouter/MediaTranscriber can download the file
+ $ctx['media_id'] = $mediaId;
BotRouter::route(self::$currentCompany, $ctx, $caption, $type);
}
}
diff --git a/public/index.php b/public/index.php
index ca13f77..eec0def 100644
--- a/public/index.php
+++ b/public/index.php
@@ -395,6 +395,7 @@ $routes = [
// Flows
$flowKeys = $_POST['flow_key'] ?? [];
+ $flowNluDescs = $_POST['flow_nlu_desc'] ?? [];
$flowTypes = $_POST['flow_type'] ?? [];
$flowMessages = $_POST['flow_message'] ?? [];
$flowFunctions = $_POST['flow_function'] ?? [];
@@ -443,6 +444,9 @@ $routes = [
$f = ['type' => $ftype];
+ $nluDesc = trim($flowNluDescs[$i] ?? '');
+ if ($nluDesc !== '') $f['nlu_description'] = $nluDesc;
+
if ($ftype === 'text') {
$f['message'] = trim($flowMessages[$i] ?? '');
diff --git a/services/AiBot.php b/services/AiBot.php
index f79b550..0ff71db 100644
--- a/services/AiBot.php
+++ b/services/AiBot.php
@@ -17,7 +17,7 @@ class AiBot
default => 'un archivo',
};
- $canUpload = $permType === 3;
+ $canUpload = in_array($permType, [1, 3], true); // 1=solo reporta, 3=ambos
$permDesc = $canUpload
? 'El usuario tiene permisos para subir información y reportes.'
: 'El usuario solo puede recibir información o descargar informes, NO puede subir archivos.';
@@ -382,8 +382,9 @@ PROMPT;
if ($isUpload && !in_array($permType, [1, 3], true)) continue;
if ($isDownload && !in_array($permType, [2, 3], true)) continue;
- // Skip purely internal/navigation flows
- if (in_array($type, ['text', 'image'], true) && !$isUpload && !$isDownload) continue;
+ // Skip internal/navigation flows unless they have an explicit NLU description
+ $hasNluDesc = isset($flow['nlu_description']) && $flow['nlu_description'] !== '';
+ if (in_array($type, ['text', 'image'], true) && !$isUpload && !$isDownload && !$hasNluDesc) continue;
$label = $flow['nlu_description'] ?? $labels[$key] ?? $key;
$dir = $isUpload ? 'subida' : ($isDownload ? 'descarga' : '');
diff --git a/services/BotRouter.php b/services/BotRouter.php
index a390b91..9ac3e4c 100644
--- a/services/BotRouter.php
+++ b/services/BotRouter.php
@@ -118,9 +118,10 @@ class BotRouter
}
if ($nluEnabled && in_array($inputType, ['audio', 'image'], true)) {
+ $mediaId = $context['media_id'] ?? $input; // injected by WpWebhook::handleMedia
$text = $inputType === 'audio'
- ? MediaTranscriber::transcribeAudio($input, $company)
- : MediaTranscriber::extractFromImage($input, $company);
+ ? MediaTranscriber::transcribeAudio($mediaId, $company)
+ : MediaTranscriber::extractFromImage($mediaId, $company);
if ($text !== null && trim($text) !== '') {
self::log("NLU media [{$inputType}]: texto extraÃdo → \"{$text}\"");