Download the PHP package shibuj/laravel-ai-chat-assistant without Composer

On this page you can find all versions of the php package shibuj/laravel-ai-chat-assistant. 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-ai-chat-assistant

Laravel AI Chat Assistant

A BotMan-powered, tool-calling AI chat widget for Laravel. Drop in a floating chat widget backed by an LLM that can call your app's own PHP methods ("tools") to answer questions from real data — orders, stock, customers, whatever you define.


Requirements


Installation

Publish the config file:

Publish the widget's CSS/JS assets:

Optionally publish the Blade view if you want to customize the widget markup itself:

Add your API key to .env:

Two things the widget expects from your layout

The widget's JS posts to the chat endpoint with fetch(), and its icons use Font Awesome — neither is bundled by the package, since both are things a Laravel app almost always already has. Add both to the <head> of any layout that includes the widget:

That's it — the package auto-registers its service provider and a chat route.


Quick start (single assistant)

1. Generate a tool

A tool is one thing the assistant can look up. Start small.

This creates app/AiTools/GetOrderStatusTool.php:

Important: never trust arguments the model sends for identity — always scope queries using the logged-in user, not anything the model could pass in. See Security below.

2. Generate an assistant

This creates app/Assistants/OrderAssistant.php:

3. Register the assistant

In app/Providers/AppServiceProvider.php:

With only one assistant registered, you don't need a resolver — it's used automatically.

4. Add the widget to your layout

In your main Blade layout — make sure the <meta name="csrf-token"> tag and Font Awesome link from Installation are in the <head> first — then just before </body>:

Done. Visit any page with that layout and you'll see the chat launcher.


Widget options

Option Description
name Shown in the panel header and the launcher's aria-label.
welcome Sub-text shown under "How can I help?" on first open.
placeholder Input field placeholder text.
footer Small print under the input (e.g. a disclaimer).
scope Required to keep conversations separate per user/role. Any unique string — e.g. 'user-' . auth()->id(). Two different scopes never see each other's chat history.
quick Array of quick-action chips. Each is either ['icon' => ..., 'label' => ..., 'send' => '...'] (sends a message immediately) or ['icon' => ..., 'label' => ..., 'prefill' => '...'] (fills the input for the user to complete).

Icons use Font Awesome classes (fa-search, fa-history, etc.) — make sure Font Awesome is loaded on the page (see Installation), or swap the markup in the published view for your own icon set.


Multiple assistants

If your app has more than one kind of user who should get a different assistant (customer-facing vs. staff-facing vs. admin, for example), register several and tell the manager how to pick one:

Then in each layout, @include the widget with whatever copy/chips/scope fit that audience — the manager figures out which registered assistant actually answers based on the resolver, independent of what the widget's name/welcome text says.


Restricting a tool per role

If one assistant should expose different tools to different users of the same role (e.g. staff members with different permissions), gate it inside the assistant, not the tool:

hasAccess() is checked before every message; if it returns false, noAccessMessage() is sent instead and no tool ever runs.


Swapping the AI driver

The package ships two drivers — gemini (default) and a minimal openai example. Swap globally:

Or pin one specific assistant to a different driver, regardless of the global default:

Writing your own driver

Implement ShibuJ\AiChatAssistant\Contracts\AiDriver:

Register it in config/ai-assistant.php:

Then set AI_ASSISTANT_DRIVER=anthropic or use driverName() on a specific assistant.


Security

The package deliberately keeps identity out of tool arguments. A few rules worth following in every tool and assistant you write:


How conversation history works

Each scope you pass to the widget gets its own conversation, cached server-side (default: file cache store, last 6 turns, 30-minute TTL — all configurable in config/ai-assistant.php). The widget also mirrors the visible chat log in the browser's sessionStorage so a page navigation doesn't visually clear the chat, but a full page reload starts fresh on both ends.


Interactive actions (buttons)

If a tool needs the user to confirm something before it happens (e.g. "place this order?"), set pendingAction on the assistant from within your reply() flow — typically by having a tool set a property your Assistant subclass checks after driver->converse() returns. The simplest approach: store draft state yourself (cache, DB) and check for it after calling the driver in an overridden reply():

The bundled AssistantChatController will render these as buttons automatically. Handling __confirm__:... / __cancel__:... button presses is app-specific — extend or replace the controller's fallback/hears wiring for that (see Customizing the controller below).


Customizing the controller

If you need extra BotMan hears() handlers (e.g. for confirm/cancel buttons, as above), publish nothing — instead, register your own route pointing at your own controller that composes the package's pieces:

Then point the widget's data-endpoint at your own route instead of the package's, either by publishing the view (--tag=ai-assistant-views) and editing it, or by setting 'route' => ['path' => '/my-assistant-chat'] in the published config and building your own controller at that path.


Testing your tools

Tools are plain classes — test them directly, no HTTP or AI calls needed:


Configuration reference


Troubleshooting

"CSRF token mismatch" / widget always shows "The assistant could not answer"

The page including the widget is missing the CSRF meta tag. Add this to the <head>:

The widget's JS reads this tag and sends it as the X-CSRF-TOKEN header on every request; without it, Laravel's VerifyCsrfToken middleware rejects every message with a 419 response, which the widget surfaces as a generic connection error. This is easy to miss on a bare test page (e.g. the default welcome.blade.php) since a full app layout usually already has this tag from Laravel's default scaffolding.

Chat icons show as empty boxes or don't appear at all

Font Awesome isn't loaded on the page. Add a CDN link (or your own npm-bundled copy) to the <head>:

The widget's launcher, close/new-chat buttons, and quick-action chips all use fas fa-* classes. The widget still functions correctly without Font Awesome present — only the icons are affected.

vendor:publish --tag=ai-assistant-assets fails with "Can't locate path"

This means the installed package version is missing its resources/assets/ files (a packaging bug in early 0.1.x releases, fixed in v0.1.4+). Update to the latest version and republish:

Composer can't find the package / version conflict on install

Double check you're requiring the exact published name — composer require shibuj/laravel-ai-chat-assistant — and that your Laravel/PHP version falls within the package's declared require range in its own composer.json. Run with -vvv for the exact conflicting constraint if it still fails:


Upgrading

Check CHANGELOG.md before upgrading a major version — the Assistant and Tool contracts are considered the stable public API; changes to them will always be a major-version bump.



All versions of laravel-ai-chat-assistant with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0.2
illuminate/support Version ^9.0|^10.0|^11.0|^12.0
illuminate/http Version ^9.0|^10.0|^11.0|^12.0
botman/botman Version ^2.8
botman/driver-web Version ^1.5
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 shibuj/laravel-ai-chat-assistant contains the following files

Loading the files please wait ...