Added ChatBot Module in CCMS
This commit is contained in:
0
Modules/Chatbot/app/Http/Controllers/.gitkeep
Normal file
0
Modules/Chatbot/app/Http/Controllers/.gitkeep
Normal file
249
Modules/Chatbot/app/Http/Controllers/ChatbotController.php
Normal file
249
Modules/Chatbot/app/Http/Controllers/ChatbotController.php
Normal file
@@ -0,0 +1,249 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Chatbot\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Http\Client\ConnectionException;
|
||||
use Illuminate\Http\Client\RequestException;
|
||||
|
||||
class ChatbotController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return view('chatbot::index');
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
return view('chatbot::create');
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
return view('chatbot::show');
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
return view('chatbot::edit');
|
||||
}
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function queryold(Request $request)
|
||||
{
|
||||
$message = $request->input('message');
|
||||
return response()->json(['reply' => 'You said: ' . $message]);
|
||||
}
|
||||
|
||||
// public function query(Request $request)
|
||||
// {
|
||||
// $request->validate([
|
||||
// 'message' => 'required|string'
|
||||
// ]);
|
||||
|
||||
// // 1) Pull the current contact details from settings
|
||||
// $phone = setting('phone'); // e.g. "5344710"
|
||||
// $email = setting('email'); // e.g. "info@rohini.edu.np"
|
||||
// $address = setting('address'); // e.g. "House #160, Adwait Marg, Putalisadak, Kathmandu, Nepal"
|
||||
// $facebook = setting('facebook'); // if you have this
|
||||
// $whatsapp = setting('whatsapp'); // if you have this
|
||||
|
||||
// $userMessage = trim($request->message);
|
||||
|
||||
// // 2) Build a system prompt that *includes* your real contact info
|
||||
// $systemContents = <<<EOT
|
||||
// You are an assistant for Rohini International Education Services in Nepal.
|
||||
// Use *only* the following facts when answering:
|
||||
|
||||
// • Website: https://rohini.edu.np/
|
||||
// • Phone: {$phone}
|
||||
// • Email: {$email}
|
||||
// • Address: {$address}
|
||||
// EOT;
|
||||
|
||||
// // 3) Prepare the message payload
|
||||
// $messages = [
|
||||
// ['role' => 'system', 'content' => $systemContents],
|
||||
// ['role' => 'user', 'content' => $userMessage],
|
||||
// ];
|
||||
|
||||
// // 4) Call the AI as before
|
||||
// try {
|
||||
// $response = Http::timeout(60)
|
||||
// ->retry(2, 100)
|
||||
// ->withToken(config('services.openrouter.key'))
|
||||
// ->post('https://openrouter.ai/api/v1/chat/completions', [
|
||||
// 'model' => 'deepseek/deepseek-r1:free',
|
||||
// 'messages' => $messages,
|
||||
// ]);
|
||||
|
||||
// $response->throw();
|
||||
|
||||
// // 5) Return exactly what the AI gave, knowing the system prompt constrained it
|
||||
// return response()->json([
|
||||
// 'reply' => $response->json('choices.0.message.content') ?? 'No response from assistant.'
|
||||
// ]);
|
||||
// } catch (ConnectionException $e) {
|
||||
// return response()->json([
|
||||
// 'reply' => 'Sorry, I could not connect to the AI service. Please try again later.'
|
||||
// ], 504);
|
||||
// } catch (RequestException $e) {
|
||||
// $msg = $e->response->json('error.message') ?? $e->getMessage();
|
||||
// return response()->json([
|
||||
// 'reply' => 'Sorry, an error occurred. Please try again later.',
|
||||
// 'error' => $msg
|
||||
// ], 500);
|
||||
// }
|
||||
// }
|
||||
|
||||
public function query(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'message' => 'required|string'
|
||||
]);
|
||||
|
||||
// 1) Pull the current contact details from your settings/config
|
||||
$phone = setting('phone'); // e.g. "+977 1-5344710"
|
||||
$email = setting('email'); // e.g. "info@rohini.edu.np"
|
||||
$address = setting('address'); // e.g. "House #160, Adait Marg, Kathmandu, Nepal"
|
||||
$whatsapp = setting('whatsapp');
|
||||
$instagram = setting('instagram');
|
||||
$location = setting('location');
|
||||
$youtube = setting('youtube');
|
||||
$tiktok = setting('tiktok');
|
||||
$userMessage = strtolower(trim($request->message));
|
||||
|
||||
$contactInfo = "\n\nPlease contact us for more information. Visit <a href=\"https://rohini.edu.np/\" target=\"_blank\">https://rohini.edu.np/</a> or call us on " . $phone . ".";
|
||||
|
||||
$allowedPrompts = [
|
||||
'hi' => 'Hello! How can I assist you with your study abroad plans today?',
|
||||
|
||||
'what is rohini international education services?' =>
|
||||
'Rohini International Education Services is a Nepal-based consultancy specializing in guiding students who want to study in New Zealand. Visit https://rohini.edu.np/ for more details.',
|
||||
|
||||
'where is rohini international located?' =>
|
||||
'Our Kathmandu office is at ' . $address . '.',
|
||||
|
||||
'how can i contact support?' =>
|
||||
'You can call us at ' . $phone . ', email us at ' . $email .
|
||||
', or message us on WhatsApp at ' . $whatsapp . '. We are available Sunday to Friday, 09:00 AM to 05:00 PM.',
|
||||
|
||||
'what services do you provide?' =>
|
||||
'We provide counseling, university and course selection, visa application support, documentation help, pre-departure briefings, financial and scholarship guidance, and accommodation support for students going to New Zealand.',
|
||||
|
||||
'do you offer test preparation?' =>
|
||||
'Yes, we offer IELTS and PTE test preparation classes with experienced instructors and flexible schedules.',
|
||||
|
||||
'why choose new zealand for higher education?' =>
|
||||
'New Zealand offers globally recognized qualifications, high-quality education, a safe environment, and post-study work opportunities.',
|
||||
|
||||
'what is the process to apply to study in new zealand?' =>
|
||||
'We guide students through selecting a course, checking eligibility, gathering documents, applying for a visa, and preparing for departure.',
|
||||
|
||||
'are there work opportunities in new zealand for students?' =>
|
||||
'Yes, students can work part-time during study, full-time during holidays, and apply for post-study work visas after graduation.',
|
||||
|
||||
'what accommodation options are available in new zealand?' =>
|
||||
'Students can choose from shared flats, homestays, hostels, or on-campus housing. We help you find the right option.',
|
||||
|
||||
'do you support nepalese students in new zealand?' =>
|
||||
'Absolutely! We provide full pre-departure briefings and continuous support to ensure students feel at home in New Zealand.',
|
||||
|
||||
'rohini' =>
|
||||
'Rohini International Education Services is a Nepal-based consultancy located in Kathmandu, specializing in guiding students who want to study in New Zealand. Visit https://rohini.edu.np/ for full information.',
|
||||
|
||||
'location' =>
|
||||
'Our main office is at ' . $address . '. We also have branches in Birtamode, Birgunj, Damak, Chitwan, and Pokhara.',
|
||||
|
||||
'contact' =>
|
||||
'You can call us at ' . $phone . ', email us at ' . $email .
|
||||
', or message us on WhatsApp at ' . $whatsapp . '. We’re available Sunday to Friday, 09:00 AM to 05:00 PM.',
|
||||
|
||||
'services' =>
|
||||
'We provide counseling, university and course selection, visa application support, documentation help, pre-departure briefings, financial and scholarship guidance, and accommodation support for students going to New Zealand.',
|
||||
|
||||
'social media' =>
|
||||
'Follow us on Instagram: ' . $instagram . ', YouTube: ' . $youtube . ', TikTok: ' . $tiktok . '.',
|
||||
];
|
||||
if (array_key_exists($userMessage, $allowedPrompts)) {
|
||||
return response()->json([
|
||||
'reply' => $allowedPrompts[$userMessage] . $contactInfo
|
||||
]);
|
||||
}
|
||||
|
||||
if (str_contains($userMessage, 'location') || str_contains($userMessage, 'located')) {
|
||||
return response()->json([
|
||||
'reply' => $allowedPrompts['where is rohini international located?'] . $contactInfo
|
||||
]);
|
||||
}
|
||||
|
||||
if (str_contains($userMessage, 'contact') || str_contains($userMessage, 'support')) {
|
||||
return response()->json([
|
||||
'reply' => $allowedPrompts['how can i contact support?'] . $contactInfo
|
||||
]);
|
||||
}
|
||||
|
||||
if (str_contains($userMessage, 'service') || str_contains($userMessage, 'services')) {
|
||||
return response()->json([
|
||||
'reply' => $allowedPrompts['what services do you provide?'] . $contactInfo
|
||||
]);
|
||||
}
|
||||
|
||||
foreach ($allowedPrompts as $prompt => $answer) {
|
||||
similar_text($userMessage, $prompt, $percent);
|
||||
if ($percent > 80) {
|
||||
return response()->json([
|
||||
'reply' => "Did you mean: \"$prompt\"?\n" . $answer . $contactInfo
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
$response = Http::timeout(60)
|
||||
->retry(2, 100)
|
||||
->withToken(config('services.openrouter.key'))
|
||||
->post('https://openrouter.ai/api/v1/chat/completions', [
|
||||
'model' => 'deepseek/deepseek-r1:free',
|
||||
'messages' => [
|
||||
[
|
||||
'role' => 'system',
|
||||
'content' => 'You are an assistant for Rohini International Education Services in Nepal. Answer ONLY using information found on https://rohini.edu.np/. If the question is not related to this organization or its services for studying in New Zealand, reply with: "Sorry, I can only answer questions related to Rohini International Education Services and studying in New Zealand."'
|
||||
],
|
||||
['role' => 'user', 'content' => $request->message],
|
||||
],
|
||||
]);
|
||||
|
||||
$response->throw();
|
||||
|
||||
return response()->json([
|
||||
'reply' => ($response->json('choices.0.message.content') ?? 'No response from assistant.') . $contactInfo
|
||||
]);
|
||||
} catch (ConnectionException $e) {
|
||||
return response()->json([
|
||||
'reply' => 'Sorry, I could not connect to the AI service. Please try again later.' . $contactInfo
|
||||
], 504);
|
||||
} catch (RequestException $e) {
|
||||
$msg = $e->response->json('error.message') ?? $e->getMessage();
|
||||
return response()->json([
|
||||
'reply' => 'Sorry, an error occurred. Please try again later.' . $contactInfo,
|
||||
'error' => $msg
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
}
|
0
Modules/Chatbot/app/Models/Scopes/.gitkeep
Normal file
0
Modules/Chatbot/app/Models/Scopes/.gitkeep
Normal file
0
Modules/Chatbot/app/Providers/.gitkeep
Normal file
0
Modules/Chatbot/app/Providers/.gitkeep
Normal file
135
Modules/Chatbot/app/Providers/ChatbotServiceProvider.php
Normal file
135
Modules/Chatbot/app/Providers/ChatbotServiceProvider.php
Normal file
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Chatbot\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Nwidart\Modules\Traits\PathNamespace;
|
||||
use RecursiveDirectoryIterator;
|
||||
use RecursiveIteratorIterator;
|
||||
|
||||
class ChatbotServiceProvider extends ServiceProvider
|
||||
{
|
||||
use PathNamespace;
|
||||
|
||||
protected string $name = 'Chatbot';
|
||||
|
||||
protected string $nameLower = 'chatbot';
|
||||
|
||||
/**
|
||||
* Boot the application events.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
$this->registerCommands();
|
||||
$this->registerCommandSchedules();
|
||||
$this->registerTranslations();
|
||||
$this->registerConfig();
|
||||
$this->registerViews();
|
||||
$this->loadMigrationsFrom(module_path($this->name, 'database/migrations'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
$this->app->register(EventServiceProvider::class);
|
||||
$this->app->register(RouteServiceProvider::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register commands in the format of Command::class
|
||||
*/
|
||||
protected function registerCommands(): void
|
||||
{
|
||||
// $this->commands([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register command Schedules.
|
||||
*/
|
||||
protected function registerCommandSchedules(): void
|
||||
{
|
||||
// $this->app->booted(function () {
|
||||
// $schedule = $this->app->make(Schedule::class);
|
||||
// $schedule->command('inspire')->hourly();
|
||||
// });
|
||||
}
|
||||
|
||||
/**
|
||||
* Register translations.
|
||||
*/
|
||||
public function registerTranslations(): void
|
||||
{
|
||||
$langPath = resource_path('lang/modules/'.$this->nameLower);
|
||||
|
||||
if (is_dir($langPath)) {
|
||||
$this->loadTranslationsFrom($langPath, $this->nameLower);
|
||||
$this->loadJsonTranslationsFrom($langPath);
|
||||
} else {
|
||||
$this->loadTranslationsFrom(module_path($this->name, 'lang'), $this->nameLower);
|
||||
$this->loadJsonTranslationsFrom(module_path($this->name, 'lang'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register config.
|
||||
*/
|
||||
protected function registerConfig(): void
|
||||
{
|
||||
$relativeConfigPath = config('modules.paths.generator.config.path');
|
||||
$configPath = module_path($this->name, $relativeConfigPath);
|
||||
|
||||
if (is_dir($configPath)) {
|
||||
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($configPath));
|
||||
|
||||
foreach ($iterator as $file) {
|
||||
if ($file->isFile() && $file->getExtension() === 'php') {
|
||||
$relativePath = str_replace($configPath . DIRECTORY_SEPARATOR, '', $file->getPathname());
|
||||
$configKey = $this->nameLower . '.' . str_replace([DIRECTORY_SEPARATOR, '.php'], ['.', ''], $relativePath);
|
||||
$key = ($relativePath === 'config.php') ? $this->nameLower : $configKey;
|
||||
|
||||
$this->publishes([$file->getPathname() => config_path($relativePath)], 'config');
|
||||
$this->mergeConfigFrom($file->getPathname(), $key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register views.
|
||||
*/
|
||||
public function registerViews(): void
|
||||
{
|
||||
$viewPath = resource_path('views/modules/'.$this->nameLower);
|
||||
$sourcePath = module_path($this->name, 'resources/views');
|
||||
|
||||
$this->publishes([$sourcePath => $viewPath], ['views', $this->nameLower.'-module-views']);
|
||||
|
||||
$this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->nameLower);
|
||||
|
||||
$componentNamespace = $this->module_namespace($this->name, $this->app_path(config('modules.paths.generator.component-class.path')));
|
||||
Blade::componentNamespace($componentNamespace, $this->nameLower);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the services provided by the provider.
|
||||
*/
|
||||
public function provides(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
private function getPublishableViewPaths(): array
|
||||
{
|
||||
$paths = [];
|
||||
foreach (config('view.paths') as $path) {
|
||||
if (is_dir($path.'/modules/'.$this->nameLower)) {
|
||||
$paths[] = $path.'/modules/'.$this->nameLower;
|
||||
}
|
||||
}
|
||||
|
||||
return $paths;
|
||||
}
|
||||
}
|
30
Modules/Chatbot/app/Providers/EventServiceProvider.php
Normal file
30
Modules/Chatbot/app/Providers/EventServiceProvider.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Chatbot\Providers;
|
||||
|
||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||
|
||||
class EventServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The event handler mappings for the application.
|
||||
*
|
||||
* @var array<string, array<int, string>>
|
||||
*/
|
||||
protected $listen = [];
|
||||
|
||||
/**
|
||||
* Indicates if events should be discovered.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected static $shouldDiscoverEvents = true;
|
||||
|
||||
/**
|
||||
* Configure the proper event listeners for email verification.
|
||||
*/
|
||||
protected function configureEmailVerification(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
50
Modules/Chatbot/app/Providers/RouteServiceProvider.php
Normal file
50
Modules/Chatbot/app/Providers/RouteServiceProvider.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Chatbot\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
protected string $name = 'Chatbot';
|
||||
|
||||
/**
|
||||
* Called before routes are registered.
|
||||
*
|
||||
* Register any model bindings or pattern based filters.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
parent::boot();
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the routes for the application.
|
||||
*/
|
||||
public function map(): void
|
||||
{
|
||||
$this->mapApiRoutes();
|
||||
$this->mapWebRoutes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "web" routes for the application.
|
||||
*
|
||||
* These routes all receive session state, CSRF protection, etc.
|
||||
*/
|
||||
protected function mapWebRoutes(): void
|
||||
{
|
||||
Route::middleware('web')->group(module_path($this->name, '/routes/web.php'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "api" routes for the application.
|
||||
*
|
||||
* These routes are typically stateless.
|
||||
*/
|
||||
protected function mapApiRoutes(): void
|
||||
{
|
||||
Route::middleware('api')->prefix('api')->name('api.')->group(module_path($this->name, '/routes/api.php'));
|
||||
}
|
||||
}
|
0
Modules/Chatbot/app/Services/.gitkeep
Normal file
0
Modules/Chatbot/app/Services/.gitkeep
Normal file
30
Modules/Chatbot/composer.json
Normal file
30
Modules/Chatbot/composer.json
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"name": "nwidart/chatbot",
|
||||
"description": "",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nicolas Widart",
|
||||
"email": "n.widart@gmail.com"
|
||||
}
|
||||
],
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [],
|
||||
"aliases": {
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Modules\\Chatbot\\": "app/",
|
||||
"Modules\\Chatbot\\Database\\Factories\\": "database/factories/",
|
||||
"Modules\\Chatbot\\Database\\Seeders\\": "database/seeders/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Modules\\Chatbot\\Tests\\": "tests/"
|
||||
}
|
||||
}
|
||||
}
|
0
Modules/Chatbot/config/.gitkeep
Normal file
0
Modules/Chatbot/config/.gitkeep
Normal file
5
Modules/Chatbot/config/config.php
Normal file
5
Modules/Chatbot/config/config.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'name' => 'Chatbot',
|
||||
];
|
0
Modules/Chatbot/database/factories/.gitkeep
Normal file
0
Modules/Chatbot/database/factories/.gitkeep
Normal file
0
Modules/Chatbot/database/migrations/.gitkeep
Normal file
0
Modules/Chatbot/database/migrations/.gitkeep
Normal file
0
Modules/Chatbot/database/seeders/.gitkeep
Normal file
0
Modules/Chatbot/database/seeders/.gitkeep
Normal file
16
Modules/Chatbot/database/seeders/ChatbotDatabaseSeeder.php
Normal file
16
Modules/Chatbot/database/seeders/ChatbotDatabaseSeeder.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Chatbot\Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class ChatbotDatabaseSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// $this->call([]);
|
||||
}
|
||||
}
|
11
Modules/Chatbot/module.json
Normal file
11
Modules/Chatbot/module.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "Chatbot",
|
||||
"alias": "chatbot",
|
||||
"description": "",
|
||||
"keywords": [],
|
||||
"priority": 0,
|
||||
"providers": [
|
||||
"Modules\\Chatbot\\Providers\\ChatbotServiceProvider"
|
||||
],
|
||||
"files": []
|
||||
}
|
15
Modules/Chatbot/package.json
Normal file
15
Modules/Chatbot/package.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build"
|
||||
},
|
||||
"devDependencies": {
|
||||
"axios": "^1.1.2",
|
||||
"laravel-vite-plugin": "^0.7.5",
|
||||
"sass": "^1.69.5",
|
||||
"postcss": "^8.3.7",
|
||||
"vite": "^4.0.0"
|
||||
}
|
||||
}
|
18
Modules/Chatbot/readme.md
Normal file
18
Modules/Chatbot/readme.md
Normal file
@@ -0,0 +1,18 @@
|
||||
inside config/services.php
|
||||
|
||||
add
|
||||
'openrouter' => [
|
||||
'api_key' => env('OPENROUTER_API_KEY'),
|
||||
'base_url' => 'https://openrouter.ai/api/v1/chat/completions',
|
||||
],
|
||||
|
||||
----------------OR--------------------------
|
||||
|
||||
'openrouter' => [
|
||||
'key' => env('OPENROUTER_API_KEY'),
|
||||
],
|
||||
-------------------------------
|
||||
|
||||
add to your .env
|
||||
|
||||
OPENROUTER_API_KEY=your_api_key
|
120
Modules/Chatbot/resources/assets/css/chatbot.css
Normal file
120
Modules/Chatbot/resources/assets/css/chatbot.css
Normal file
@@ -0,0 +1,120 @@
|
||||
/* Message Styling */
|
||||
.message {
|
||||
padding: 8px;
|
||||
margin: 5px 0;
|
||||
border-radius: 10px;
|
||||
max-width: 100%;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
/* User Message (Blue with transparency) */
|
||||
.user-message {
|
||||
background-color: rgba(0, 123, 255, 0.2); /* Blue with 70% opacity */
|
||||
color: black;
|
||||
text-align: right;
|
||||
align-self: flex-end;
|
||||
}
|
||||
|
||||
/* Bot Message (vz-primary with transparency) */
|
||||
.bot-message {
|
||||
background-color: rgba(var(--vz-primary-rgb), 0.2); /* Assuming var(--vz-primary-rgb) holds RGB value */
|
||||
color: black;
|
||||
text-align: left;
|
||||
align-self: flex-start;
|
||||
}
|
||||
|
||||
/* Floating Chatbot Button */
|
||||
#chatbot-toggle {
|
||||
position: fixed;
|
||||
bottom: 45px;
|
||||
right: 38px;
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
background-color: var(--vz-primary); /* Using CSS variable */
|
||||
color: white;
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 24px;
|
||||
cursor: pointer;
|
||||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
|
||||
transition: all 0.3s ease-in-out;
|
||||
z-index: 1000; /* Ensure it's above other elements */
|
||||
}
|
||||
|
||||
/* Chatbot Container */
|
||||
#chatbot-container {
|
||||
position: fixed;
|
||||
bottom: 42px;
|
||||
right: 32px;
|
||||
width: 320px;
|
||||
background: white;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 10px;
|
||||
box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.2);
|
||||
font-family: Arial, sans-serif;
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
z-index: 1000; /* Ensure it floats above the content */
|
||||
}
|
||||
|
||||
/* Chatbot Header */
|
||||
#chatbot-header {
|
||||
background-color: var(--vz-primary);
|
||||
color: white;
|
||||
padding: 10px;
|
||||
text-align: center;
|
||||
font-size: 16px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
/* Close Button */
|
||||
#chatbot-close {
|
||||
font-size: 20px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* Chatbot Body */
|
||||
#chatbot-body {
|
||||
height: 250px;
|
||||
overflow-y: auto;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
/* Input and Send Button Styling */
|
||||
#chatbot-input-container {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
margin-top: 10px;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
#chatbot-input {
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 20px;
|
||||
outline: none;
|
||||
font-size: 14px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
#chatbot-send {
|
||||
position: absolute;
|
||||
right: 10px;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
background-color: transparent;
|
||||
border: none;
|
||||
color: var(--vz-primary);
|
||||
font-size: 18px;
|
||||
cursor: pointer;
|
||||
z-index: 10;
|
||||
}
|
||||
|
0
Modules/Chatbot/resources/assets/js/app.js
Normal file
0
Modules/Chatbot/resources/assets/js/app.js
Normal file
47
Modules/Chatbot/resources/assets/js/chatbot.js
Normal file
47
Modules/Chatbot/resources/assets/js/chatbot.js
Normal file
@@ -0,0 +1,47 @@
|
||||
$(document).ready(function() {
|
||||
// Toggle chatbot visibility
|
||||
$('#chatbot-toggle').click(function() {
|
||||
$('#chatbot-container').fadeIn();
|
||||
$('#chatbot-toggle').hide();
|
||||
});
|
||||
|
||||
// Close chatbot
|
||||
$('#chatbot-close').click(function() {
|
||||
$('#chatbot-container').fadeOut();
|
||||
$('#chatbot-toggle').show();
|
||||
});
|
||||
|
||||
// Send message on button click
|
||||
$('#chatbot-send').click(function() {
|
||||
sendMessage();
|
||||
});
|
||||
|
||||
// Send message on "Enter" key
|
||||
$('#chatbot-input').keypress(function(e) {
|
||||
if (e.which == 13) {
|
||||
sendMessage();
|
||||
}
|
||||
});
|
||||
|
||||
function sendMessage() {
|
||||
var message = $('#chatbot-input').val().trim();
|
||||
if (message === '') return;
|
||||
|
||||
$('#chatbot-body').append('<div class="message user-message"><strong>You:</strong> ' + message + '</div>');
|
||||
$('#chatbot-input').val('');
|
||||
$('#chatbot-body').scrollTop($('#chatbot-body')[0].scrollHeight);
|
||||
|
||||
$.ajax({
|
||||
url: '{{ route('chatbot.query') }}',
|
||||
type: 'POST',
|
||||
data: { message: message, _token: '{{ csrf_token() }}' },
|
||||
success: function(response) {
|
||||
$('#chatbot-body').append('<div class="message bot-message"><strong>Bot:</strong> ' + response.reply + '</div>');
|
||||
$('#chatbot-body').scrollTop($('#chatbot-body')[0].scrollHeight);
|
||||
},
|
||||
error: function() {
|
||||
$('#chatbot-body').append('<div class="message bot-message"><strong>Bot:</strong> Sorry, something went wrong.</div>');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
0
Modules/Chatbot/resources/assets/sass/app.scss
Normal file
0
Modules/Chatbot/resources/assets/sass/app.scss
Normal file
0
Modules/Chatbot/resources/views/.gitkeep
Normal file
0
Modules/Chatbot/resources/views/.gitkeep
Normal file
445
Modules/Chatbot/resources/views/chatbot.blade.php
Normal file
445
Modules/Chatbot/resources/views/chatbot.blade.php
Normal file
@@ -0,0 +1,445 @@
|
||||
@push('css')
|
||||
<style>
|
||||
/* Message Styling */
|
||||
.message {
|
||||
padding: 8px;
|
||||
margin: 5px 0;
|
||||
border-radius: 10px;
|
||||
max-width: 100%;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
/* User Message (Blue with transparency) */
|
||||
.user-message {
|
||||
background-color: rgba(0, 123, 255, 0.2);
|
||||
/* Blue with 70% opacity */
|
||||
color: black;
|
||||
text-align: right;
|
||||
align-self: flex-end;
|
||||
}
|
||||
|
||||
/* Bot Message (vz-primary with transparency) */
|
||||
.bot-message {
|
||||
background-color: rgba(var(--vz-primary-rgb), 0.2);
|
||||
/* Assuming var(--vz-primary-rgb) holds RGB value */
|
||||
color: black;
|
||||
text-align: left;
|
||||
align-self: flex-start;
|
||||
}
|
||||
|
||||
/* Floating Chatbot Button */
|
||||
#chatbot-toggle {
|
||||
position: fixed;
|
||||
bottom: 45px;
|
||||
right: 38px;
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
background-color: var(--vz-primary);
|
||||
/* Using CSS variable */
|
||||
color: white;
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 24px;
|
||||
cursor: pointer;
|
||||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
|
||||
transition: all 0.3s ease-in-out;
|
||||
z-index: 1000;
|
||||
/* Ensure it's above other elements */
|
||||
}
|
||||
|
||||
/* Chatbot Container */
|
||||
#chatbot-container {
|
||||
position: fixed;
|
||||
bottom: 42px;
|
||||
right: 36px;
|
||||
width: 320px;
|
||||
padding: 0px;
|
||||
background: white;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 10px;
|
||||
box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.2);
|
||||
font-family: Arial, sans-serif;
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
z-index: 1000;
|
||||
/* Ensure it floats above the content */
|
||||
}
|
||||
|
||||
/* Chatbot Header */
|
||||
#chatbot-header {
|
||||
background-color: var(--vz-primary);
|
||||
color: white;
|
||||
padding: 10px;
|
||||
text-align: center;
|
||||
font-size: 16px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
/* Close Button */
|
||||
#chatbot-close {
|
||||
font-size: 20px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* Chatbot Body */
|
||||
#chatbot-body {
|
||||
height: 250px;
|
||||
overflow-y: auto;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
/* Input and Send Button Styling */
|
||||
#chatbot-input-container {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
margin-top: 10px;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
#chatbot-input {
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 20px;
|
||||
outline: none;
|
||||
font-size: 14px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
#chatbot-send {
|
||||
position: absolute;
|
||||
right: 10px;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
background-color: transparent;
|
||||
border: none;
|
||||
color: var(--vz-primary);
|
||||
font-size: 18px;
|
||||
cursor: pointer;
|
||||
z-index: 10;
|
||||
}
|
||||
</style>
|
||||
@endpush
|
||||
|
||||
|
||||
<style>
|
||||
/* floating buttons container */
|
||||
.floating-social {
|
||||
position: fixed;
|
||||
bottom: 210px;
|
||||
right: 45px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
z-index: 9999;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* each circular button */
|
||||
.floating-social .btn-circle {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 24px;
|
||||
color: #fff;
|
||||
/* white icon */
|
||||
text-decoration: none;
|
||||
box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
/* brand backgrounds */
|
||||
.btn-whatsapp {
|
||||
background: #25D366;
|
||||
}
|
||||
|
||||
.btn-facebook {
|
||||
background: #1877F2;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style>
|
||||
.glowing-animation {
|
||||
background-color: #F98D1E;
|
||||
box-shadow: 0 0 10px rgba(249, 141, 30, 0.5),
|
||||
0 0 20px rgba(249, 141, 30, 0.4),
|
||||
0 0 30px rgba(249, 141, 30, 0.3);
|
||||
animation: pulseGlow 2s ease-in-out infinite;
|
||||
border-radius: 50%;
|
||||
transition: transform 0.3s ease;
|
||||
}
|
||||
|
||||
/* .glowing-animation:hover {
|
||||
transform: scale(1.1);
|
||||
} */
|
||||
|
||||
@keyframes pulseGlow {
|
||||
|
||||
0%,
|
||||
100% {
|
||||
box-shadow: 0 0 10px rgba(249, 141, 30, 0.4),
|
||||
0 0 20px rgba(249, 141, 30, 0.3),
|
||||
0 0 30px rgba(249, 141, 30, 0.2);
|
||||
}
|
||||
|
||||
50% {
|
||||
box-shadow: 0 0 20px rgba(249, 141, 30, 0.6),
|
||||
0 0 30px rgba(249, 141, 30, 0.5),
|
||||
0 0 40px rgba(249, 141, 30, 0.4);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="floating-social">
|
||||
<a href="https://{{ ltrim(setting('whatsapp'), 'https://') }}" target="_blank" class="btn-circle btn-whatsapp">
|
||||
<i class="fab fa-whatsapp"></i>
|
||||
</a>
|
||||
|
||||
|
||||
<!-- Chatbot Floating Button -->
|
||||
<div id="chatbot-toggle" class="glowing-animation">
|
||||
<i class="ri-message-2-fill" style="font-size: 30px; color: white;"></i>
|
||||
</div>
|
||||
|
||||
<!-- Chatbot UI -->
|
||||
<div id="chatbot-container" style="z-index: 9999">
|
||||
<div id="chatbot-header">
|
||||
Chatbot
|
||||
<span id="chatbot-close">×</span>
|
||||
</div>
|
||||
<div id="chatbot-body"></div>
|
||||
<div id="chatbot-input-container">
|
||||
<input type="text" id="chatbot-input" placeholder="Ask me something...">
|
||||
<button id="chatbot-send">
|
||||
<i class="ri-send-plane-2-fill"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Styles -->
|
||||
@push('css')
|
||||
<style>
|
||||
/* Floating Button */
|
||||
#chatbot-toggle {
|
||||
position: fixed;
|
||||
bottom: 45px;
|
||||
right: 38px;
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
background-color: var(--vz-primary);
|
||||
color: white;
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
/* Chat Container */
|
||||
#chatbot-container {
|
||||
position: fixed;
|
||||
bottom: 42px;
|
||||
right: 36px;
|
||||
width: 340px;
|
||||
height: 400px;
|
||||
background: #fff;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 14px;
|
||||
box-shadow: 0px 8px 24px rgba(0, 0, 0, 0.25);
|
||||
font-family: 'Segoe UI', sans-serif;
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
#chatbot-header {
|
||||
background-color: var(--vz-primary);
|
||||
color: white;
|
||||
padding: 12px 16px;
|
||||
font-size: 16px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#chatbot-body {
|
||||
flex: 1;
|
||||
padding: 12px;
|
||||
overflow-y: auto;
|
||||
background: #f9f9f9;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
scroll-behavior: smooth;
|
||||
}
|
||||
|
||||
.message {
|
||||
position: relative;
|
||||
padding: 10px 16px;
|
||||
margin: 6px 0;
|
||||
border-radius: 20px;
|
||||
max-width: 80%;
|
||||
font-size: 14px;
|
||||
line-height: 1.4;
|
||||
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
.user-message {
|
||||
background-color: rgba(0, 123, 255, 0.15);
|
||||
color: black;
|
||||
align-self: flex-end;
|
||||
margin-left: auto;
|
||||
border-bottom-right-radius: 0;
|
||||
}
|
||||
|
||||
.bot-message {
|
||||
background-color: rgba(var(--vz-primary-rgb), 0.15);
|
||||
color: black;
|
||||
align-self: flex-start;
|
||||
margin-right: auto;
|
||||
border-bottom-left-radius: 0;
|
||||
}
|
||||
|
||||
.typing-indicator {
|
||||
font-style: italic;
|
||||
font-size: 13px;
|
||||
color: #888;
|
||||
margin-top: 5px;
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
#chatbot-input-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 10px;
|
||||
border-top: 1px solid #eee;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
#chatbot-input {
|
||||
flex: 1;
|
||||
padding: 10px 15px;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 30px;
|
||||
font-size: 14px;
|
||||
outline: none;
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
#chatbot-send {
|
||||
background: var(--vz-primary);
|
||||
border: none;
|
||||
border-radius: 50%;
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: white;
|
||||
font-size: 18px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.floating-social {
|
||||
position: fixed;
|
||||
bottom: 210px;
|
||||
right: 45px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
.floating-social .btn-circle {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 24px;
|
||||
color: #fff;
|
||||
box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
.btn-whatsapp {
|
||||
background: #25D366;
|
||||
}
|
||||
</style>
|
||||
@endpush
|
||||
|
||||
<!-- Scripts -->
|
||||
@push('js')
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#chatbot-toggle').click(function() {
|
||||
$('#chatbot-container').fadeIn();
|
||||
$(this).hide();
|
||||
});
|
||||
|
||||
$('#chatbot-close').click(function() {
|
||||
$('#chatbot-container').fadeOut();
|
||||
$('#chatbot-toggle').show();
|
||||
});
|
||||
|
||||
$('#chatbot-send').click(sendMessage);
|
||||
$('#chatbot-input').keypress(function(e) {
|
||||
if (e.which == 13) sendMessage();
|
||||
});
|
||||
|
||||
function sendMessage() {
|
||||
const input = $('#chatbot-input');
|
||||
const body = $('#chatbot-body');
|
||||
const message = input.val().trim();
|
||||
|
||||
if (message === '') return;
|
||||
|
||||
body.append('<div class="message user-message">You: ' + message + '</div>');
|
||||
input.val('');
|
||||
body.append('<div class="typing-indicator" id="typing">Bot is typing...</div>');
|
||||
scrollToBottom();
|
||||
|
||||
$.ajax({
|
||||
url: '{{ route('chatbot.query') }}',
|
||||
type: 'POST',
|
||||
data: {
|
||||
message: message,
|
||||
_token: '{{ csrf_token() }}'
|
||||
},
|
||||
success: function(response) {
|
||||
$('#typing').remove();
|
||||
body.append('<div class="message bot-message">Bot: ' + response.reply +
|
||||
'</div>');
|
||||
scrollToBottom();
|
||||
},
|
||||
error: function() {
|
||||
$('#typing').remove();
|
||||
body.append(
|
||||
'<div class="message bot-message">Bot: Sorry, something went wrong.</div>'
|
||||
);
|
||||
scrollToBottom();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function scrollToBottom() {
|
||||
const body = $('#chatbot-body');
|
||||
body.scrollTop(body[0].scrollHeight);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@endpush
|
7
Modules/Chatbot/resources/views/index.blade.php
Normal file
7
Modules/Chatbot/resources/views/index.blade.php
Normal file
@@ -0,0 +1,7 @@
|
||||
@extends('chatbot::layouts.master')
|
||||
|
||||
@section('content')
|
||||
<h1>Hello World</h1>
|
||||
|
||||
<p>Module: {!! config('chatbot.name') !!}</p>
|
||||
@endsection
|
29
Modules/Chatbot/resources/views/layouts/master.blade.php
Normal file
29
Modules/Chatbot/resources/views/layouts/master.blade.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="csrf-token" content="{{ csrf_token() }}">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
|
||||
<title>Chatbot Module - {{ config('app.name', 'Laravel') }}</title>
|
||||
|
||||
<meta name="description" content="{{ $description ?? '' }}">
|
||||
<meta name="keywords" content="{{ $keywords ?? '' }}">
|
||||
<meta name="author" content="{{ $author ?? '' }}">
|
||||
|
||||
<!-- Fonts -->
|
||||
<link rel="preconnect" href="https://fonts.bunny.net">
|
||||
<link href="https://fonts.bunny.net/css?family=figtree:400,500,600&display=swap" rel="stylesheet" />
|
||||
|
||||
{{-- Vite CSS --}}
|
||||
{{-- {{ module_vite('build-chatbot', 'resources/assets/sass/app.scss', storage_path('vite.hot')) }} --}}
|
||||
</head>
|
||||
|
||||
<body>
|
||||
@yield('content')
|
||||
|
||||
{{-- Vite JS --}}
|
||||
{{-- {{ module_vite('build-chatbot', 'resources/assets/js/app.js', storage_path('vite.hot')) }} --}}
|
||||
</body>
|
0
Modules/Chatbot/routes/.gitkeep
Normal file
0
Modules/Chatbot/routes/.gitkeep
Normal file
19
Modules/Chatbot/routes/api.php
Normal file
19
Modules/Chatbot/routes/api.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Modules\Chatbot\Http\Controllers\ChatbotController;
|
||||
|
||||
/*
|
||||
*--------------------------------------------------------------------------
|
||||
* API Routes
|
||||
*--------------------------------------------------------------------------
|
||||
*
|
||||
* Here is where you can register API routes for your application. These
|
||||
* routes are loaded by the RouteServiceProvider within a group which
|
||||
* is assigned the "api" middleware group. Enjoy building your API!
|
||||
*
|
||||
*/
|
||||
|
||||
Route::middleware(['auth:sanctum'])->prefix('v1')->group(function () {
|
||||
Route::apiResource('chatbot', ChatbotController::class)->names('chatbot');
|
||||
});
|
21
Modules/Chatbot/routes/web.php
Normal file
21
Modules/Chatbot/routes/web.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Modules\Chatbot\Http\Controllers\ChatbotController;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Web Routes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here is where you can register web routes for your application. These
|
||||
| routes are loaded by the RouteServiceProvider within a group which
|
||||
| contains the "web" middleware group. Now create something great!
|
||||
|
|
||||
*/
|
||||
|
||||
Route::group([], function () {
|
||||
|
||||
Route::post('/chatbot/query', [ChatbotController::class, 'query'])->name('chatbot.query');
|
||||
Route::resource('chatbot', ChatbotController::class)->names('chatbot');
|
||||
});
|
57
Modules/Chatbot/vite.config.js
Normal file
57
Modules/Chatbot/vite.config.js
Normal file
@@ -0,0 +1,57 @@
|
||||
import { defineConfig } from 'vite';
|
||||
import laravel from 'laravel-vite-plugin';
|
||||
import { readdirSync, statSync } from 'fs';
|
||||
import { join,relative,dirname } from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
export default defineConfig({
|
||||
build: {
|
||||
outDir: '../../public/build-chatbot',
|
||||
emptyOutDir: true,
|
||||
manifest: true,
|
||||
},
|
||||
plugins: [
|
||||
laravel({
|
||||
publicDirectory: '../../public',
|
||||
buildDirectory: 'build-chatbot',
|
||||
input: [
|
||||
__dirname + '/resources/assets/sass/app.scss',
|
||||
__dirname + '/resources/assets/js/app.js'
|
||||
],
|
||||
refresh: true,
|
||||
}),
|
||||
],
|
||||
});
|
||||
// Scen all resources for assets file. Return array
|
||||
//function getFilePaths(dir) {
|
||||
// const filePaths = [];
|
||||
//
|
||||
// function walkDirectory(currentPath) {
|
||||
// const files = readdirSync(currentPath);
|
||||
// for (const file of files) {
|
||||
// const filePath = join(currentPath, file);
|
||||
// const stats = statSync(filePath);
|
||||
// if (stats.isFile() && !file.startsWith('.')) {
|
||||
// const relativePath = 'Modules/Chatbot/'+relative(__dirname, filePath);
|
||||
// filePaths.push(relativePath);
|
||||
// } else if (stats.isDirectory()) {
|
||||
// walkDirectory(filePath);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// walkDirectory(dir);
|
||||
// return filePaths;
|
||||
//}
|
||||
|
||||
//const __filename = fileURLToPath(import.meta.url);
|
||||
//const __dirname = dirname(__filename);
|
||||
|
||||
//const assetsDir = join(__dirname, 'resources/assets');
|
||||
//export const paths = getFilePaths(assetsDir);
|
||||
|
||||
|
||||
//export const paths = [
|
||||
// 'Modules/Chatbot/resources/assets/sass/app.scss',
|
||||
// 'Modules/Chatbot/resources/assets/js/app.js',
|
||||
//];
|
@@ -18,5 +18,6 @@
|
||||
"Drive": true,
|
||||
"Sitemap": true,
|
||||
"Document": true,
|
||||
"CostCalculator": true
|
||||
}
|
||||
"CostCalculator": true,
|
||||
"Chatbot": true
|
||||
}
|
Reference in New Issue
Block a user