Chatbot for Laravel Website Owners: Add the Embed Script to Blade the Safe Way, With Config Caching, Logged-In Names and Test Routes (Free Copy-Ready Snippets)

Chatbot for Laravel website projects does not need a package. LiveChatBot installs with one embed script, and your Blade layout is the right place for it. This guide covers where to put the tag, how to keep the key in config so it survives config caching, how to pass a signed-in user to the chat, and the small mistakes that make a widget vanish in production.

1embed script, no package
2websites on the free plan
100free visitors per site each month
0per-seat charges

โšก In short

  • There is no Laravel package. You paste one embed script into your main Blade layout.
  • Keep the widget key in config/services.php, not in env() calls inside views, so config:cache cannot break it.
  • Use a layout stack so pages without the chat (admin, checkout) can opt out.
  • Signed-in users can be named in the chat with the JavaScript API call setVisitor.
Chatbot for laravel website in LiveChatBot: AI Agent knowledge sources and a sample chat answered from them
How it looks in LiveChatBot: AI Agent knowledge sources and a sample chat answered from them.

The short version

What a chatbot for Laravel website projects actually needs

LiveChatBot has no Composer package and no Laravel-specific plugin. That is a fact worth saying early, because search results for this topic are full of packages you do not need.

What you do get is a script tag. It loads the widget from livechatbot.in and takes a key that tells it which website it belongs to. Laravel renders HTML through Blade, so adding a script tag is the same job as adding an analytics tag.

The work is therefore not integration. It is housekeeping: put the tag in one layout, keep the key in one config file, load it only where you want chat, and make sure it still works after you deploy with cached config. The rest of this guide covers those four things in order.

Install

Step one: the layout partial

Create a partial, for example `resources/views/partials/livechatbot.blade.php`, and include it near the end of your main layout, just before the closing body tag.

Why a partial

One file means one place to change the key, and one place to remove the chat if you ever need to. Putting the raw script in ten templates is how a widget ends up on the login page and not on the pricing page.

Where to include it

Include it in the layout that wraps your public pages. If you have a separate admin layout, leave it out. Staff do not need a chat bubble over a dashboard, and visitor counts stay cleaner without it. Copy your widget key from the install page of your LiveChatBot dashboard after you sign up.

The snippet itself is in the copy-ready box further down. Our general website setup guide covers the dashboard side, such as colours and welcome text.

Config

Step two: keep the key where config:cache can find it

The classic Laravel trap is calling `env(‘LIVECHATBOT_KEY’)` inside a Blade view. It works on your laptop. After you run `php artisan config:cache` in production, `env()` outside config files returns null, and the script tag renders with an empty key.

The fix takes two lines. Add an entry to `config/services.php` that reads the environment variable, and call `config(‘services.livechatbot.key’)` in the partial.

Why it only bites in production

Local development rarely caches config, so everything looks fine until the first deploy. Add the cache command to your release checklist and test one public page straight after each release.

A small guard

Wrap the script in a check so an empty key renders nothing instead of a broken tag. That also means local and staging environments can stay chat-free simply by leaving the variable unset. You will not accidentally count test visits as real visitors, which matters because each website has a monthly visitor allowance.

Try it

Copy-ready snippets for a chatbot for Laravel website layouts

Four tabs: the partial, the config entry, the logged-in call and a per-page opt-out. Replace the placeholder names with your own.

@if (config(‘services.livechatbot.key’))
<script src="https://livechatbot.in/widget.js" data-key="{{ config(‘services.livechatbot.key’) }}" async></script>
@endif
‘livechatbot’ => [‘key’ => env(‘LIVECHATBOT_KEY’)], // inside config/services.php
LIVECHATBOT_KEY=your-widget-key // in .env, then run php artisan config:cache
@auth
<script>window.addEventListener(‘load’, function () { if (window.LiveChatBot) { window.LiveChatBot.setVisitor({ name: @json(auth()->user()->name), email: @json(auth()->user()->email) }); } });</script>
@endauth
@unless (View::hasSection(‘no_chat’)) @include(‘partials.livechatbot’) @endunless
@section(‘no_chat’) @endsection // add this line in any page that should have no chat

