Search by

waapi / waapi-laravel-sdk

WaAPIapp

WaAPI Laravel Package

Package info

github.com/WaAPIapp/waapi-laravel-sdk

pkg:composer/waapi/waapi-laravel-sdk

Statistics

Installs: 6 229

Dependents: 0

Suggesters: 0

Stars: 11

Open Issues: 1

v2.1.0 2026-10-30 18:47 UTC

This package is auto-updated.

Last update: 2026-10-30 18:49:25 UTC


README

Latest Version on Packagist Total Downloads

Laravel Package to use with waapi.app.

Installation

You can install the package via composer:

composer require waapi/waapi-laravel-sdk

You can publish the config file with:

php artisan vendor:publish --tag="waapi-config"

This is the contents of the published config file:

return [
    'api_token' => env('WAAPI_API_TOKEN'),
    'instance_id' => env('WAAPI_INSTANCE_ID'),
];

Please adapt your .env with your instance ID and Token which can be obtained from your API Tokens

Replace with your token and your instance ID

WAAPI_API_TOKEN=abcdefghijkl123456789
WAAPI_INSTANCE_ID=123

Usage

$waAPI = new WaAPI\WaAPI();
$waAPI->sendMessage('1222333444@c.us', 'Hello there!');

Webhook Listener

The package provides a webhooks endpoint to handle incoming webhooks. Simply update your instance with the event types you want to listen to and the endpoint.

Make sure your app is running on a publicly availabel domain. Locally the webhooks won't work.

app(WaAPI::class)->updateInstance(
    route('waapi.webhooks'),
    [
        EventType::MESSAGE->value,
        EventType::QR->value
    ]
);

Create an event listener to listen on the webhook events

new Message example:

php artisan make:listener WaAPIMessageListener --event=\\WaAPI\\WaAPI\\Events\\MessageEvent

QR Code change example:

php artisan make:listener WaAPIQrCodeListener --event=\\WaAPI\\WaAPI\\Events\\QrEvent

Register your listener in app/Providers/EventServiceProvider.php if autodiscovery for events is disabled

    use App\Listeners\WaAPIInstanceReadyListener;
    use App\Listeners\WaAPIMessageListener;
    use WaAPI\WaAPI\Events\MessageEvent;
    use WaAPI\WaAPI\Events\QrEvent;
        
    [...]
        
    protected $listen = [
        MessageEvent::class => [
            WaAPIMessageListener::class,
        ],
        QrEvent::class => [
            WaAPIQrCodeListener::class,
        ],
    ];

Example for WaAPIMessageListener:

<?php

namespace App\Listeners;

use WaAPI\WaAPI\Events\MessageEvent;
use WaAPI\WaAPI\WaAPI;

class WaAPIMessageListener
{
    /**
     * Handle the event.
     */
    public function handle(MessageEvent $message): void
    {
        if (!$message->isFromMe()) {
            app(WaAPI::class)->sendMessage($message->getFrom(), 'Hello to you too!');
        }
    }
}

Available events:

AuthenticatedEvent
AuthFailureEvent
DisconnectedEvent
GroupJoinEvent
GroupLeaveEvent
GroupUpdateEvent
InstanceReadyEvent
LoadingScreenEvent
MediaDownloadRetryEvent
MediaDownloadedEvent
MediaUploadedEvent
MessageAcknowledgedEvent
MessageCreatedEvent
MessageEvent
MessageReactionEvent
MessageRevokedEveryoneEvent
MessageRevokedMeEvent
QrEvent
StateChangeEvent

MediaDownloadRetryEvent (media_download_retry) fires once for an incoming media message whose download had failed: data.media carries the file after a successful retry, or {status: 'error', error, detail, final: true}, and data.retry.outcome says which (delivered or failed). It is opt-in: select it on the instance or in a webhook subscription.

MediaDownloadedEvent (media_downloaded) fires once for an incoming media message as soon as its file is available — on the first download or after a retry — and carries data.message only; fetch the file with downloadMedia(). A repeat for the same message id is rare but possible and safe to ignore. It works with every media mode and needs a message event (message, message_create or message_edit) subscribed too.

Testing

composer test

Changelog

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

License

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