AgentforceConversation

Concrete implementation of the AgentConversation protocol providing full conversation management capabilities. It orchestrates all aspects of a conversation session including service communication, state management, message processing, and context handling. This class serves as the primary interface between application code and the underlying Agentforce service infrastructure.

PropertyTypeDescription
agentIdString?The identifier of the agent handling this conversation
conversationIdUUIDUnique identifier for this conversation instance
conversationStatePublished.PublisherPublisher providing real-time conversation state updates
messagesPublished<[AgentforceMessage]>.PublisherPublisher providing access to the complete conversation message history
sessionIdString?The unique session identifier for this conversation
hasEndedBoolIndicates whether the conversation has been explicitly ended by the user
isHumanAgentModeBoolIndicates whether the conversation is with a human agent
statusEventsAnyPublisher<AgentforceEvent, Never>Publisher for status events (typing indicators, etc.)
systemEventsAnyPublisher<AgentforceEvent, Never>Publisher for system events (participant changes, escalations, etc.)
deliveryStatusEventsAnyPublisher<MessageDeliveryStatusEvent, Never>Publisher for delivery status events
MethodSignatureDescription
sendUtterancefunc sendUtterance(utterance: String, attachment: AgentforceAttachment?) asyncSends a user message to the agent with optional file attachments
setAdditionalContextfunc setAdditionalContext(context: [AgentforceVariable])Updates the conversation context with additional variables that inform agent responses
closeConversationfunc closeConversation() async throwsCloses the current conversation session and clears the session ID to prevent resumption
endConversationfunc endConversation() async throwsEnds the current conversation session
resetfunc reset() async throwsRemoves all messages from the conversation
recommendedUtterancesfunc recommendedUtterances() async throws -> [String]Manually retrieve recommended utterances (fetches fresh data)
updateRecommendedUtterancesfunc updateRecommendedUtterances(recommendations: [String])Updates the conversation with recommended utterances for quick user interaction
downloadTranscriptfunc downloadTranscript() async throws -> TranscriptResponseDownloads a PDF transcript of the current conversation