netflie/laravel-notification-whatsapp
Send WhatsApp notifications from your Laravel app using this channel for the built-in notification system. It supports multiple drivers, queued messages, and a simple API for delivering text and media messages to your users.
composer require netflie/laravel-notification-whatsapp:^1.4
.env. Run php artisan config:clear after credential changes.config/whatsapp.php or the package’s published config file.Component.php and Component/Document.php if you send media.WhatsAppChannel.public function via(object $notifiable): array
{
return [\Netflie\WhatsApp\WhatsAppChannel::class];
}
public function toWhatsapp(object $notifiable)
{
return \Netflie\WhatsApp\WhatsAppMessage::create()
->document('https://example.com/invoices/123.pdf', 'invoice-123.pdf');
}
The second document() argument is new in 1.4.0 and is optional. Existing calls with only the document URL should continue to work.via() and implement the package’s toWhatsapp() method on the notification.routeNotificationForWhatsapp() method or a dedicated phone column. Avoid hard-coding phone numbers inside notifications.return WhatsAppMessage::create()
->document($invoiceUrl, "invoice-{$invoice->number}.pdf");
ShouldQueue for non-critical sends. This keeps request latency down and lets Laravel retry failed API calls.Notification::fake() and assert the channel/notification was sent. For payload-level tests, inspect the message object’s toArray() output; 1.4.0 includes the document filename there.^1.4, update your app’s Illuminate constraints, and run the notification test suite. The release updates illuminate/notifications and illuminate/support for Laravel 12.filename parameter is optional and backwards-compatible. Existing document($url) calls should still work, but explicitly setting a filename avoids provider-side filename inference and gives recipients a cleaner download name.toArray(). If you snapshot or log message payloads in tests, update expectations only where you assert exact arrays.toArray() before sending and by checking the WhatsApp API/provider response. For document failures, verify URL accessibility, MIME type, file size limits, and filename extension.phpstan/phpstan 2.1 support is development/static-analysis related, not a runtime feature. It should not affect production behavior.How can I help you explore Laravel packages today?