Skip to content

Getting Started

Laravel WAHA is an elegant Saloon PHP package for interacting with the WAHA API.

Requirements

VersionPHPComposerLaravel
1.x>= 8.4Required>= 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-waha

Environment 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
VariableDescriptionDefault
WAHA_API_KEYYour WAHA API key-
WAHA_BASE_URLBase API URLhttps://waha.example.com
WAHA_SESSIONDefault WhatsApp session namedefault
WAHA_ENGINEEngine type: WEBJS,WPP, GOWS, or NOWEBWEBJS
WAHA_SEND_TYPING_STATUSSend typing status before message to reduce ban risktrue

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:

EngineDescription
WEBJSConnects via WhatsApp Web using Puppeteer to avoid detection
GOWSConnects directly via WebSocket without requiring a browser
NOWEBConnects 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);

References

Released under the MIT License.