bahricanli / whatsapp-bridge
Laravel notification channel for WhatsApp via Baileys Bridge
v1.0.2
2026-05-01 21:22 UTC
Requires
- php: >=8.0
- guzzlehttp/guzzle: ^7.0
- illuminate/notifications: ^8.0|^9.0|^10.0|^11.0
- illuminate/support: ^8.0|^9.0|^10.0|^11.0
Requires (Dev)
- mockery/mockery: ^1.5
- orchestra/testbench: ^6.0|^7.0|^8.0
- phpunit/phpunit: ^9.0|^10.0
README
Laravel notification channel for sending WhatsApp messages via a self-hosted Baileys bridge.
Designed as a parallel channel alongside bahricanli/netgsm — the API is intentionally similar for easy integration.
Requirements
- PHP 8.0+
- Laravel 8+
- A running Baileys WhatsApp bridge (see docker-sip-ai-service/whatsapp-bridge)
Installation
composer require bahricanli/whatsapp-bridge
Laravel's auto-discovery registers the service provider automatically.
Publish the config file:
php artisan vendor:publish --tag=whatsapp-bridge-config
Configuration
Add the following to your .env:
WHATSAPP_BRIDGE_URL=http://localhost:3000 WHATSAPP_BRIDGE_API_KEY= # optional WHATSAPP_BRIDGE_TIMEOUT=10
Or edit config/whatsapp-bridge.php directly.
Usage
1. Direct usage (no notification system)
use NotificationChannels\WhatsAppBridge\WhatsAppFacade as WhatsApp; use NotificationChannels\WhatsAppBridge\WhatsAppMessage; // Shorthand WhatsApp::sendMessage('905551234567', 'Doğrulama kodunuz: 4821'); // Fluent message WhatsApp::sendMessage( WhatsAppMessage::create('Doğrulama kodunuz: 4821')->to('905551234567') );
2. As a Laravel notification channel
In your notification class:
use Illuminate\Notifications\Notification; use NotificationChannels\WhatsAppBridge\WhatsAppChannel; use NotificationChannels\WhatsAppBridge\WhatsAppMessage; class PhoneVerificationNotification extends Notification { public function __construct(private string $code) {} public function via($notifiable): array { return [WhatsAppChannel::class]; } public function toWhatsApp($notifiable): WhatsAppMessage { return WhatsAppMessage::create("Doğrulama kodunuz: {$this->code}"); // Recipient is pulled from routeNotificationForWhatsAppBridge() } }
In your notifiable model (e.g. User):
public function routeNotificationForWhatsAppBridge(): string { return $this->phone_number; // e.g. 905551234567 }
3. Parallel with NetGSM
Send via both SMS and WhatsApp simultaneously:
public function via($notifiable): array { return [ \NotificationChannels\Netgsm\NetgsmChannel::class, \NotificationChannels\WhatsAppBridge\WhatsAppChannel::class, ]; } public function toNetgsm($notifiable): string { return "Doğrulama kodunuz: {$this->code}"; } public function toWhatsApp($notifiable): WhatsAppMessage { return WhatsAppMessage::create("Doğrulama kodunuz: {$this->code}"); }
Phone Number Formats
The library normalizes phone numbers automatically:
| Input | Stored as |
|---|---|
905551234567 |
905551234567 |
+905551234567 |
905551234567 |
0905551234567 |
905551234567 |
05551234567 |
905551234567 |
5551234567 |
905551234567 |
Events
| Event | Fired |
|---|---|
SendingMessage |
Before a message is sent |
MessageWasSent |
After successful delivery |
use NotificationChannels\WhatsAppBridge\Events\MessageWasSent; Event::listen(MessageWasSent::class, function (MessageWasSent $event) { Log::info('WhatsApp sent', [ 'to' => $event->message->to, 'content' => $event->message->content, ]); });
Bridge Status Check
use NotificationChannels\WhatsAppBridge\WhatsAppFacade as WhatsApp; $status = WhatsApp::status(); // ['ok' => true, 'connected' => true, 'sessions' => 3]
License
MIT — see LICENSE.md.