vntrungld/laravel-zalo-bot

Laravel integration for the Zalo Bot Platform API — facade, webhook handling, notification channel, and Artisan commands.

Maintainers

Package info

github.com/vntrungld/laravel-zalo-bot

pkg:composer/vntrungld/laravel-zalo-bot

Transparency log

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.0 2026-07-07 10:45 UTC

This package is auto-updated.

Last update: 2026-07-07 11:11:52 UTC


README

Laravel integration for the Zalo Bot Platform API, wrapping vntrungld/zalo-bot-php-sdk.

Install

composer require vntrungld/laravel-zalo-bot
php artisan vendor:publish --tag=zalo-bot-config

Set in .env:

ZALO_BOT_TOKEN="{id}:{secret}"
ZALO_BOT_SECRET_TOKEN="a-long-webhook-secret"

Sending messages

use Vntrungld\LaravelZaloBot\Facades\ZaloBot;

ZaloBot::sendMessage($chatId, 'Xin chào!');

Or inject ZaloBot\Client directly.

Webhook

A POST /zalo-bot/webhook route is registered automatically (configurable via ZALO_BOT_WEBHOOK_PATH). It verifies the X-Bot-Api-Secret-Token header and dispatches an event:

Security: if ZALO_BOT_SECRET_TOKEN is unset while the webhook is enabled, signature verification is skipped and the endpoint accepts unauthenticated requests. Always set ZALO_BOT_SECRET_TOKEN in production.

use Vntrungld\LaravelZaloBot\Events\ZaloUpdateReceived;

Event::listen(function (ZaloUpdateReceived $e) {
    $text = $e->update->message->text;
    // ...
});

Register the URL with Zalo:

php artisan zalo-bot:webhook:set https://your-app.test/zalo-bot/webhook
php artisan zalo-bot:webhook:info
php artisan zalo-bot:webhook:delete

Notifications

use Illuminate\Notifications\Notification;
use Vntrungld\LaravelZaloBot\Notifications\ZaloMessage;

class Reminder extends Notification
{
    public function via($notifiable): array
    {
        return ['zalo'];
    }

    public function toZalo($notifiable): ZaloMessage
    {
        return ZaloMessage::text('Cuộc hẹn lúc 3 giờ chiều');
    }
}

Route the notifiable by adding routeNotificationForZalo() returning the chat id, or call ->to($chatId) on the message.

License

MIT.