PHPackages                             halilcosdu/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. halilcosdu/laravel-chatbot

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

halilcosdu/laravel-chatbot
==========================

Laravel AI Chatbot Package

v1.3.0(2mo ago)645.1k↓33.5%6[5 PRs](https://github.com/halilcosdu/laravel-chatbot/pulls)MITPHPPHP ^8.2CI failing

Since Apr 17Pushed 2mo ago2 watchersCompare

[ Source](https://github.com/halilcosdu/laravel-chatbot)[ Packagist](https://packagist.org/packages/halilcosdu/laravel-chatbot)[ Docs](https://github.com/halilcosdu/laravel-chatbot)[ Fund](https://www.buymeacoffee.com/halilcosdu5)[ RSS](/packages/halilcosdu-laravel-chatbot/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (10)Dependencies (28)Versions (18)Used By (0)

Laravel AI Chatbot Package
==========================

[](#laravel-ai-chatbot-package)

[![Latest Version on Packagist](https://camo.githubusercontent.com/fbef2aeba5a2fab19698a2a46eb1bb46073e9c42ab053df6ad96992dcb05f273/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f68616c696c636f7364752f6c61726176656c2d63686174626f742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/halilcosdu/laravel-chatbot)[![GitHub Tests Action Status](https://camo.githubusercontent.com/acc339b5854962cda60f017a1d23646d8530203366f997e30b560249acdb464c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f68616c696c636f7364752f6c61726176656c2d63686174626f742f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/halilcosdu/laravel-chatbot/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/5bd53126f899e9c0a8d15f8c1c292cab6dcfc8a11a602438fe57cd1544e0b0aa/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f68616c696c636f7364752f6c61726176656c2d63686174626f742f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/halilcosdu/laravel-chatbot/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/f1b728778236367d6ece301e5aa77e79a2476559fb3810b61574b101b7a15f0c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f68616c696c636f7364752f6c61726176656c2d63686174626f742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/halilcosdu/laravel-chatbot)

Laravel Chatbot provides a robust and easy-to-use solution for integrating AI chatbots into your Laravel applications. Leveraging the power of OpenAI, it allows you to create, manage, and interact with chat threads directly from your Laravel application. Whether you're building a customer service chatbot or an interactive AI assistant, `laravel-chatbot` offers a streamlined, Laravel-friendly interface to the OpenAI API.

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

[](#installation)

You can install the package via composer:

```
composer require halilcosdu/laravel-chatbot
```

You can publish the config file with:

```
php artisan vendor:publish --tag="chatbot-config"
```

This is the contents of the published config file:

You have to create an assistant on OpenAI and get the API key and assistant ID.

```
return [
    'assistant_id' => env('OPENAI_API_ASSISTANT_ID'),
    'api_key' => env('OPENAI_API_KEY'),
    'organization' => env('OPENAI_ORGANIZATION'),
    'request_timeout' => env('OPENAI_TIMEOUT'),
    'sleep_seconds' => env('OPENAI_SLEEP_SECONDS'), // Sleep seconds between requests default .1
    'models' => [
        // Thread model must have threadMessages(): HasMany relation
        // ThreadMessage model mush have thread(): BelongsTo relation
        'thread' => \HalilCosdu\ChatBot\Models\Thread::class,
        'thread_messages' => \HalilCosdu\ChatBot\Models\ThreadMessage::class
    ],
];
```

You can publish and run the migrations with:

```
php artisan vendor:publish --tag="chatbot-migrations"
php artisan migrate
```

This will migrate the following tables:

```
Schema::create('threads', function (Blueprint $table) {
    $table->id();
    $table->string('owner_id')->nullable()->index();
    $table->string('subject');
    $table->string('remote_thread_id')->index();

    $table->timestamps();
});
```

```
Schema::create('thread_messages', function (Blueprint $table) {
    $table->id();
    $table->foreignIdFor(config('chatbot.models.thread'))->constrained()->cascadeOnDelete();
    $table->string('role')->index();
    $table->longText('content');

    $table->timestamps();
});
```

Usage
-----

[](#usage)

```
public function listThreads(mixed $ownerId = null, mixed $search = null, mixed $appends = null): \Illuminate\Contracts\Pagination\LengthAwarePaginator
public function createThread(string $subject, mixed $ownerId = null): \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Builder
public function thread(int $id, mixed $ownerId = null): \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Builder
public function updateThread(string $message, int $id, mixed $ownerId = null): \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Builder
public function deleteThread(int $id, mixed $ownerId = null): void
```

```
ChatBot::listThreads(): LengthAwarePaginator; /* List all threads */
ChatBot::createThread('Hello, what is the capital of Turkey?'): Model; /* Create a new thread */
ChatBot::thread($id): Model; /* Get a thread with messages */
ChatBot::updateThread('Where should I visit?', $id): Model; /* Continue the conversation */
ChatBot::deleteThread($id): void; /* Delete the thread */
```

### Raw Data - Not Saved to Database

[](#raw-data---not-saved-to-database)

#### You can use the following methods to interact with the OpenAI API directly.

[](#you-can-use-the-following-methods-to-interact-with-the-openai-api-directly)

```
public function createThreadAsRaw(string $subject)
public function listThreadMessagesAsRaw(string $remoteThreadId)
public function updateThreadAsRaw(string $remoteThreadId, array $data) /* $data = ['role' => 'user or assistant', 'content' => 'Hello'] */
public function deleteThreadAsRaw(string $remoteThreadId)
public function threadAsRaw(string $threadId)
public function messageAsRaw(string $threadId, string $messageId)
public function modifyMessageAsRaw(string $threadId, string $messageId, array $parameters)
```

```
ChatBot::createThreadAsRaw(string $subject);
ChatBot::listThreadMessagesAsRaw(string $remoteThreadId);
ChatBot::updateThreadAsRaw(string $remoteThreadId, array $data);
ChatBot::deleteThreadAsRaw(string $remoteThreadId);
ChatBot::threadAsRaw(string $threadId);
ChatBot::messageAsRaw(string $threadId, string $messageId);
ChatBot::modifyMessageAsRaw(string $threadId, string $messageId, array $parameters);
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Halil Cosdu](https://github.com/halilcosdu)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

53

—

FairBetter than 96% of packages

Maintenance85

Actively maintained with recent releases

Popularity37

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 58.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~65 days

Recently: every ~176 days

Total

12

Last Release

76d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/eb33d4d47ce7f6f885331f34e8ed984e57866237d54526a2e3c97bdcbb11ecbb?d=identicon)[halilcosdu](/maintainers/halilcosdu)

---

Top Contributors

[![halilcosdu](https://avatars.githubusercontent.com/u/6373017?v=4)](https://github.com/halilcosdu "halilcosdu (42 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (15 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (12 commits)")[![rashidlaasri](https://avatars.githubusercontent.com/u/36804104?v=4)](https://github.com/rashidlaasri "rashidlaasri (2 commits)")[![gracieuxsikuly](https://avatars.githubusercontent.com/u/80897404?v=4)](https://github.com/gracieuxsikuly "gracieuxsikuly (1 commits)")

---

Tags

laravelHalilCosdularavel-chatbot

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/halilcosdu-laravel-chatbot/health.svg)

```
[![Health](https://phpackages.com/badges/halilcosdu-laravel-chatbot/health.svg)](https://phpackages.com/packages/halilcosdu-laravel-chatbot)
```

###  Alternatives

[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.3M42](/packages/spatie-laravel-pdf)[codewithdennis/filament-select-tree

The multi-level select field enables you to make single selections from a predefined list of options that are organized into multiple levels or depths.

328482.0k25](/packages/codewithdennis-filament-select-tree)[nativephp/desktop

NativePHP for Desktop

38133.6k8](/packages/nativephp-desktop)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

124581.3k](/packages/worksome-exchange)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3913.7k](/packages/rawilk-profile-filament-plugin)[hydrat/filament-table-layout-toggle

Filament plugin adding a toggle button to tables, allowing user to switch between Grid and Table layouts.

63105.4k2](/packages/hydrat-filament-table-layout-toggle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
