Extension and action examples
Use the action functions with records and Data objects supplied by your application. They pass each argument to the package operation and return its result.
These adapters show container registration. Use the owning package registry when a contract requires contributor discovery.
Contract adapters wrap an existing implementation. Call their registration function from your service provider with that implementation; tagged contracts keep their declared tag. Resolve the backend by its concrete class before registration so the replacement contract does not resolve itself. Static contract metadata uses one backend class per adapter.
Contract Capell\LiveChat\Contracts\LiveChatKnowledgeProvider
Section titled “Contract Capell\LiveChat\Contracts\LiveChatKnowledgeProvider”<?phpdeclare(strict_types=1);
namespace App\CapellExamples\LiveChat;
final class LiveChatKnowledgeProviderAdapter implements \Capell\LiveChat\Contracts\LiveChatKnowledgeProvider{ public function __construct(private readonly \Capell\LiveChat\Contracts\LiveChatKnowledgeProvider $backend) {}
#[\Override] public function documents(\Capell\LiveChat\Models\LiveChatConversation $conversation, \Capell\LiveChat\Models\LiveChatMessage $message): array { return $this->backend->documents($conversation, $message); }}
function registerLiveChatKnowledgeProviderAdapter(\Capell\LiveChat\Contracts\LiveChatKnowledgeProvider $backend): void{ app()->bind(LiveChatKnowledgeProviderAdapter::class, static fn (): LiveChatKnowledgeProviderAdapter => new LiveChatKnowledgeProviderAdapter($backend)); app()->bind(\Capell\LiveChat\Contracts\LiveChatKnowledgeProvider::class, LiveChatKnowledgeProviderAdapter::class); app()->tag([LiveChatKnowledgeProviderAdapter::class], \Capell\LiveChat\Contracts\LiveChatKnowledgeProvider::TAG);}Contract Capell\LiveChat\Contracts\LiveChatResponder
Section titled “Contract Capell\LiveChat\Contracts\LiveChatResponder”<?phpdeclare(strict_types=1);
namespace App\CapellExamples\LiveChat;
final class LiveChatResponderAdapter implements \Capell\LiveChat\Contracts\LiveChatResponder{ public function __construct(private readonly \Capell\LiveChat\Contracts\LiveChatResponder $backend) {}
#[\Override] public function respond(\Capell\LiveChat\Models\LiveChatConversation $conversation, \Capell\LiveChat\Models\LiveChatMessage $message): \Capell\LiveChat\Data\LiveChatResponseData { return $this->backend->respond($conversation, $message); }}
function registerLiveChatResponderAdapter(\Capell\LiveChat\Contracts\LiveChatResponder $backend): void{ app()->bind(LiveChatResponderAdapter::class, static fn (): LiveChatResponderAdapter => new LiveChatResponderAdapter($backend)); app()->bind(\Capell\LiveChat\Contracts\LiveChatResponder::class, LiveChatResponderAdapter::class);}Contract Capell\LiveChat\Contracts\LiveChatWidgetRenderer
Section titled “Contract Capell\LiveChat\Contracts\LiveChatWidgetRenderer”<?phpdeclare(strict_types=1);
namespace App\CapellExamples\LiveChat;
final class LiveChatWidgetRendererAdapter implements \Capell\LiveChat\Contracts\LiveChatWidgetRenderer{ public function __construct(private readonly \Capell\LiveChat\Contracts\LiveChatWidgetRenderer $backend) {}
#[\Override] public function render(): \Symfony\Component\HttpFoundation\Response { return $this->backend->render(); }}
function registerLiveChatWidgetRendererAdapter(\Capell\LiveChat\Contracts\LiveChatWidgetRenderer $backend): void{ app()->bind(LiveChatWidgetRendererAdapter::class, static fn (): LiveChatWidgetRendererAdapter => new LiveChatWidgetRendererAdapter($backend)); app()->bind(\Capell\LiveChat\Contracts\LiveChatWidgetRenderer::class, LiveChatWidgetRendererAdapter::class);}Action buildLiveChatAnalytics
Section titled “Action buildLiveChatAnalytics”<?phpdeclare(strict_types=1);
namespace App\CapellExamples\LiveChat;
function runBuildLiveChatAnalytics(int $siteId, ?int $installationId = null): array{ return \Capell\LiveChat\Actions\BuildLiveChatAnalyticsAction::run($siteId, $installationId);}Action buildLiveChatOperatorState
Section titled “Action buildLiveChatOperatorState”<?phpdeclare(strict_types=1);
namespace App\CapellExamples\LiveChat;
function runBuildLiveChatOperatorState(\Capell\LiveChat\Models\LiveChatConversation $conversation): array{ return \Capell\LiveChat\Actions\BuildLiveChatOperatorStateAction::run($conversation);}Action buildLiveChatSuggestedReply
Section titled “Action buildLiveChatSuggestedReply”<?phpdeclare(strict_types=1);
namespace App\CapellExamples\LiveChat;
function runBuildLiveChatSuggestedReply(\Capell\LiveChat\Models\LiveChatConversation $conversation, ?array $state = null): string{ return \Capell\LiveChat\Actions\BuildLiveChatSuggestedReplyAction::run($conversation, $state);}Action buildLiveChatTranscript
Section titled “Action buildLiveChatTranscript”<?phpdeclare(strict_types=1);
namespace App\CapellExamples\LiveChat;
function runBuildLiveChatTranscript(\Capell\LiveChat\Models\LiveChatConversation $conversation): array{ return \Capell\LiveChat\Actions\BuildLiveChatTranscriptAction::run($conversation);}Action buildLiveChatWidgetConfig
Section titled “Action buildLiveChatWidgetConfig”<?phpdeclare(strict_types=1);
namespace App\CapellExamples\LiveChat;
function runBuildLiveChatWidgetConfig(?\Capell\LiveChat\Models\LiveChatInstallation $installation = null): \Capell\LiveChat\Data\LiveChatWidgetConfigData{ return \Capell\LiveChat\Actions\BuildLiveChatWidgetConfigAction::run($installation);}Action closeLiveChatConversation
Section titled “Action closeLiveChatConversation”<?phpdeclare(strict_types=1);
namespace App\CapellExamples\LiveChat;
function runCloseLiveChatConversation(\Capell\LiveChat\Models\LiveChatConversation $conversation): \Capell\LiveChat\Models\LiveChatConversation{ return \Capell\LiveChat\Actions\CloseLiveChatConversationAction::run($conversation);}Action detectLiveChatIntent
Section titled “Action detectLiveChatIntent”<?phpdeclare(strict_types=1);
namespace App\CapellExamples\LiveChat;
function runDetectLiveChatIntent(string $message): \Capell\LiveChat\Enums\LiveChatIntent{ return \Capell\LiveChat\Actions\DetectLiveChatIntentAction::run($message);}Action determineLiveChatEscalation
Section titled “Action determineLiveChatEscalation”<?phpdeclare(strict_types=1);
namespace App\CapellExamples\LiveChat;
function runDetermineLiveChatEscalation(\Capell\LiveChat\Models\LiveChatConversation $conversation, \Capell\LiveChat\Models\LiveChatMessage $message, \Capell\LiveChat\Data\LiveChatResponseData $response, bool $available): \Capell\LiveChat\Data\LiveChatEscalationDecisionData{ return \Capell\LiveChat\Actions\DetermineLiveChatEscalationAction::run($conversation, $message, $response, $available);}Action generateLiveChatSummary
Section titled “Action generateLiveChatSummary”<?phpdeclare(strict_types=1);
namespace App\CapellExamples\LiveChat;
function runGenerateLiveChatSummary(\Capell\LiveChat\Models\LiveChatConversation $conversation): array{ return \Capell\LiveChat\Actions\GenerateLiveChatSummaryAction::run($conversation);}Action guardLiveChatInstallationOrigin
Section titled “Action guardLiveChatInstallationOrigin”<?phpdeclare(strict_types=1);
namespace App\CapellExamples\LiveChat;
function runGuardLiveChatInstallationOrigin(\Capell\LiveChat\Models\LiveChatInstallation $installation, \Illuminate\Http\Request $request): string{ return \Capell\LiveChat\Actions\GuardLiveChatInstallationOriginAction::run($installation, $request);}Action guardLiveChatSameSiteRequest
Section titled “Action guardLiveChatSameSiteRequest”<?phpdeclare(strict_types=1);
namespace App\CapellExamples\LiveChat;
function runGuardLiveChatSameSiteRequest(\Capell\LiveChat\Models\LiveChatInstallation $installation, \Illuminate\Http\Request $request): void{ \Capell\LiveChat\Actions\GuardLiveChatSameSiteRequestAction::run($installation, $request);}Action indexLiveChatKnowledgeDocument
Section titled “Action indexLiveChatKnowledgeDocument”<?phpdeclare(strict_types=1);
namespace App\CapellExamples\LiveChat;
function runIndexLiveChatKnowledgeDocument(\Capell\LiveChat\Data\LiveChatKnowledgeDocumentData $data): \Capell\LiveChat\Models\LiveChatKnowledgeDocument{ return \Capell\LiveChat\Actions\IndexLiveChatKnowledgeDocumentAction::run($data);}Action indexLiveChatKnowledgeSource
Section titled “Action indexLiveChatKnowledgeSource”<?phpdeclare(strict_types=1);
namespace App\CapellExamples\LiveChat;
function runIndexLiveChatKnowledgeSource(\Capell\LiveChat\Models\LiveChatKnowledgeSource $source, ?int $installationId = null): ?\Capell\LiveChat\Models\LiveChatKnowledgeDocument{ return \Capell\LiveChat\Actions\IndexLiveChatKnowledgeSourceAction::run($source, $installationId);}Action recordLiveChatAIRun
Section titled “Action recordLiveChatAIRun”<?phpdeclare(strict_types=1);
namespace App\CapellExamples\LiveChat;
function runRecordLiveChatAIRun(\Capell\LiveChat\Data\LiveChatAIRunData $data): \Capell\LiveChat\Models\LiveChatAIRun{ return \Capell\LiveChat\Actions\RecordLiveChatAIRunAction::run($data);}Action recordLiveChatKnowledgeGap
Section titled “Action recordLiveChatKnowledgeGap”<?phpdeclare(strict_types=1);
namespace App\CapellExamples\LiveChat;
function runRecordLiveChatKnowledgeGap(string $question, ?int $installationId = null, ?int $conversationId = null, ?int $messageId = null, ?string $sourceArea = null, array $metadata = []): \Capell\LiveChat\Models\LiveChatKnowledgeGap{ return \Capell\LiveChat\Actions\RecordLiveChatKnowledgeGapAction::run($question, $installationId, $conversationId, $messageId, $sourceArea, $metadata);}Action replyToLiveChatMessage
Section titled “Action replyToLiveChatMessage”<?phpdeclare(strict_types=1);
namespace App\CapellExamples\LiveChat;
function runReplyToLiveChatMessage(\Capell\LiveChat\Models\LiveChatConversation $conversation, \Capell\LiveChat\Models\LiveChatMessage $message): \Capell\LiveChat\Models\LiveChatMessage{ return \Capell\LiveChat\Actions\ReplyToLiveChatMessageAction::run($conversation, $message);}Action requestLiveChatHandoff
Section titled “Action requestLiveChatHandoff”<?phpdeclare(strict_types=1);
namespace App\CapellExamples\LiveChat;
function runRequestLiveChatHandoff(\Capell\LiveChat\Models\LiveChatConversation $conversation, ?string $note = null): \Capell\LiveChat\Models\LiveChatConversation{ return \Capell\LiveChat\Actions\RequestLiveChatHandoffAction::run($conversation, $note);}Action resolveLiveChatAvailability
Section titled “Action resolveLiveChatAvailability”<?phpdeclare(strict_types=1);
namespace App\CapellExamples\LiveChat;
function runResolveLiveChatAvailability(int $siteId, ?\Carbon\CarbonImmutable $at = null, ?string $timezone = null): \Capell\LiveChat\Data\LiveChatAvailabilityData{ return \Capell\LiveChat\Actions\ResolveLiveChatAvailabilityAction::run($siteId, $at, $timezone);}Action resolveLiveChatConversationForInstallation
Section titled “Action resolveLiveChatConversationForInstallation”<?phpdeclare(strict_types=1);
namespace App\CapellExamples\LiveChat;
function runResolveLiveChatConversationForInstallation(\Capell\LiveChat\Models\LiveChatInstallation $installation, string $uuid, ?string $visitorToken): \Capell\LiveChat\Models\LiveChatConversation{ return \Capell\LiveChat\Actions\ResolveLiveChatConversationForInstallationAction::run($installation, $uuid, $visitorToken);}Action resolveLiveChatInstallation
Section titled “Action resolveLiveChatInstallation”<?phpdeclare(strict_types=1);
namespace App\CapellExamples\LiveChat;
function runResolveLiveChatInstallation(?string $publicKey = null, ?int $siteId = null): ?\Capell\LiveChat\Models\LiveChatInstallation{ return \Capell\LiveChat\Actions\ResolveLiveChatInstallationAction::run($publicKey, $siteId);}Action searchLiveChatKnowledgeDocuments
Section titled “Action searchLiveChatKnowledgeDocuments”<?phpdeclare(strict_types=1);
namespace App\CapellExamples\LiveChat;
function runSearchLiveChatKnowledgeDocuments(\Capell\LiveChat\Models\LiveChatConversation $conversation, \Capell\LiveChat\Models\LiveChatMessage $message, int $limit = 3): array{ return \Capell\LiveChat\Actions\SearchLiveChatKnowledgeDocumentsAction::run($conversation, $message, $limit);}Action startLiveChatConversation
Section titled “Action startLiveChatConversation”<?phpdeclare(strict_types=1);
namespace App\CapellExamples\LiveChat;
function runStartLiveChatConversation(\Capell\LiveChat\Data\IncomingLiveChatMessageData $data, int $siteId, ?\Capell\LiveChat\Models\LiveChatInstallation $installation = null): array{ return \Capell\LiveChat\Actions\StartLiveChatConversationAction::run($data, $siteId, $installation);}Action storeLiveChatAttachments
Section titled “Action storeLiveChatAttachments”<?phpdeclare(strict_types=1);
namespace App\CapellExamples\LiveChat;
function runStoreLiveChatAttachments(array $files, string $conversationUuid): array{ return \Capell\LiveChat\Actions\StoreLiveChatAttachmentsAction::run($files, $conversationUuid);}Action storeLiveChatMessage
Section titled “Action storeLiveChatMessage”<?phpdeclare(strict_types=1);
namespace App\CapellExamples\LiveChat;
function runStoreLiveChatMessage(\Capell\LiveChat\Models\LiveChatConversation $conversation, \Capell\LiveChat\Data\IncomingLiveChatMessageData $data): array{ return \Capell\LiveChat\Actions\StoreLiveChatMessageAction::run($conversation, $data);}Action suggestLiveChatHumanReply
Section titled “Action suggestLiveChatHumanReply”<?phpdeclare(strict_types=1);
namespace App\CapellExamples\LiveChat;
function runSuggestLiveChatHumanReply(\Capell\LiveChat\Models\LiveChatConversation $conversation): array{ return \Capell\LiveChat\Actions\SuggestLiveChatHumanReplyAction::run($conversation);}Action syncLiveChatConversationContact
Section titled “Action syncLiveChatConversationContact”<?phpdeclare(strict_types=1);
namespace App\CapellExamples\LiveChat;
function runSyncLiveChatConversationContact(\Capell\LiveChat\Models\LiveChatConversation $conversation, ?string $leadTitle = null): ?\Capell\Contacts\Data\ContactSourceSyncResultData{ return \Capell\LiveChat\Actions\SyncLiveChatConversationContactAction::run($conversation, $leadTitle);}