Getting Started
Laravel WAHA is an elegant Saloon PHP package for interacting with the WAHA API.
Requirements
| Version | PHP | Composer | Laravel |
|---|---|---|---|
| 1.x | >= 8.4 | Required | >= 12.x |
IMPORTANT
This package supports Laravel package auto-discovery - no need to register the service provider.
Installation
You can install the package via Composer:
bash
composer require njoguamos/laravel-wahaEnvironment Variables
The package uses the following environment variables. You can add them to your .env file:
dotenv
WAHA_API_KEY=your-api-key
WAHA_BASE_URL=https://waha.example.com| Variable | Description | Default |
|---|---|---|
WAHA_API_KEY | Your WAHA API key | - |
WAHA_BASE_URL | Base API URL | https://waha.example.com |
WAHA_SESSION | Default WhatsApp session name | default |
WAHA_ENGINE | Engine type: WEBJS,WPP, GOWS, or NOWEB | WEBJS |
WAHA_SEND_TYPING_STATUS | Send typing status before message to reduce ban risk | true |
Configuration
You can publish the waha.php configuration by running the following command:
bash
php artisan vendor:publish --tag=config --provider="NjoguAmos\Waha\WahaServiceProvider"Content of the waha.php
php
return [
'base_url' => env('WAHA_BASE_URL'),
'api_key' => env('WAHA_API_KEY'),
'session' => env('WAHA_SESSION', 'default'),
'engine' => env('WAHA_ENGINE', 'WEBJS'),
];Engines
WAHA supports different engines with varying features:
| Engine | Description |
|---|---|
| WEBJS | Connects via WhatsApp Web using Puppeteer to avoid detection |
| GOWS | Connects directly via WebSocket without requiring a browser |
| NOWEB | Connects directly via WebSocket, saving CPU and memory |
See WAHA Engines for more details.
Usage
Here is a quick example of how to send a text status message using the Status facade.
php
use NjoguAmos\Waha\Facades\Status;
use NjoguAmos\Waha\Dto\TextStatusData;
$statusData = new TextStatusData(
text: 'Hello from WhatsApp.',
backgroundColor: '#38b42f',
font: 1
);
$result = Status::sendText(session: 'default', data: $statusData);