ChatThread
public struct ChatThread : Identifiable, Sendable
All information about a chat thread as well as the messages for the thread.
-
The unique id of the thread. Refers to the
idOnExternalPlatform.The canonical, case-preserving identifier of the thread as provided by the backend. Stores the exact value from the backend, without altering case.
Declaration
Swift
public let id: String -
The name given to the thread (for multi-thread channels only).
Declaration
Swift
public let name: String? -
The list of messages on the thread.
Declaration
Swift
public let messages: [Message] -
The agent assigned in the thread.
Declaration
Swift
public let assignedAgent: Agent? -
The last agent that has been assigned to the thread
This attribute can be used to get the previously assigned agent back to the thread after unassignment.
Declaration
Swift
public let lastAssignedAgent: Agent? -
The agent that owns the case — the last agent it was actually assigned to.
Unlike
assignedAgent(the inbox assignee, i.e. who currently has the case open), the owner persists across unassignment. It is populated from the backend on thread recovery and is used to determine that the customer has already been engaged by an agent (and is therefore no longer in the queue).Declaration
Swift
public let ownerAssignee: Agent? -
The identifier of the contact associated with this thread, as provided by the backend.
May be
nilwhen the thread has no associated contact yet — for example, a thread constructed locally before the SDK has populated it. This value is read-only: it is supplied by the SDK and cannot be set when constructing aChatThreaddirectly.Declaration
Swift
public let contactId: String? -
The token for the scroll position used to load more messages.
Declaration
Swift
public let scrollToken: String -
The thread state
Declaration
Swift
public let state: ChatThreadState -
Whether there are more messages to load in the thread.
Declaration
Swift
public var hasMoreMessagesToLoad: Bool { get } -
The position in the queue
Declaration
Swift
public let positionInQueue: Int? -
The party currently responsible for handling the contact behind this thread.
While an automated bot holds the contact, the customer is not queued for a human agent, so there is no position in queue to report. Once the bot hands the conversation over, this becomes
cxoneand the regular routing rules apply again.nilwhen the platform reports no handler for the channel, in which case the thread behaves exactly as it did before handlers existed.Declaration
Swift
public let contactHandler: ContactHandler?
-
init(id:state: name: messages: assignedAgent: lastAssignedAgent: ownerAssignee: scrollToken: positionInQueue: contactHandler: ) Creates a
ChatThreadvalue, typically when synthesising threads for tests, previews, or seeding state.Production code receives
ChatThreadinstances from the SDK via thethreadsprovider and thethreadUpdated(_:)/threadsUpdated(_:)events — direct construction is rarely needed.Declaration
Swift
public init( id: String, state: ChatThreadState, name: String? = nil, messages: [Message] = [], assignedAgent: Agent? = nil, lastAssignedAgent: Agent? = nil, ownerAssignee: Agent? = nil, scrollToken: String = "", positionInQueue: Int? = nil, contactHandler: ContactHandler? = nil )Parameters
idThe backend-canonical thread identifier (
idOnExternalPlatform).stateThe current state of the thread.
nameDisplay name (multi-thread channels only).
messagesThe known messages on the thread.
assignedAgentCurrently assigned agent, if any.
lastAssignedAgentPreviously assigned agent, useful for re-assignment flows.
ownerAssigneeThe agent that owns the case, persisted across unassignment.
scrollTokenCursor for paging older messages; empty means no more history.
positionInQueuePosition in queue for live-chat scenarios.
contactHandlerThe party currently handling the contact, when the platform reports one.
View on GitHub