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

ActiveLibrary[API Development](/categories/api)

logicalcrow/laravel-whatsapp-api
================================

A Whatsapp Business Cloud API wrapper for Laravel.

v1.0.1(1y ago)014MITPHPPHP ^8.2

Since Aug 9Pushed 1y agoCompare

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

READMEChangelogDependencies (6)Versions (3)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 logicalcrow/laravel-whatsapp-api
```

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="Logicalcrow\Whatsapp\WhatsappServiceProvider" --tag=config
```

Usage
-----

[](#usage)

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

```
use Logicalcrow\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 Logicalcrow\Whatsapp\Messages\TextMessage;

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

and you can mark messages as read:

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

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): \Logicalcrow\Whatsapp\WhatsappMedia|string
Whatsapp::getMedia(string $mediaId, bool $download = false): \Logicalcrow\Whatsapp\WhatsappMedia
Whatsapp::deleteMedia(\Logicalcrow\Whatsapp\WhatsappMedia|string $id): bool
Whatsapp::downloadMedia(string|\Logicalcrow\Whatsapp\WhatsappMedia $media): \Logicalcrow\Whatsapp\WhatsappMedia
```

### Business Profile

[](#business-profile)

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

```
Whatsapp::getProfile(): \Logicalcrow\Whatsapp\BusinessProfile
Whatsapp::updateProfile(\Logicalcrow\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 `Logicalcrow\Whatsapp\Events\SubscriptionIntentReceived` event will be fired, if the request is successful the `Logicalcrow\Whatsapp\Events\SuccessfullySubscribed` event will fire too.

On the other hand notifications will trigger a `Logicalcrow\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 `Logicalcrow\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:

- `Logicalcrow\Whatsapp\Events\WebhookEntry` generic entry
- `Logicalcrow\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 Logicalcrow\Whatsapp\Messages\TemplateMessage;
use Logicalcrow\Whatsapp\Messages\Components\Parameters;
use Logicalcrow\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 \Logicalcrow\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).

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity53

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

2

Last Release

641d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0de9bb72f8dc6c4926fcd257d3faf30705459edee91f84e1c32692729c8cbb84?d=identicon)[logicalcrow](/maintainers/logicalcrow)

---

Top Contributors

[![giovicespedes](https://avatars.githubusercontent.com/u/7133460?v=4)](https://github.com/giovicespedes "giovicespedes (2 commits)")

---

Tags

apilaravelsdkfacebookwhatsapp

### Embed Badge

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

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

###  Alternatives

[laravel/cashier

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.

2.5k25.9M107](/packages/laravel-cashier)[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)
