PHPackages                             tizfai/laravel-whatsapp - 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. [API Development](/categories/api)
4. /
5. tizfai/laravel-whatsapp

ActiveLibrary[API Development](/categories/api)

tizfai/laravel-whatsapp
=======================

WhatsApp Business API integration for Laravel - Send messages, PDFs, and secure prescription links

v1.0.4(4mo ago)021↓78.6%MITPHPPHP ^8.1

Since Feb 25Pushed 4mo agoCompare

[ Source](https://github.com/Tizfai-Technologies-AB/laravel-whatsapp)[ Packagist](https://packagist.org/packages/tizfai/laravel-whatsapp)[ RSS](/packages/tizfai-laravel-whatsapp/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (5)Versions (6)Used By (0)

tizfai/laravel-whatsapp
=======================

[](#tizfailaravel-whatsapp)

WhatsApp Business API (Meta Cloud API) integration for Laravel. Send text messages, PDFs, and generate secure time-limited share links for any model.

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

[](#installation)

```
composer require tizfai/laravel-whatsapp
```

Publish config and run migration:

```
php artisan vendor:publish --tag=whatsapp-config
php artisan migrate
```

Configuration
-------------

[](#configuration)

Add to your `.env`:

```
WHATSAPP_ACCESS_TOKEN=EAAG...your_system_user_token
WHATSAPP_PHONE_NUMBER_ID=984998221371272
WHATSAPP_BUSINESS_ACCOUNT_ID=1615131750010820
WHATSAPP_WEBHOOK_VERIFY_TOKEN=your_custom_verify_token_here
WHATSAPP_API_VERSION=v21.0
WHATSAPP_LINK_EXPIRY_HOURS=24
WHATSAPP_MAX_ACCESS_COUNT=3
```

---

Usage
-----

[](#usage)

### Send Text Message

[](#send-text-message)

```
use Tizfai\LaravelWhatsApp\Facades\WhatsApp;

$result = WhatsApp::sendText('+8801711111111', 'Hello from DocFai!');

if ($result['success']) {
    echo $result['message_id'];
}
```

### Send PDF Document

[](#send-pdf-document)

```
$result = WhatsApp::sendDocument(
    phone: '+8801711111111',
    fileUrl: 'https://your-wasabi-url.com/prescription.pdf',
    filename: 'prescription_001.pdf',
    caption: 'Your prescription'
);
```

### Send Text + PDF Together

[](#send-text--pdf-together)

```
$result = WhatsApp::sendDocumentWithText(
    toPhone: '+8801711111111',
    fileUrl: 'https://storage.com/prescription.pdf',
    filename: 'prescription.pdf',
    textMessage: '🏥 Your prescription is attached.',
    caption: 'DocFai Prescription'
);
```

### Send Template Message

[](#send-template-message)

```
$result = WhatsApp::sendTemplate(
    toPhone: '+8801711111111',
    templateName: 'prescription_ready',
    parameters: [
        ['type' => 'text', 'text' => 'Kamal'],
        ['type' => 'text', 'text' => 'RX-2026-001'],
    ],
    languageCode: 'en'
);
```

---

Secure Share Links
------------------

[](#secure-share-links)

Generate time-limited, access-counted secure links for any Eloquent model.

### Create Share Link Only

[](#create-share-link-only)

```
$share = WhatsApp::createShareLink(
    model: $prescription,
    recipientPhone: '+8801711111111',
    recipientName: 'Kamal Tizfai',
    expiryHours: 24,     // optional, uses config default
    maxAccess: 3,         // optional, uses config default
    metadata: ['shared_by' => auth()->id()]
);

echo $share->getShareUrl(); // https://yourapp.com/wa-view/{token}
echo $share->isValid();     // true/false
```

### Create Share Link AND Send via WhatsApp

[](#create-share-link-and-send-via-whatsapp)

```
$result = WhatsApp::sendShareLink(
    model: $prescription,
    recipientPhone: '+8801711111111',
    recipientName: 'Kamal Tizfai',
    messageBody: "🏥 Your prescription is ready:\n{URL}\n\nValid 24h | Max 3 views",
    expiryHours: 24,
    maxAccess: 3
);

$share = $result['share']; // WhatsAppShare model instance
```

### Access the Share in Your Controller

[](#access-the-share-in-your-controller)

Add a public route in your app:

```
// routes/web.php
Route::get('/wa-view/{token}', [YourPrescriptionViewController::class, 'show']);
```

```
// YourPrescriptionViewController.php
use Tizfai\LaravelWhatsApp\Models\WhatsAppShare;

public function show(string $token, Request $request)
{
    $share = WhatsAppShare::where('secure_token', $token)->firstOrFail();

    if (!$share->isValid()) {
        abort(403, 'Link has expired or access limit reached');
    }

    $share->recordAccess([
        'ip' => $request->ip(),
        'user_agent' => $request->userAgent(),
    ]);

    $prescription = $share->shareable; // Polymorphic - returns your model
    return view('prescriptions.view', compact('prescription'));
}
```

---

Webhook Setup
-------------

[](#webhook-setup)

The package automatically registers these routes:

- `GET  /api/webhooks/whatsapp` - Meta webhook verification
- `POST /api/webhooks/whatsapp` - Delivery status &amp; incoming messages

**In Meta Developer Console:**

1. Go to your app → WhatsApp → Configuration
2. Webhook URL: `https://yourdomain.com/api/webhooks/whatsapp`
3. Verify token: same value as `WHATSAPP_WEBHOOK_VERIFY_TOKEN`
4. Subscribe to: `messages`

---

Artisan Commands
----------------

[](#artisan-commands)

```
# Clean up expired shares (default: older than 30 days)
php artisan whatsapp:clean-shares

# Preview without deleting
php artisan whatsapp:clean-shares --dry-run

# Custom retention period
php artisan whatsapp:clean-shares --days=7
```

Schedule in `app/Console/Kernel.php`:

```
$schedule->command('whatsapp:clean-shares')->daily();
```

---

API Reference
-------------

[](#api-reference)

MethodDescription`sendText($phone, $message, $previewUrl)`Send plain text`sendDocument($phone, $url, $filename, $caption)`Send PDF/file`sendTemplate($phone, $name, $params, $lang)`Send template`sendDocumentWithText(...)`Send text + document`sendShareLink($model, $phone, $name, ...)`Create share + send`createShareLink($model, $phone, $name, ...)`Create share only`validateToken()`Test API credentials`formatPhone($phone)`Format to E.164 (no +)---

License
-------

[](#license)

MIT

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance77

Regular maintenance activity

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity47

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

Every ~0 days

Total

5

Last Release

127d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/208376062?v=4)[Tizfai-BD](/maintainers/Tizfai-BD)[@Tizfai-BD](https://github.com/Tizfai-BD)

---

Top Contributors

[![Muradhossain19](https://avatars.githubusercontent.com/u/100775507?v=4)](https://github.com/Muradhossain19 "Muradhossain19 (8 commits)")

---

Tags

laravelmessagingwhatsappmetawhatsapp-business-api

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/tizfai-laravel-whatsapp/health.svg)

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[api-platform/laravel

API Platform support for Laravel

58171.6k14](/packages/api-platform-laravel)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5021.9k](/packages/simplestats-io-laravel-client)[defstudio/telegraph

A laravel facade to interact with Telegram Bots

816333.8k3](/packages/defstudio-telegraph)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

45444.2k1](/packages/pressbooks-pressbooks)

PHPackages © 2026

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