isConfigured()) { $this->error('Set WHATSAPP_TOKEN and WHATSAPP_PHONE_NUMBER_ID in .env first.'); return 1; } $to = $client->normalizeMsisdn($this->option('to') ?: env('ADMIN_PHONE_NUMBER')); if (!$to) { $this->error('Pass --to=60193450165 or set ADMIN_PHONE_NUMBER.'); return 1; } $template = config('whatsapp.template', 'hello_world'); $lang = config('whatsapp.template_lang', 'en_US'); $bodyParams = []; if (strtolower($template) !== 'hello_world') { $bodyParams = [ 'Tampoi', 'TEST-SAG', '100.00', 'Maybank ****1234', date('d/m/Y'), 'TEST-REF', ]; } $this->info("Sending {$template} ({$lang}) to {$to} …"); $response = $client->sendTemplate($to, $template, $lang, $bodyParams); if ($response->successful()) { $this->info('OK ' . $response->status() . ' ' . $response->body()); return 0; } $this->error('FAIL ' . $response->status() . ' ' . $response->body()); return 1; } }