mosamy / whatsapp
Laravel package to integrate WhatsApp Business API.
Requires
- php: >=8.2
This package is auto-updated.
Last update: 2026-02-03 00:37:41 UTC
README
This package provides tools and utilities for interacting with WhatsApp services. Below is a detailed guide to help you get started.
Installation
To install the package, use the following command:
composer require mosamy/whatsapp
Features
- Message Sending: Send text, images, and other media to WhatsApp users.
Usage
Usage in Laravel
To use the WhatsApp package in a Laravel application, follow these steps:
- Install the Package
Ensure the package is installed via Composer:composer require mosamy/whatsapp Configure the Package
After installation, add the following CloudWA configuration to your
.envfile:CLOUDWA_USERNAME=your_cloudwa_username CLOUDWA_PASSWORD=your_cloudwa_password CLOUDWA_SESSION_UUID=your_session_uuid CLOUDWA_REPORT_EMAIL=your_report_emailReplace
your_cloudwa_username,your_cloudwa_passwordandyour_session_uuidwith the appropriate values for your CloudWA account.If any error occurs, a report will be sent to the email configured in
CLOUDWA_REPORT_EMAIL.Sending a Message
Use theWhatsApphelper to easily send a message:whatsapp()->send([ 'to' => '+1234567890', 'message' => 'Hello from Laravel!', ]);## Advanced Usage
For more advanced features, you can create a page to display the session status. The following example is compatible with Livewire, but you can customize it to suit your needs.
### Step 1: Create a Livewire Component
First, create a Livewire component to handle the session status:
use Livewire\Component; use ServicesCloudWA; class WhatsappSessionStatus extends Component { #[Computed] public function sessionStatus() { return ServicesCloudWA::sessionStatus(); } }### Step 2: Create a Blade View
Next, create a Blade file named
whatsapp-session-status.blade.phpto display the session status:<div class="card-body text-center"> <div wire:poll.10s="$refresh"> <div class="text-danger">{{ $this->sessionStatus['message'] ?? $this->sessionStatus['errors'][0] ?? '' }}</div> @if((($this->sessionStatus['status'] ?? '') != 'CONNECTED')) <div class="mt-2"> <img class="qrcode" src="{{ $this->sessionStatus['qrcode'] ?? asset('style/images/qr-code-placeholder.png') }}" style="border: 1px solid white; height: 192px; width: 192px;" alt="QRCode Loading"> </div> @endif </div> <x-webadmin.buttons.button label="Refresh" type="button" wire:click="$refresh" class="btn mt-4 btn-secondary"> Refresh </x-webadmin.buttons.button> </div>### Step 3: Define the Route
Finally, define a route to serve the Livewire component:
use App\Http\Livewire\WhatsappSessionStatus; Route::get('whatsapp-session-status', WhatsappSessionStatus::class)->name('whatsapp-session-status');This setup will allow you to monitor the session status in real-time and refresh the QR code or status as needed.
For additional details, consult the official documentation or open an issue for support.
Contributing
Contributions are welcome! Please submit a pull request or open an issue for any bugs or feature requests.
Support
For support, please contact dev.mohamed.samy@gmail.com.