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.
composer require dimmi/dimmi-laravelphp artisan dimmi:installdimmi:install publishes config/dimmi.php and adds these keys to .env and .env.example:
DIMMI_BASE_URL=https://trydimmi.comDIMMI_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.
Render the messenger in Blade
Section titled “Render the messenger in Blade” @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 |
Call the REST API
Section titled “Call the REST API”Use the Dimmi facade to call any method from the PHP SDK:
<?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, ]); }}Receive webhooks
Section titled “Receive webhooks”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 asdimmi.webhook.conversation.created) with aDimmi\WebhookEvent.
See Verify webhook signatures for a ready-to-paste event listener.