Documentation

CustomerChatSession extends Model
in package
uses HasFactory

Table of Contents

Properties

$contact_id  : int|null
$created_at  : Carbon
$id  : string
$incrementing  : mixed
$messages  : array<string|int, mixed>
$metadata  : array<string|int, mixed>|null
$qualified  : bool
$updated_at  : Carbon
$visitor_id  : string
$attributes  : mixed
$casts  : mixed
$fillable  : mixed
$keyType  : mixed

Methods

addAssistantMessage()  : self
Add an assistant message.
addMessage()  : self
Add a message to the conversation.
addUserMessage()  : self
Add a user message.
contact()  : BelongsTo
Get the contact associated with this chat session.
findOrCreateByVisitorId()  : self
Find or create a session by visitor ID.
getConversationForAgent()  : array<string|int, mixed>
Get the conversation history formatted for the AI agent.
getRecentForVisitor()  : Collection
Get recent sessions for a visitor.
markAsQualified()  : self
Mark this session as having a qualified lead.
booting()  : mixed

Properties

$attributes

protected mixed $attributes = ['messages' => '[]', 'qualified' => false]

$casts

protected mixed $casts = ['messages' => 'array', 'metadata' => 'array', 'qualified' => 'boolean']

$fillable

protected mixed $fillable = ['id', 'visitor_id', 'contact_id', 'messages', 'qualified', 'metadata']

Methods

addAssistantMessage()

Add an assistant message.

public addAssistantMessage(string $content) : self
Parameters
$content : string
Return values
self

addMessage()

Add a message to the conversation.

public addMessage(string $role, string $content) : self
Parameters
$role : string
$content : string
Return values
self

addUserMessage()

Add a user message.

public addUserMessage(string $content) : self
Parameters
$content : string
Return values
self

contact()

Get the contact associated with this chat session.

public contact() : BelongsTo
Return values
BelongsTo

findOrCreateByVisitorId()

Find or create a session by visitor ID.

public static findOrCreateByVisitorId(string $visitorId[, array<string|int, mixed> $metadata = [] ]) : self
Parameters
$visitorId : string
$metadata : array<string|int, mixed> = []
Return values
self

getConversationForAgent()

Get the conversation history formatted for the AI agent.

public getConversationForAgent() : array<string|int, mixed>
Return values
array<string|int, mixed>

getRecentForVisitor()

Get recent sessions for a visitor.

public static getRecentForVisitor(string $visitorId[, int $limit = 10 ]) : Collection
Parameters
$visitorId : string
$limit : int = 10
Return values
Collection

markAsQualified()

Mark this session as having a qualified lead.

public markAsQualified() : self
Return values
self

        
On this page

Search results