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.
| Property | Type | Description |
|---|
| agentId | String? | The identifier of the agent handling this conversation |
| conversationId | UUID | Unique identifier for this conversation instance |
| conversationState | Published.Publisher | Publisher providing real-time conversation state updates |
| messages | Published<[AgentforceMessage]>.Publisher | Publisher providing access to the complete conversation message history |
| sessionId | String? | The unique session identifier for this conversation |
| hasEnded | Bool | Indicates whether the conversation has been explicitly ended by the user |
| isHumanAgentMode | Bool | Indicates whether the conversation is with a human agent |
| statusEvents | AnyPublisher<AgentforceEvent, Never> | Publisher for status events (typing indicators, etc.) |
| systemEvents | AnyPublisher<AgentforceEvent, Never> | Publisher for system events (participant changes, escalations, etc.) |
| deliveryStatusEvents | AnyPublisher<MessageDeliveryStatusEvent, Never> | Publisher for delivery status events |
| Method | Signature | Description |
|---|
| sendUtterance | func sendUtterance(utterance: String, attachment: AgentforceAttachment?) async | Sends a user message to the agent with optional file attachments |
| setAdditionalContext | func setAdditionalContext(context: [AgentforceVariable]) | Updates the conversation context with additional variables that inform agent responses |
| closeConversation | func closeConversation() async throws | Closes the current conversation session and clears the session ID to prevent resumption |
| endConversation | func endConversation() async throws | Ends the current conversation session |
| reset | func reset() async throws | Removes all messages from the conversation |
| recommendedUtterances | func recommendedUtterances() async throws -> [String] | Manually retrieve recommended utterances (fetches fresh data) |
| updateRecommendedUtterances | func updateRecommendedUtterances(recommendations: [String]) | Updates the conversation with recommended utterances for quick user interaction |
| downloadTranscript | func downloadTranscript() async throws -> TranscriptResponse | Downloads a PDF transcript of the current conversation |