PHPackages                             vibrantcoder/whatsapp-notifier - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. vibrantcoder/whatsapp-notifier

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

vibrantcoder/whatsapp-notifier
==============================

Reusable Laravel package for sending WhatsApp notifications via multiple drivers (Twilio, Meta Cloud API).

v1.0.0(1mo ago)00MITPHPPHP ^8.1CI failing

Since Apr 30Pushed 1mo agoCompare

[ Source](https://github.com/vibrantcoder/whatsapp-notifier)[ Packagist](https://packagist.org/packages/vibrantcoder/whatsapp-notifier)[ Docs](https://github.com/vibrantcoder/whatsapp-notifier)[ RSS](/packages/vibrantcoder-whatsapp-notifier/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (7)Versions (2)Used By (0)

WhatsApp Notifier for Laravel
=============================

[](#whatsapp-notifier-for-laravel)

Reusable Laravel package for sending WhatsApp messages through multiple drivers (**Twilio**, **Meta Cloud API**) with dynamic templates, queues, events, and DB logging. Works with Laravel 10, 11, 12, 13.

---

Features
--------

[](#features)

- **Driver pattern** — `meta`, `twilio`, or your own custom driver.
- **Fluent template builder** — `metaTemplate()` for any Meta template (text body, image/video/document headers, URL/quick-reply/copy-code buttons, location, named placeholders).
- **Template registry** — declare each template once in config, reference by alias from app code.
- **Queue support** — fire-and-forget async delivery via Laravel queues.
- **Events** — `WhatsAppMessageSending`, `WhatsAppMessageSent`, `WhatsAppMessageFailed`.
- **DB logging** — every send attempt persisted to `whatsapp_messages` (success or failure, with full Meta response).
- **Service provider + facade** — auto-discovered, no manual registration.

---

Requirements
------------

[](#requirements)

- PHP 8.1+
- Laravel 10, 11, 12, or 13
- Composer 2.x

---

Installation
------------

[](#installation)

There are three ways to install — pick the one that matches where the package lives.

### Option 1 — Local path repository (during development)

[](#option-1--local-path-repository-during-development)

Use this when the package source lives inside or next to your Laravel app (e.g. `packages/vibrantcoders/whatsapp-notifier`).

In your Laravel app's `composer.json`:

```
{
    "require": {
        "vibrantcoder/whatsapp-notifier": "@dev"
    },
    "repositories": [
        {
            "type": "path",
            "url": "../packages/vibrantcoders/whatsapp-notifier",
            "options": { "symlink": true }
        }
    ]
}
```

> The `@dev` constraint is required because path repos publish as `dev-main`. `symlink: true` means edits inside the package are picked up immediately.

```
composer update vibrantcoder/whatsapp-notifier
```

### Option 2 — Private Git repository

[](#option-2--private-git-repository)

```
{
    "require": {
        "vibrantcoder/whatsapp-notifier": "^1.0"
    },
    "repositories": [
        {
            "type": "vcs",
            "url": "git@github.com:vibrantcoder/whatsapp-notifier.git"
        }
    ]
}
```

```
composer require vibrantcoder/whatsapp-notifier
```

### Option 3 — Public Packagist (once published)

[](#option-3--public-packagist-once-published)

```
composer require vibrantcoder/whatsapp-notifier
```

---

Setup (after install)
---------------------

[](#setup-after-install)

One command does everything — publishes config, migrations, env keys, and runs migrate:

```
php artisan whatsapp:install
```

Service provider and facade are auto-discovered — no manual registration in `config/app.php` is required.

For the manual breakdown, see [INSTALL.md](./INSTALL.md).

---

Environment variables
---------------------

[](#environment-variables)

Add the relevant block to your `.env`:

```
# Default driver: meta | twilio |
WHATSAPP_DRIVER=meta

# Meta Cloud API
META_WHATSAPP_PHONE_ID=1001922139681184
META_WHATSAPP_TOKEN=EAAxxx...
META_WHATSAPP_VERSION=v25.0

# Twilio (only if using the twilio driver)
# TWILIO_SID=ACxxxx
# TWILIO_AUTH_TOKEN=xxxx
# TWILIO_WHATSAPP_FROM=whatsapp:+14155238886

# Queue
WHATSAPP_QUEUE=true
WHATSAPP_QUEUE_NAME=whatsapp

# Logging
WHATSAPP_LOG=true
WHATSAPP_LOG_DB=true
```

> ⚠️ The Meta **temporary** access token expires every 24 hours. For production, generate a **System User** token from Meta Business Settings (60-day or never-expiring).

---

Usage
-----

[](#usage)

### 1. Inline free-form message (Meta or Twilio)

[](#1-inline-free-form-message-meta-or-twilio)

Free-form messages are only deliverable in the 24-hour customer-care window on Meta. Use templates outside that window.

```
use VibrantCoders\WhatsAppNotifier\Facades\WhatsApp;

WhatsApp::message('Hello {{name}}, this is a test.')
    ->with(['name' => 'Ali'])
    ->send('919727927400');
```

### 2. Meta template via the **registry** (recommended)

[](#2-meta-template-via-the-registry-recommended)

Declare each template once in `config/whatsapp.php`:

```
'meta_templates' => [
    'order_confirmed' => [
        'name'     => 'jaspers_market_order_confirmation_v1',
        'language' => 'en_US',
        'body'     => ['customer_name', 'order_id', 'expected_delivery'],
    ],
],
```

Then in your code:

```
WhatsApp::metaTemplate('order_confirmed', [
    'customer_name'     => $order->customer_name,
    'order_id'          => (string) $order->id,
    'expected_delivery' => $order->expectedDeliveryFormatted(),
])->send($order->customer_phone);
```

### 3. Meta template via the **fluent builder**

[](#3-meta-template-via-the-fluent-builder)

Use this when the template has dynamic header/buttons that vary per call, or when you don't want to maintain the registry.

```
WhatsApp::metaTemplate('jaspers_market_order_confirmation_v1', 'en_US')
    ->body('Ali', '1042', '4 May 2026')
    ->send('919727927400');

// Image header + URL button
WhatsApp::metaTemplate('order_shipped_v2')
    ->headerImage('https://cdn.example.com/box.jpg')
    ->body('Ali', '1042')
    ->urlButton(0, '1042')
    ->send($phone);

// PDF document header
WhatsApp::metaTemplate('invoice_ready')
    ->headerDocument('https://cdn.example.com/inv-1042.pdf', 'invoice-1042.pdf')
    ->body('Ali', '1042', 'INR 1,499.00')
    ->send($phone);

// Quick-reply buttons
WhatsApp::metaTemplate('feedback_request')
    ->body('Ali')
    ->quickReplyPayload(0, 'YES')
    ->quickReplyPayload(1, 'NO')
    ->send($phone);

// Named placeholders ({{customer_name}} style)
WhatsApp::metaTemplate('order_confirmed_named')
    ->bodyNamed(['customer_name' => 'Ali', 'order_id' => '1042'])
    ->send($phone);

// Escape hatch — supply the full components array
WhatsApp::metaTemplate('any_template')->withRawComponents([...])->send($phone);
```

### 4. Override driver per call

[](#4-override-driver-per-call)

```
WhatsApp::via('twilio')->message('Hi!')->send('+923001234567');
WhatsApp::via('meta')->metaTemplate('order_confirmed', [...])->send($phone);
```

### 5. Force sync or queue

[](#5-force-sync-or-queue)

```
WhatsApp::message('OTP: 123456')->queue(false)->send($phone);  // sync
WhatsApp::message('Receipt')->queue(true)->send($phone);        // async
```

### 6. Event-driven delivery (recommended for app code)

[](#6-event-driven-delivery-recommended-for-app-code)

```
// app/Events/OrderPlaced.php
class OrderPlaced
{
    use Dispatchable, SerializesModels;
    public function __construct(public Order $order) {}
}

// app/Listeners/SendOrderConfirmationWhatsApp.php
class SendOrderConfirmationWhatsApp
{
    public function handle(OrderPlaced $event): void
    {
        WhatsApp::metaTemplate('order_confirmed', [
            'customer_name'     => $event->order->customer_name,
            'order_id'          => (string) $event->order->id,
            'expected_delivery' => $event->order->expectedDeliveryFormatted(),
        ])->send($event->order->customer_phone);
    }
}

// Anywhere in your code:
event(new OrderPlaced($order));
```

Laravel auto-discovers the listener from the typehint — no `EventServiceProvider`mapping required (Laravel 11+).

---

Supported template features
---------------------------

[](#supported-template-features)

FeatureBuilder methodRegistry keyBody `{{1}} {{2}}``body(...$values)``'body' => [...]`Named body `{{name}}``bodyNamed(['k' => 'v'])`(use builder)Header text`headerText('...')``'header' => 'text'`Header image`headerImage($url)``'header' => 'image'`Header video`headerVideo($url)``'header' => 'video'`Header document`headerDocument($url, $filename)``'header' => 'document'`Header location`headerLocation($lat, $lng, $name, $addr)`(use builder)URL button`urlButton($index, $value)``'buttons' => [['type' => 'url']]`Quick-reply button`quickReplyPayload($index, $payload)``'buttons' => [['type' => 'quick_reply']]`Copy-code button`copyCodeButton($index, $code)``'buttons' => [['type' => 'copy_code']]`Raw passthrough`withRawComponents([...])`—---

Custom drivers
--------------

[](#custom-drivers)

Register in any service provider's `boot()`:

```
use VibrantCoders\WhatsAppNotifier\Contracts\WhatsAppDriver;
use VibrantCoders\WhatsAppNotifier\Services\WhatsAppManager;

app(WhatsAppManager::class)->extend('myprovider', function ($app, $config) {
    return new class implements WhatsAppDriver {
        public function name(): string { return 'myprovider'; }
        public function send(string $to, string $message, array $options = []): array
        {
            // your provider call here...
            return ['success' => true, 'id' => '...', 'response' => [...], 'error' => null];
        }
    };
});
```

Then `WhatsApp::via('myprovider')->message(...)->send(...)`.

---

Logged messages
---------------

[](#logged-messages)

Every attempt — sync or queued, success or failure — is persisted:

```
use VibrantCoders\WhatsAppNotifier\Models\WhatsAppMessage;

WhatsAppMessage::orderByDesc('id')->limit(50)->get();
```

Columns:

ColumnType`id`bigint`driver`varchar (32)`to`varchar (32)`body`text`status`pending|sent|failed`provider_id`varchar`error`text (nullable)`response`json (nullable)`sent_at`timestamp`created_at`timestamp`updated_at`timestamp---

Quick test (5 minutes, no real templates needed)
------------------------------------------------

[](#quick-test-5-minutes-no-real-templates-needed)

```
# 1. Install + setup
composer update vibrantcoder/whatsapp-notifier
php artisan vendor:publish --tag=whatsapp-config
php artisan vendor:publish --tag=whatsapp-migrations
php artisan migrate

# 2. Add a tinker test
php artisan tinker
>>> use VibrantCoders\WhatsAppNotifier\Facades\WhatsApp;
>>> WhatsApp::metaTemplate('order_confirmed', [
...     'customer_name' => 'Ali',
...     'order_id' => '999',
...     'expected_delivery' => '4 May 2026',
... ])->send('919727927400');
```

You should receive a real WhatsApp message and see a row in the `whatsapp_messages` table with `status = sent` and a `provider_id` returned by Meta.

---

Troubleshooting
---------------

[](#troubleshooting)

SymptomCause / fix`(#132001) Template name does not exist in the translation`Template not approved, wrong name, or wrong language code. Check WhatsApp Manager.`(#131030) Recipient phone number not in allowed list`You're using Meta's free test number — add the recipient under "Send messages to" in API Setup.`Invalid OAuth access token`Temp token expired (24h). Generate a new one in API Setup, paste into `.env`, run `php artisan config:clear`.`Meta template alias [...] is not registered`Add the alias to `meta_templates` in `config/whatsapp.php`, or use builder mode.Sends silently fail outside 24h windowMeta only allows **template** messages outside the customer-care window. Use `metaTemplate()`, not `message()`.Queue jobs not runningMake sure a worker is running: `php artisan queue:work --queue=whatsapp`---

Roadmap
-------

[](#roadmap)

- Webhook receiver to update `whatsapp_messages` status from Meta callbacks (`delivered` / `read` / `failed`)
- Inbound message handling (conversations + agents)
- Carousel + authentication (OTP) template helpers
- Rate limiting per Meta tier (1k / 10k / 100k / unlimited messages-per-day)

---

License
-------

[](#license)

MIT © VibrantCoders

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance92

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

40d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/011a3d2612a29a5fcd1731cb7b17e2996e94e0bcf9f033fb33987a5aa8926dac?d=identicon)[vibrantcoder](/maintainers/vibrantcoder)

---

Top Contributors

[![dharmeshsavaliya](https://avatars.githubusercontent.com/u/22440974?v=4)](https://github.com/dharmeshsavaliya "dharmeshsavaliya (3 commits)")

---

Tags

laravelnotificationtwiliomessagingwhatsappmetacloud-api

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/vibrantcoder-whatsapp-notifier/health.svg)

```
[![Health](https://phpackages.com/badges/vibrantcoder-whatsapp-notifier/health.svg)](https://phpackages.com/packages/vibrantcoder-whatsapp-notifier)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3325.1M337](/packages/psalm-plugin-laravel)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9732.3M121](/packages/roots-acorn)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k14.1M120](/packages/laravel-pulse)[spatie/laravel-health

Monitor the health of a Laravel application

88011.3M149](/packages/spatie-laravel-health)[laravel-notification-channels/twilio

Provides Twilio notification channel for Laravel

2588.1M15](/packages/laravel-notification-channels-twilio)[flarum/core

Delightfully simple forum software.

261.4M2.2k](/packages/flarum-core)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
