vntrungld/laravel-zalo-bot 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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_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.

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-07-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固