PHPackages                             omarseyam/laravel-chatbot - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. omarseyam/laravel-chatbot

ActiveLibrary

omarseyam/laravel-chatbot
=========================

Conversation-persisted AI chat scaffolding for Laravel, built on the Laravel AI SDK.

v1.0.0(today)00MITPHPPHP ^8.3

Since Aug 9Pushed todayCompare

[ Source](https://github.com/OmarSeyam/laravel-chatbot)[ Packagist](https://packagist.org/packages/omarseyam/laravel-chatbot)[ Docs](https://github.com/omarseyam/laravel-chatbot)[ RSS](/packages/omarseyam-laravel-chatbot/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (5)Versions (2)Used By (0)

Laravel Chatbot
===============

[](#laravel-chatbot)

Conversation-persisted AI chat scaffolding for Laravel, built on top of the [Laravel AI SDK](https://packagist.org/packages/laravel/ai). It gives you a `ChatService` you can call from a controller or job, and stores every conversation and message in your own database so history survives across requests and can be replayed back into an agent.

Requirements
------------

[](#requirements)

- PHP 8.3+
- Laravel 13.x
- [`laravel/ai`](https://packagist.org/packages/laravel/ai) — install it yourself with `composer require laravel/ai` and configure at least one provider before using this package. It isn't bundled automatically.

Installation
------------

[](#installation)

```
composer require omarseyam/laravel-chatbot
composer require laravel/ai
php artisan chatbot:install
php artisan migrate
```

`chatbot:install` publishes `config/agents.php` and copies the chat source files into `app/Ai/...` and the two models into `app/Models/...`. These become part of your application once copied, so edit them freely — running the command again won't overwrite anything that already exists unless you pass `--force`.

**You don't need to publish or copy the migrations.** They ship with the package and load automatically the moment the service provider boots — just run `php artisan migrate` and the `agent_conversations` and `agent_conversation_messages` tables will be created.

Configuration
-------------

[](#configuration)

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

```
return [
    'assistant' => \App\Ai\Agents\ExampleAgent::class,
];
```

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

Usage
-----

[](#usage)

```
use App\Ai\Data\ChatRequest;
use App\Ai\Services\ChatService;

$response = app(ChatService::class)->ask(new ChatRequest(
    prompt: 'What can you help me with?',
    conversationId: null, // pass an existing conversation id to continue it
    agent: 'assistant',
));

// $response = ['conversation_id' => '...', 'content' => [...]]
```

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
--------------------------------------------------

[](#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:

```
