vntrungld/laravel-zalo-bot
Composer 安装命令:
composer require vntrungld/laravel-zalo-bot
包简介
Laravel integration for the Zalo Bot Platform API — facade, webhook handling, notification channel, and Artisan commands.
README 文档
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_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.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-07-07