---
schema_version: "1"
id: fbddfedb9d357826648d5995c6f5875c886969cc85eed5ce8cd92b5d8176b1ca
title: AgentforceClient
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/genai/agentforce-mobile-sdk/references/ios/agentforce-client-ios.md
canonical_url: https://developer.salesforce.com/docs/ai/agentforce-mobile-sdk/references/agentforce-mobile-sdk/agentforce-client-ios.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 220702f6698b36952bdb7af867ae3acde36330d117c782d2061665b2582fc6db
products:
  - Agentforce Mobile SDK
  - Agentforce and Einstein Generative AI
---
# AgentforceClient

## 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

```swift
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

```swift
let client = AgentforceClient(
    credentialProvider: myCredentialProvider,
    agentforceConfiguration: myConfiguration
)
```

```swift
// 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 */ }
)
```
