定制 sontus/laravel-support-chatbot 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

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

  1. Install via Composer:
composer require sontus/laravel-support-chatbot
  1. Run the installation command:
php artisan chatbot:install
  1. Run Migrations:
php artisan migrate
  1. Configure Environment: Add the following to your .env file:
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
  1. 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 (Requires message, and session_id or user_id)
  • GET /api/chatbot/history (Requires session_id or user_id)

License

MIT

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固