sontus/laravel-support-chatbot
Composer 安装命令:
composer require sontus/laravel-support-chatbot
包简介
AI-powered support chatbot package for Laravel with direct Gemini and OpenAI integration.
README 文档
README
A production-ready, AI-powered support chatbot package for Laravel applications. This package seamlessly integrates an intelligent, context-aware chatbot into your application. It uses direct HTTP integrations without heavy dependencies.
Features
- AI Integration: Directly supports OpenAI and Gemini models without requiring PHP 8.4 dependencies.
- Knowledge Base (RAG): Admin panel to add FAQs and documentation, searchable via AI embeddings.
- Context Awareness: The chatbot automatically understands the logged-in user, their orders, and tickets.
- Frontend Widget: A sleek, customizable, floating Vanilla JS widget for real-time chat. Drop it into any site!
- Queue System: Messages are processed asynchronously to maintain high performance.
- Multi-channel API: Interact via frontend widget or via exposed REST APIs.
- Multi-Tenancy Ready: Configurable database connection for tenant-specific deployments.
Installation
- Install via Composer:
composer require sontus/laravel-support-chatbot
- Run the installation command:
php artisan chatbot:install
- Run Migrations:
php artisan migrate
- Configure Environment:
Add the following to your
.envfile:
CHATBOT_AI_API_KEY="your_api_key_here" # For Gemini (Default) CHATBOT_AI_PROVIDER=gemini CHATBOT_AI_MODEL=gemini-2.0-flash # For OpenAI # CHATBOT_AI_PROVIDER=openai # CHATBOT_AI_MODEL=gpt-4o-mini
- Start the Queue Worker: Because the chatbot processes AI requests asynchronously to ensure high performance and avoid blocking your app, you need to run a queue worker:
php artisan queue:work
Usage
1. Frontend Chat Widget
The frontend widget is pure Vanilla JavaScript and includes its own styling. It works on any Laravel site without needing a Node/Vue compilation step.
Simply add the script tag before the closing </body> tag in your layout (e.g. resources/views/layouts/app.blade.php):
<script src="{{ asset('vendor/chatbot/chatbot-widget.js') }}"></script>
Add a meta tag for CSRF and optionally User ID if authenticated (in your <head>):
<meta name="csrf-token" content="{{ csrf_token() }}"> @auth <meta name="user-id" content="{{ auth()->id() }}"> @endauth
2. Admin Panel
To train the chatbot and view conversations, visit the admin dashboard:
URL: /admin/chatbot
Ensure your admin users pass the configured middleware (web, auth).
3. Customizing Context
You can bind your own ContextResolver in your application's AppServiceProvider if you want to provide custom data (like specific tenant data) to the AI:
use Sontus\SupportChatbot\Services\ContextResolver; $this->app->bind(ContextResolver::class, function ($app) { return new class extends ContextResolver { public function resolveForUser($user = null): array { // Return any array of data you want the AI to know about this user return [ 'name' => $user->name, 'subscription_plan' => $user->plan->name, ]; } }; });
4. API Endpoints
POST /api/chatbot/message(Requiresmessage, andsession_idoruser_id)GET /api/chatbot/history(Requiressession_idoruser_id)
License
MIT
sontus/laravel-support-chatbot 适用场景与选型建议
sontus/laravel-support-chatbot 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 05 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 sontus/laravel-support-chatbot 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 sontus/laravel-support-chatbot 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 34
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-05-05