Overview
The primary entry point and orchestrator for all Agentforce SDK functionality. It serves as the central coordinator that manages agent conversations, UI component creation, and service dependencies. It implements a comprehensive architecture that handles authentication, networking, theming, and extensibility through provider protocols.
Declaration
class AgentforceClient
Methods
| Method | Signature | Description |
|---|---|---|
| init | init(credentialProvider:mode:viewProvider:themeManager:) | Creates an AgentforceClient with full customization capabilities including view provider overrides |
| startAgentforceConversation(forAgentId:sessionId:) | func startAgentforceConversation(forAgentId: String?, sessionId: String?) -> AgentConversation | Initiates a new conversation session with an Agentforce agent |
| startAgentforceConversation(forESDeveloperName:) | func startAgentforceConversation(forESDeveloperName: String) -> AgentConversation | Initiates a new conversation session with a service agent using Einstein Service developer name |
| getExistingAgentforceConversation | func getExistingAgentforceConversation(forAgentId: String, sessionId: String?) -> AgentConversation? | Gets an existing Agentforce conversation that matches the specified criteria |
| createAgentforceChatView | func createAgentforceChatView(conversation:delegate:showTopBar:onContainerClose:) throws -> AgentforceChatView | Creates a fully-configured Agentforce chat interface for interactive dialogue |
| createAgentforceCard | func createAgentforceCard(chatView:launchChatView:) -> AgentforceCard | Creates a compact conversation summary card with follow-up interaction capabilities |
| createAgentforceLauncher | func createAgentforceLauncher(chatView:launchChatView:) -> AgentforceLauncher | Creates an Agentforce Launcher View |
| createAgentforceVoiceView | func createAgentforceVoiceView(conversation:voiceIcon:circleSizeRatio:onContainerClose:) throws -> AgentforceVoiceView | Creates an Agentforce Voice View for real-time voice interaction with visual feedback |
Usage Patterns
let client = AgentforceClient(
credentialProvider: myCredentialProvider,
agentforceConfiguration: myConfiguration
)
// 1. Start conversation
let conversation = client.startAgentforceConversation(forAgentId: "agent123", sessionId: nil)
// 2. Create chat interface
let chatView = try client.createAgentforceChatView(
conversation: conversation,
delegate: myUIDelegate,
onContainerClose: { /* handle close */ }
)
// 3. Create summary card (optional)
let card = client.createAgentforceCard(
chatView: chatView,
launchChatView: { /* handle launch */ }
)
// 4.
let voiceView = try client.createAgentforceVoiceView(
conversation: conversation,
circleSizeRatio: 0.4,
onContainerClose: { /* close the voice view and open the associated chat view */ }
)