Signed-in users

Step three: tell the chat who is logged in

If your Laravel app has customer accounts, your team will ask the same thing in every chat: who are you? The JavaScript API answers it. The call `window.LiveChatBot.setVisitor` accepts details such as name and email, and the snippet above runs it only for authenticated users.

Three cautions. First, send only what your agents need; a name and email are usually enough. Second, use `@json` rather than building strings by hand, so an apostrophe in a name cannot break the script. Third, mention website chat in your privacy notice. If you want more API calls, ask our team for developer documentation; the full list is not published on livechatbot.in yet.

The chat also supports `open`, `close`, `show`, `hide`, `sendMessage`, `pageView` and an `on` listener. If your Laravel front end is a single-page app, call `pageView` after route changes so visitor tracking sees every page.

Where it shows

Step four: decide which routes get chat

A good chatbot for Laravel website work is selective. Chat helps on pricing, product and help pages. It rarely helps on a password reset or a payment form where a floating bubble can cover a button.

You have two ways to control this. In code, the opt-out pattern above lets any view remove the partial. In the dashboard, the “where it shows” setting lets you hide the chat on chosen pages, limit it by device or country, and needs no deploy. Use the dashboard for business rules and code for technical ones.

For proactive messages, such as a greeting on the pricing page only, use Flows with a page condition. That keeps marketing wording out of your Blade files entirely, so non-developers can change it.

Test

Test routes and the mistakes that hide the widget

After deploying, open a private window on a public route and check three things: the script tag appears in the page source with a real key, the bubble loads, and a test message reaches your inbox or the Android app.

Common causes when nothing shows:

  • Empty key after config caching, as described above.
  • Content Security Policy. If you send a CSP header, allow scripts and connections from livechatbot.in.
  • Page cache or CDN serving an old HTML copy. Clear it after adding the tag.
  • Layout mismatch. The page extends a different layout from the one you edited.
  • Ad blockers in your own browser. Test in a clean profile.

A quick routine

Keep one test page URL in your release notes. After each deploy, load it, send “test” from the chat, and confirm it arrives. The check takes a minute and catches nearly every silent failure.

Our script troubleshooting guide goes deeper on tags that load but show nothing.

Limits

What this does not do

Be clear about the gaps before you plan work around them.

  • There is no Laravel package, Artisan command or Eloquent integration. The chat does not read your database.
  • The AI Agent answers from the knowledge you give it, not from your tables. It cannot look up an order or a user’s plan.
  • There is no WhatsApp inbox, and the team app is Android only.
  • “Powered by LiveChatBot” stays on all plans.

What you can connect: webhooks for tickets (created and solved), a REST API, and Zapier, all described on the integrations page. If your Laravel app must react to a new ticket, a webhook route is the usual path.

Frequently asked questions

Is there a Composer package for a chatbot for Laravel website use?

No. LiveChatBot installs with one embed script, which you place in a Blade layout or partial.

Why does the widget disappear after config:cache?

Calling env() inside a view returns null once config is cached. Read the key through config(‘services.livechatbot.key’) instead.

Can I show the chat only to logged-in users?

Yes. Wrap the include in an @auth block, or use the dashboard’s where-it-shows settings.

Can the chat see my Laravel database?

No. It answers from the knowledge you add and does not read your database or orders.

What does it cost to try?

The free plan covers two websites with 100 free visitors per website each month, with no per-seat charges.

Keep reading

Related guides

๐Ÿ“˜

Free Chatbot for Webflow: What Stays Free, What Costs Money and What Webflow Itself Charges For

Read the guide โ†’

Add chat to your Laravel project

One script tag, a free plan for two websites and no per-seat charges. Start free on livechatbot.in.