debug(template): expose Meta error subcode/details, add canal meta

- WhatsAppService::makeRequest: include error_subcode and error_data.details
  in the thrown exception message to surface the real reason for #100 errors
- chat_send_message: log template name/lang/params before sending;
  pass canal+operator_id meta so outgoing templates are tagged correctly

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Lizandro Guarnizo
2026-07-03 14:54:10 -05:00
co-authored by Claude Sonnet 4.6
parent f60df038d8
commit a8380ddc81
2 changed files with 15 additions and 11 deletions
+4 -1
View File
@@ -35,7 +35,10 @@ try {
$wa = new WhatsAppService('turnero');
if ($type === 'template') {
$response = $wa->sendTemplateMessage($user['phone_number'], $template, $lang, $params);
error_log("chat_send_message template: name={$template} lang={$lang} params=" . json_encode($params));
$meta = ['canal' => 'turnero'];
if ($operatorId) $meta['operator_id'] = $operatorId;
$response = $wa->sendTemplateMessage($user['phone_number'], $template, $lang, $params, [], null, $meta);
} else {
$extra = ['canal' => 'turnero'];
if ($operatorId) $extra['operator_id'] = $operatorId;