Skip to content
dimmiDocs

SDKs

Laravel SDK

Install dimmi/dimmi-laravel for Blade messenger rendering, automatic identity signing, the Dimmi facade, and webhook routes.

dimmi/dimmi-laravel supports Laravel 10, 11, and 12 on PHP 8.2+ and includes the PHP SDK.

Terminal window
composer require dimmi/dimmi-laravel
php artisan dimmi:install

dimmi:install publishes config/dimmi.php and adds these keys to .env and .env.example:

.env
DIMMI_BASE_URL=https://trydimmi.com
DIMMI_TOKEN=<api_token>
DIMMI_WORKSPACE=
DIMMI_APP_ID=wgt_<app_id>
DIMMI_IDENTITY_SECRET=dmi_idsec_<secret>
DIMMI_IDENTITY_KID=isk_<key_id>
DIMMI_WEBHOOK_SECRET=whsec_<secret>
Environment key Purpose
DIMMI_BASE_URL Your dimmi URL (change when self-hosting).
DIMMI_TOKEN Your API token.
DIMMI_WORKSPACE Leave blank; tokens already scope to their workspace.
DIMMI_APP_ID Messenger app ID (wgt_...) from Settings → Messengers.
DIMMI_IDENTITY_SECRET, DIMMI_IDENTITY_KID Secret from identity verification.
DIMMI_WEBHOOK_SECRET Signing secret for your webhook endpoint.

Run php artisan dimmi:test to verify your config. It checks API connectivity, signs a sample identity token, and exits non-zero if anything fails.

resources/views/layouts/app.blade.php
@dimmiMessenger
</body>

@dimmiMessenger signs an identity token for auth()->user() automatically and falls back to anonymous chat for guests. By default it sends the user’s id, email, name, email_verified_at, and created_at.

Goal Config setting
Send extra user attributes 'user' => ['attributes' => ['plan', 'team_name' => 'team.name']] in config/dimmi.php
Build a custom identity payload 'user' => ['resolver' => App\Support\DimmiIdentity::class] (invokable class returning an array)
Fetch tokens from built-in GET /dimmi/token DIMMI_MESSENGER_IDENTITY=url

Use the Dimmi facade to call any method from the PHP SDK:

app/Listeners/SyncCustomer.php
<?php
namespace App\Listeners;
use Dimmi\Laravel\Facades\Dimmi;
use Illuminate\Auth\Events\Registered;
class SyncCustomer
{
public function handle(Registered $event): void
{
Dimmi::contacts()->store([
'email' => $event->user->email,
'external_id' => (string) $event->user->id,
]);
}
}

Add Route::dimmiWebhooks('webhooks/dimmi') in routes/web.php. The route verifies every signature, rejects unsigned requests with 400, and dispatches two Laravel events:

  • Dimmi\Laravel\Events\DimmiWebhookReceived: fires on every webhook, with the parsed event on $received->event.
  • dimmi.webhook.<type>: fires per event type (such as dimmi.webhook.conversation.created) with a Dimmi\WebhookEvent.

See Verify webhook signatures for a ready-to-paste event listener.