blissjaspis/laravel-whatsapp-cloud-api

Laravel package for interacting to whatsapp cloud api

v1.0.0 2025-07-10 06:57 UTC

This package is auto-updated.

Last update: 2025-07-10 06:59:23 UTC


README

Latest Version on Packagist Total Downloads

Laravel package to interact with the WhatsApp Cloud API.

Requirements

  • PHP 8.1 or higher
  • Laravel 10, 11, or 12

Installation

You can install the package via composer:

composer require blissjaspis/laravel-whatsapp-cloud-api

Configuration

First, publish the configuration file:

php artisan vendor:publish --provider="BlissJaspis\\WhatsappCloudApi\\WhatsappServiceProvider" --tag="config"

This will create a config/whatsapp-cloud-api.php file.

Next, you need to add the following environment variables to your .env file:

WHATSAPP_VERSION_SDK=v19.0
WHATSAPP_PHONE_NUMBER_ID=
WHATSAPP_ACCESS_TOKEN=
WHATSAPP_COUNTRY_CODE=+62
  • WHATSAPP_VERSION_SDK: The WhatsApp Cloud API version you want to use.
  • WHATSAPP_PHONE_NUMBER_ID: Your WhatsApp Business Phone Number ID.
  • WHATSAPP_ACCESS_TOKEN: Your System User Access Token.
  • WHATSAPP_COUNTRY_CODE: Your country code.

Usage

Sending a Text Message

You can send a text message using the Whatsapp facade.

use BlissJaspis\WhatsappCloudApi\Facades\Whatsapp;
use BlissJaspis\WhatsappCloudApi\Support\Text;

$response = Whatsapp::message()
    ->to('081234567890') // or ->to('6281234567890', false)
    ->body(Text::message('Hello from Laravel!')->build())
    ->send();

if ($response->successful()) {
    // Message sent successfully
}

The to() method automatically adds the country code from the configuration. If you want to use a phone number with the country code already included, you can pass false as the second argument.

Sending other types of messages

This package supports sending various types of messages. Here are some examples:

Image

use BlissJaspis\WhatsappCloudApi\Facades\Whatsapp;
use BlissJaspis\WhatsappCloudApi\Support\Image;

Whatsapp::message()
    ->to('081234567890')
    ->body(Image::create('https://example.com/image.jpg')->build())
    ->send();

// or with caption
Whatsapp::message()
    ->to('081234567890')
    ->body(Image::create('your-media-id')->isNotUrl()->caption('your caption')->build())
    ->send();

Document

use BlissJaspis\WhatsappCloudApi\Facades\Whatsapp;
use BlissJaspis\WhatsappCloudApi\Support\Document;

Whatsapp::message()
    ->to('081234567890')
    ->body(Document::create('https://example.com/document.pdf')->filename('your-file-name.pdf')->caption('your caption')->build())
    ->send();

Audio

use BlissJaspis\WhatsappCloudApi\Facades\Whatsapp;
use BlissJaspis\WhatsappCloudApi\Support\Audio;

Whatsapp::message()
    ->to('081234567890')
    ->body(Audio::create('your-media-id')->build())
    ->send();

Video

use BlissJaspis\WhatsappCloudApi\Facades\Whatsapp;
use BlissJaspis\WhatsappCloudApi\Support\Video;

Whatsapp::message()
    ->to('081234567890')
    ->body(Video::create('your-media-id')->build())
    ->send();

Sticker

use BlissJaspis\WhatsappCloudApi\Facades\Whatsapp;
use BlissJaspis\WhatsappCloudApi\Support\Sticker;

Whatsapp::message()
    ->to('081234567890')
    ->body(Sticker::create('your-media-id')->build())
    ->send();

Mark a message as read

You can mark a message as read using the readMessage method.

use BlissJaspis\WhatsappCloudApi\Facades\Whatsapp;

Whatsapp::readMessage('message-id');

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.