Download the PHP package omarseyam/laravel-chatbot without Composer

On this page you can find all versions of the php package omarseyam/laravel-chatbot. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-chatbot

Laravel Chatbot

Conversation-persisted AI chat scaffolding for Laravel, built on top of the Laravel AI SDK. It gives you a ChatService you can call from a controller or job, stores every conversation and message in your database, and ships a ready-to-use chat drawer UI you can drop into any page.

Requirements

Installation

chatbot:install publishes config/agents.php, publishes this package's migrations to database/migrations, and copies:

These become part of your application once copied/published, so edit them freely — running the command again won't overwrite anything that already exists unless you pass --force.

Database setup

This package does not create its own tables. laravel/ai already creates agent_conversations and agent_conversation_messages (that's what backs its RemembersConversations trait), and this package's models use those same tables — so laravel/ai's migrations have to run first:

This package's own migrations are published by chatbot:install into database/migrations (so they're visible and editable, not hidden in vendor/), and only add the extra columns AgentConversation/AgentConversationMessage need on top of those two tables — agent, structured, tool_calls, tool_results, usage, meta, and a user_id foreign key on both tables. They're dated far in the future so they always sort — and run — after laravel/ai's migration, whatever timestamp that one happens to get published with. Each column is guarded with hasColumn(): added if it's missing, or adjusted with ->change() to the shape this package expects if a column by that name already exists — so running php artisan migrate again is safe.

Configuration

Register your agents in config/agents.php by mapping an alias to an Agent class:

The alias is what you pass as agent on a ChatRequest.

Usage

content is a plain string for a normal text reply, or an array if the agent implements HasStructuredOutput. MessageService records which case each stored message is in a structured column, so anything reading history back — the chat UI, an agent's messages() — knows whether to json_decode() it.

Conversations and messages are scoped to the authenticated user (Auth::id()), so a conversationId can only be resumed by the user who started it.

Preparing an agent to receive conversation history

For an agent to actually see prior turns of a conversation (rather than only the latest prompt), it needs to accept a $messages array and implement Conversational. AgentManager::resolve() already passes the mapped history in for you when one is available — the agent just needs to be shaped to accept it:

A copy of this lives at app/Ai/Agents/ExampleAgent.php after running chatbot:install — rename it, register it in config/agents.php, and fill in instructions() (plus tools()/schema() if you keep the HasTools/ HasStructuredOutput interfaces).

Fetching a conversation's history directly

MessageService::history() returns messages already mapped into Laravel\Ai\Messages\Message objects, ready to hand to an agent. If you just need the raw rows — e.g. to render a chat thread in a view — query the model directly:

The included AIChat Blade component (see "UI" below) already does exactly this.

Models and linking your own models to a conversation

AgentConversation ships with a post() relation to a Post model as an example only — it isn't something the package requires. To link your own model(s) back to the conversation that produced them (and pull the full message history behind them), add a conversation_id foreign key column to that model's own migration, then define the matching relations:

Pruning old conversations

AgentConversation uses Laravel's Prunable trait to clean up conversations older than an hour, skipping any tied to the example post() relation above (adjust whereDoesntHave('post') in prunable() to match whatever relation you replace it with, or drop it entirely if nothing needs protecting). Deleting a conversation — by hand or via pruning — also deletes its messages, so nothing is left orphaned. Schedule pruning in routes/console.php:

UI

chatbot:install copies a ready-made chat drawer: a floating button that opens a panel with message history, a text input, and typing indicator.

Drop it into any page (a class-based component under App\View\Components\Chat resolves to the <x-chat.a-i-chat> tag):

A few things need wiring up by hand — none of these are copied automatically, since they touch files this package can't safely overwrite:

  1. CSRF token. The chat JS sends a X-CSRF-TOKEN header read from a meta tag. Add this to the <head> of the layout that renders the chat component:

  2. The API endpoint. resources/js/ai/api.js has a placeholder fetch URL — set it to whichever route in your app accepts { prompt, conversation_id } and calls ChatService::ask():

    For example:

    Then point api.js at /ai/chat.

  3. Import the chat JS. Add this to your existing resources/js/app.js:

  4. Styling. The drawer uses Tailwind utility classes plus a handful of custom ones (.ai-assistant-bubble, .ai-assistant-header, .ai-assistant-copy, and dark-mode variants) that aren't defined by default Tailwind — add them to your own CSS. It also assumes Material Design 3–style color tokens (bg-primary, text-on-surface, border-outline-variant, etc.) are already part of your Tailwind theme; if they aren't, either define them or adjust the classes in a-i-chat.blade.php to match your own design system.

  5. npm packages. The chat JS depends on marked, highlight.js, and dompurify, and the message bubbles use Tailwind's typography plugin:

Contributing

Issues and pull requests are welcome at github.com/omarseyam/laravel-chatbot.

Author

Omar Seyam (@omarseyam) — [email protected]

License

The MIT License (MIT). See LICENSE for details.


All versions of laravel-chatbot with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
illuminate/contracts Version ^13.0
illuminate/support Version ^13.0
illuminate/database Version ^13.0
illuminate/console Version ^13.0
laravel/ai Version ^0.7|^0.8|^0.9|^0.10
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package omarseyam/laravel-chatbot contains the following files

Loading the files please wait ...