Add live chat to your Laravel app

Keep the widget key in your environment, render one script tag in Blade, and let signed-in users start chats with their name and email already filled in.

You need a Laravel application with a Blade layout and a free ChatMesh workspace. Create one here if you haven’t already.

  1. Create a free ChatMesh workspace

    Sign up on the Free plan and copy your public widget key (pk_…) from Settings → Widget.

  2. Add the key to your configuration

    Put the key in .env and read it from config/services.php, so each environment (local, staging, production) can use its own workspace.

    .env
    CHATMESH_WIDGET_KEY=pk_live_...
    config/services.php
    // config/services.php
    'chatmesh' => [
        'widget_key' => env('CHATMESH_WIDGET_KEY'),
    ],
  3. Render the widget in your Blade layout

    Add the script tag just before </body> in your main layout, for example resources/views/layouts/app.blade.php.

    app.blade.php
    {{-- resources/views/layouts/app.blade.php, just before </body> --}}
    @if (config('services.chatmesh.widget_key'))
        <script src="https://chatmesh.ascend-digital.co.uk/widget.js"
                data-chatmesh-key="{{ config('services.chatmesh.widget_key') }}"
                async></script>
        @auth
            <script>
                window.addEventListener('load', () => window.ChatMesh?.identify(@json([
                    'name' => auth()->user()->name,
                    'email' => auth()->user()->email,
                ])));
            </script>
        @endauth
    @endif
  4. Allow your domain and test

    Add your app’s address under Settings → Widget → Allowed origins in ChatMesh, load a page, send a test message and answer it from the Inbox.

The widget key is public by design: it only lets visitors start conversations, and only from the origins you allow. Keep API keys (cm_sk_…) on the server.

Laravel live chat FAQ

Is there a Composer package?

You don’t need one. The widget is a single script tag, so a few lines of Blade and configuration are all it takes.

Does it work with Inertia, Livewire or a single-page app?

Yes. Put the script in the root Blade view that every page uses. It loads once and stays open while users move between pages.

My app sends a Content Security Policy. What do I allow?

Allow the widget’s origin in script-src and connect-src (including wss:// for real-time messages), and in img-src if your agents have profile pictures. The widget script is served from https://chatmesh.ascend-digital.co.uk/widget.js.

Can I connect my Laravel app to tickets on the server side?

Yes. Create an API key in the portal and call the REST API or receive signed webhooks to create notes, update tickets or sync customer data.

Using another platform? See the guides for WordPress, Shopify and plain HTML, Next.js and React.