diff --git a/modules/turnero/views/chat.php b/modules/turnero/views/chat.php index 219a5d5..2bb791f 100644 --- a/modules/turnero/views/chat.php +++ b/modules/turnero/views/chat.php @@ -998,8 +998,8 @@ async function selectTemplate(tpl) { async function sendTemplate() { if (!_tplSelected || !state.activeUserId) return; const inputs = [...document.querySelectorAll('#tpl-vars-body input[data-var-index]')]; - const params = inputs.map(el => el.value.trim()); - const missing = params.findIndex(p => !p); + const params = inputs.map(el => ({ name: el.dataset.varIndex, value: el.value.trim() })); + const missing = params.findIndex(p => !p.value); if (missing !== -1) { inputs[missing].focus(); return; } const templateName = _tplSelected.template_name; diff --git a/services/WhatsAppService.php b/services/WhatsAppService.php index a15a683..d21e805 100644 --- a/services/WhatsAppService.php +++ b/services/WhatsAppService.php @@ -181,6 +181,13 @@ class WhatsAppService $bpCopy = $bp; unset($bpCopy['name']); $normalizedBody[] = $bpCopy; // already detailed + } elseif (is_array($bp) && isset($bp['name'], $bp['value'])) { + // {name: 'param_name', value: 'text'} — include parameter_name for named-variable templates + $normalizedBody[] = [ + 'type' => 'text', + 'parameter_name' => (string)$bp['name'], + 'text' => (string)$bp['value'], + ]; } elseif (is_string($bp) || is_numeric($bp)) { $normalizedBody[] = [ 'type' => 'text',