fix(template): send parameter_name for named-variable templates

WhatsApp API returns "(#100) Invalid parameter — Parameter name is
missing or empty" for templates that use named variables.

- chat.php sendTemplate(): collect params as [{name, value}] objects
  using data-var-index as the parameter name
- WhatsAppService::sendTemplateMessage(): handle {name, value} objects
  in the indexed-array path by emitting {type, parameter_name, text}
  (backward-compatible — plain strings still work as positional params)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Lizandro Guarnizo
2026-07-03 15:04:31 -05:00
co-authored by Claude Sonnet 4.6
parent a8380ddc81
commit 3d6147bf0d
2 changed files with 9 additions and 2 deletions
+2 -2
View File
@@ -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;