laravel-zalo-bot maintained by vntrungld
Description
Laravel integration for the Zalo Bot Platform API — facade, webhook handling, notification channel, and Artisan commands.
Author
Last update
2026/07/07 12:45
(dev-master)
License
Downloads
3
Laravel Zalo Bot
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_TOKENis unset while the webhook is enabled, signature verification is skipped and the endpoint accepts unauthenticated requests. Always setZALO_BOT_SECRET_TOKENin 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.