PHPackages                             teodoriu/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. teodoriu/laravel-whatsapp

ActiveLibrary[API Development](/categories/api)

teodoriu/laravel-whatsapp
=========================

A Whatsapp Business Cloud API wrapper for Laravel.

v1.0.5(5mo ago)41.5k—0%1MITPHPPHP ^8.1CI passing

Since Jun 21Pushed 5mo agoCompare

[ Source](https://github.com/teodoriu/laravel-whatsapp)[ Packagist](https://packagist.org/packages/teodoriu/laravel-whatsapp)[ RSS](/packages/teodoriu-laravel-whatsapp/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (5)Versions (8)Used By (0)

Whatsapp Business Cloud API for Laravel
=======================================

[](#whatsapp-business-cloud-api-for-laravel)

A Laravel package for the [Whatsapp Business Cloud API](https://developers.facebook.com/docs/whatsapp/cloud-api).

- [Installation](#installation)
- [Configuration](#configuration)
- [Usage](#usage)
    - [Media](#media)
    - [Business profile](#business-profile)
- [Notification Channel](#notification-channel)
- [License](#license)

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

[](#installation)

```
composer require teodoriu/laravel-whatsapp
```

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

[](#configuration)

You will need to set the `WHATSAPP_TOKEN` and `WHATSAPP_NUMBER_ID` values in your .env.

For further configuration, please see [config/whatsapp.php](config/whatsapp.php). You can modify the configuration by copying it to your local `config` directory or by defining the environment variables used in the config file:

```
php artisan vendor:publish --provider="Teodoriu\Whatsapp\WhatsappServiceProvider" --tag=config
```

Usage
-----

[](#usage)

You can send a messages to a single or multiple clients.

```
use Teodoriu\Whatsapp\Messages;

Whatsapp::send('13333333333', Messages\TemplateMessage::create()
    ->name('one_time_password')
    ->language('en_US')
    ->body(Messages\Components\Body::create([
        Messages\Components\Parameters\Text::create('000000'),
    ])));
```

You can also respond to other messages in the conversation with any message type (except reaction message):

```
use Teodoriu\Whatsapp\Messages\TextMessage;

Whatsapp::send('13333333333', TextMessage::create('Answer to your message')->respondTo('wamid.91n23...'));
```

Send template messages

```
Whatsapp::send(
  phones: 13333333333,
  message: FlowMessage::create()
  ->name('template_name')
  ->language('language_code')
);
```

and you can mark messages as read:

```
Whatsapp::markRead('wamid.91n23...');
```

### Marketing Messages API

[](#marketing-messages-api)

You can send messages through the WhatsApp Marketing Messages API using the `sendMarketing()` method. This endpoint is specifically designed for marketing template messages and provides enhanced metrics and performance insights.

```
use Teodoriu\Whatsapp\Messages;

// Send a marketing template message
Whatsapp::sendMarketing('13333333333', Messages\TemplateMessage::create()
    ->name('marketing_template_name')
    ->language('en_US')
    ->body(Messages\Components\Body::create([
        Messages\Components\Parameters\Text::create('Your marketing content'),
    ])));

// Send to multiple recipients
Whatsapp::sendMarketing(
    ['13333333333', '14444444444'],
    Messages\TemplateMessage::create()
        ->name('marketing_template_name')
        ->language('en_US')
);
```

**Note:** The Marketing Messages API requires your WhatsApp Business Account to be registered on the Cloud API and you must accept Meta's Marketing Messages API Terms of Service in your Meta Business Manager account.

By default the messages will be sent from the `default_number_id`, if you want to use other you can use `Whatsapp::numberId()` or add the alias to the config's `numbers` list and use `Whatsapp::numberName()`. Also you can set the token manually with `Whatsapp::token()` or you can set both the token and numberId you can use `Whatsapp::client()`

### Supported messages

[](#supported-messages)

- Text Message
- Media Message
- Template Message
- Reaction Message
- Contacts Message
- Interactive Message
- Location Message

### Media

[](#media)

You can also [manage media](https://developers.facebook.com/docs/whatsapp/cloud-api/reference/media) with:

```
Whatsapp::uploadMedia(string $file, string $type = null, bool $retrieveAllData = true): \Teodoriu\Whatsapp\WhatsappMedia|string
Whatsapp::getMedia(string $mediaId, bool $download = false): \Teodoriu\Whatsapp\WhatsappMedia
Whatsapp::deleteMedia(\Teodoriu\Whatsapp\WhatsappMedia|string $id): bool
Whatsapp::downloadMedia(string|\Teodoriu\Whatsapp\WhatsappMedia $media): \Teodoriu\Whatsapp\WhatsappMedia
```

### Business Profile

[](#business-profile)

There are also two ways to manage the number's business profile:

```
Whatsapp::getProfile(): \Teodoriu\Whatsapp\BusinessProfile
Whatsapp::updateProfile(\Teodoriu\Whatsapp\BusinessProfile|array $data): bool
```

Webhooks
--------

[](#webhooks)

Whatsapp allows you to subscribe to [webhooks](https://developers.facebook.com/docs/whatsapp/cloud-api/guides/set-up-webhooks) to receive notifications and most importantly messages from your customers. Both subscriptions and notifications are handled out of the box in the route whatsapp/webhook (you can change the path with the WHATSAPP\_WEBHOOK\_PATH env variable).

When a you register the webhook meta will send a subscription, this requires a verification token that you set, you will need to set it with WHATSAPP\_WEBHOOK\_VERIFY\_TOKEN env setting. When receiving a subscription intent a `Teodoriu\Whatsapp\Events\SubscriptionIntentReceived` event will be fired, if the request is successful the `Teodoriu\Whatsapp\Events\SuccessfullySubscribed` event will fire too.

On the other hand notifications will trigger a `Teodoriu\Whatsapp\Events\WebhookReceived` event with all the payload, if you want to protect this route verifying the sha256 signature you must set the WHATSAPP\_WEBHOOK\_SIGNATURE\_VERIFY to true and the WHATSAPP\_SECRET to your whatsapp's app secret.

If the payload is invalid a `Teodoriu\Whatsapp\Events\UnprocessableWebhookPayload` event will be fired with the exception describing the error.

If you want to know when a specific notification is fired you can subscribe to this events:

- `Teodoriu\Whatsapp\Events\WebhookEntry` generic entry
- `Teodoriu\Whatsapp\Events\MessagesReceived` for the `messages` entry

Notification Channel
--------------------

[](#notification-channel)

This library has support for channel notification, just add the `routeNotificationForWhatsapp()` function to the Notifiable user (it can return a single whatsapp\_id or an array of them):

```
class User extends Authenticatable
{
    use Notifiable;

    /**
     * @return string|array
     */
    public function routeNotificationForWhatsapp(): string|array
    {
        return "{$this->phone_code}{$this->phone}";
    }
}
```

Now just create a notification that implements the `toWhatsapp()` function:

```
//...
use Teodoriu\Whatsapp\Messages\TemplateMessage;
use Teodoriu\Whatsapp\Messages\Components\Parameters;
use Teodoriu\Whatsapp\WhatsappChannel;

class VerificationCode extends Notification
{
    use Queueable;

    /**
     * Create a new notification instance.
     *
     * @return void
     */
    public function __construct(protected string $code)
    {
        //
    }

    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        return [WhatsappChannel::class];
    }

    /**
     * Get the message representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return \Teodoriu\Whatsapp\Messages\WhatsappMessage
     */
    public function toWhatsapp($notifiable)
    {
        return TemplateMessage::create('one_time_password')
            ->language('en_US')
            ->body([
                Parameters\Text::create('123456'),
            ]);
    }
}
```

Now you can send whatsapp notifications:

```
$user->notify(new VerificationCode('12345678'));
```

Configuration file
------------------

[](#configuration-file)

```
return [
    /**
     * The whatsapp token to be used.
     */
    'token' => env('WHATSAPP_TOKEN'),

    /**
     * The whatsapp's app secret code. Required for webhook request signature verification.
     */
    'secret' => env('WHATSAPP_SECRET'),

    /**
     * The default NUMBER ID used to send the messages.
     */
    'default_number_id' => env('WHATSAPP_NUMBER_ID'),

    /**
     * If you want to use other number id's you can add them here so you can call
     * `numberName` with the name you provide here and make it easier to change
     * the phone where the messages are sended.
     */
    'numbers' => [
        // 'fallback' => env('WHATSAPP_FALLBACK_NUMBER_ID'),
    ],

    'webhook' => [
        /**
         * Wether to enable the webhook routes
         */
        'enabled' => env('WHATSAPP_WEBHOOK_ENABLED', true),

        /**
         * The webhook path, by default "/whatsapp/webhook"
         */
        'path' => env('WHATSAPP_WEBHOOK_PATH', 'whatsapp'),

        /**
         * The webhook verification token.
         * For more information check https://developers.facebook.com/docs/graph-api/webhooks/getting-started#verification-requests
         */
        'verify_token' => env('WHATSAPP_WEBHOOK_VERIFY_TOKEN'),

        /**
         * Wether the webhook request signature should be verified or not.
         */
        'verify_signature' => env('WHATSAPP_WEBHOOK_SIGNATURE_VERIFY', false),
    ],
];
```

Missing features
----------------

[](#missing-features)

- Register/deregister/validate new phone numbers

License
-------

[](#license)

This project is licensed under the [MIT License](LICENSE).

Documentation
-------------

[](#documentation)

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance72

Regular maintenance activity

Popularity25

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 76.9% 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 ~89 days

Recently: every ~133 days

Total

7

Last Release

160d ago

Major Versions

v0.0.1 → v1.0.02024-06-21

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/11290723?v=4)[Teodor B.](/maintainers/teodoriu)[@teodoriu](https://github.com/teodoriu)

---

Top Contributors

[![MissaelAnda](https://avatars.githubusercontent.com/u/31199350?v=4)](https://github.com/MissaelAnda "MissaelAnda (30 commits)")[![teodoriu](https://avatars.githubusercontent.com/u/11290723?v=4)](https://github.com/teodoriu "teodoriu (7 commits)")[![mend-bolt-for-github[bot]](https://avatars.githubusercontent.com/in/16809?v=4)](https://github.com/mend-bolt-for-github[bot] "mend-bolt-for-github[bot] (1 commits)")[![teodor-ideologiq](https://avatars.githubusercontent.com/u/54398746?v=4)](https://github.com/teodor-ideologiq "teodor-ideologiq (1 commits)")

---

Tags

apilaravelsdkfacebookwhatsapp

### Embed Badge

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

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

###  Alternatives

[laravel/pulse

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

1.7k12.1M99](/packages/laravel-pulse)[missael-anda/laravel-whatsapp

A Whatsapp Business Cloud API wrapper for Laravel.

677.5k](/packages/missael-anda-laravel-whatsapp)[andreaselia/laravel-api-to-postman

Generate a Postman collection automatically from your Laravel API

1.0k586.2k3](/packages/andreaselia-laravel-api-to-postman)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[psalm/plugin-laravel

Psalm plugin for Laravel

3274.9M308](/packages/psalm-plugin-laravel)[resend/resend-laravel

Resend for Laravel

1191.4M6](/packages/resend-resend-laravel)

PHPackages © 2026

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