ges/laravel-green-api

Core Green API integration for Laravel.

Maintainers

Package info

github.com/TechGES/Laravel-green-api

pkg:composer/ges/laravel-green-api

Statistics

Installs: 126

Dependents: 1

Suggesters: 0

Stars: 1

Open Issues: 0

0.1.7 2026-03-17 11:10 UTC

This package is auto-updated.

Last update: 2026-03-17 11:10:34 UTC


README

Laravel package for Green API inbound webhooks, outbound messaging, and a persisted WhatsApp-like inbox model.

Install

composer require ges/laravel-green-api
php artisan green-api:install
php artisan migrate

Configuration

Publish the config file and set the Green API credentials:

GREEN_API_URL=
GREEN_API_MEDIA_URL=
GREEN_API_INSTANCE_ID=
GREEN_API_TOKEN=
GREEN_API_TEST_CHAT_ID=
GREEN_API_WEBHOOK_URL=
GREEN_API_WEBHOOK_AUTHORIZATION_HEADER=

The package uses App\Models\User as the default contact model and adds a dynamic greenApiConversation relation automatically at boot.

Commands

php artisan green-api:check-connection
php artisan green-api:sync-webhook

Usage

use Ges\LaravelGreenApi\Services\GreenApiInboxService;

$inbox = app(GreenApiInboxService::class);
$message = $inbox->sendTextMessage($user, 'Hello');
$conversation = $user->greenApiConversation;

Inbound webhooks are exposed at POST /green-api/webhook.

Notifications

The package also exposes a Laravel notification channel via GreenApiChannel.

use Ges\LaravelGreenApi\Notifications\GreenApiChannel;
use Ges\LaravelGreenApi\Notifications\GreenApiMessage;
use Illuminate\Notifications\Notification;

class InvoicePaid extends Notification
{
    public function via(object $notifiable): array
    {
        return [GreenApiChannel::class];
    }

    public function toGreenApi(object $notifiable): GreenApiMessage
    {
        return GreenApiMessage::make('Invoice paid.');
    }
}

You can also use the driver alias if you prefer:

public function via(object $notifiable): array
{
    return ['green_api'];
}

For file delivery:

public function toGreenApi(object $notifiable): GreenApiMessage
{
    return GreenApiMessage::make()
        ->file(storage_path('app/invoice.pdf'), 'Invoice attached', 'invoice.pdf');
}

When the notifiable is the configured contact model, notifications are persisted into the package inbox. For anonymous or non-model notifiables, route the destination with green_api:

use Illuminate\Support\Facades\Notification;

Notification::route('green_api', '+33 6 12 34 56 78')
    ->notify(new InvoicePaid);