laravel maintained by db-chatbot
DB Chatbot
Rule-based database chatbot for Laravel. It answers shop questions from registered tools and can render PDF and Word reports. There is no LLM and no external AI API.
An LLM driver can be added later by implementing DbChatbot\Chat\Drivers\ChatDriver. The tools stay the same.
Requirements
- PHP 8.3 or newer
- Laravel 13
- A Blade layout component (the default is
app-layout)
Install
composer require db-chatbot/laravel
Laravel discovers DbChatbot\DbChatbotServiceProvider.
- On the host
Usermodel, implementDbChatbot\Contracts\ChatUser, useDbChatbot\Concerns\InteractsWithDbChatbot, and castroletoDbChatbot\Enums\Role. - Run
php artisan migrate. The package addsroleonusersand the shop, chat, audit, and report tables. - Optional:
php artisan vendor:publish --tag=db-chatbot-configand changelayoutwhen the host layout component is notapp-layout.
Authenticated routes:
GET/POST/DELETE /chatGET /admin/auditfor admins- signed
GET /reports/{report}
Report files use the reports disk (storage/app/reports). The package registers that disk when the host has not defined it. reports:prune runs daily and deletes files older than 24 hours.
Authorization
Every tool receives the signed-in user through DbChatbot\Contracts\ChatUser and checks a policy or gate itself. Customers can see only their own orders. A missing order and a forbidden order both return Order not found.
Adding a tool
- Add a class under
src/Chat/Toolsthat implementsDbChatbot\Chat\Tools\Tool. - Register it in
config/chatbot.php. The first matching tool wins. - Enforce access inside
handle(). Read data with Eloquent and validate every argument. - Return a
ToolResult. Do not return password hashes, tokens,remember_token, or card data.