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. halilcosdu/laravel-chatbot

ActiveLibrary

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

Laravel AI Chatbot Package

v1.2.3(1y ago)634.5k↓35.6%6[1 issues](https://github.com/halilcosdu/laravel-chatbot/issues)[5 PRs](https://github.com/halilcosdu/laravel-chatbot/pulls)MITPHPPHP ^8.2CI failing

Since Apr 17Pushed 4mo 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 1mo ago

READMEChangelog (10)Dependencies (14)Versions (17)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

47

—

FairBetter than 94% of packages

Maintenance57

Moderate activity, may be stable

Popularity38

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 ~5 days

Total

11

Last Release

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

[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24149.7k](/packages/vormkracht10-laravel-mails)[spatie/laravel-prometheus

Export Laravel metrics to Prometheus

2651.3M6](/packages/spatie-laravel-prometheus)[hydrat/filament-table-layout-toggle

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

6292.3k1](/packages/hydrat-filament-table-layout-toggle)[scalar/laravel

Render your OpenAPI-based API reference

6183.9k2](/packages/scalar-laravel)[ralphjsmit/laravel-helpers

A package containing handy helpers for your Laravel-application.

13704.6k2](/packages/ralphjsmit-laravel-helpers)[musahmusah/laravel-multipayment-gateways

A Laravel Package that makes implementation of multiple payment Gateways endpoints and webhooks seamless

852.2k1](/packages/musahmusah-laravel-multipayment-gateways)

PHPackages © 2026

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