bahricanli/whatsapp-bridge

Laravel notification channel for WhatsApp via Baileys Bridge

Maintainers

Package info

github.com/bahricanli/whatsapp-bridge

pkg:composer/bahricanli/whatsapp-bridge

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.2 2026-05-01 21:22 UTC

This package is auto-updated.

Last update: 2026-05-01 21:22:57 UTC


README

Latest Version License: MIT

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

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.