Integrate Agentforce SDK
To use the SDK, be sure to import the Agentforce SDK packages.
The Agentforce Mobile SDK is designed for flexibility and delegates several core responsibilities to the host application. You must create concrete implementations for the following interfaces:
- AgentforceAuthCredentialProvider: Supplies the SDK with the authentication token (e.g., OAuth 2.0 access token) required to communicate securely with Salesforce APIs.
- AgentforceInstrumentation: A handler for the SDK to emit instrumentation and telemetry data into your app's analytics system.
For authentication, create a credential provider using one of the supported authentication methods.
Related links:
- Salesforce Mobile SDK Developer Guide: OAuth 2.0 Authentication Flow
- Salesforce Help: JWT-Based Access Tokens
In order to use the Agentforce SDK you must first identify the agent type you are targeting: Employee Agent or Service Agent. A single app may target each, but requires configuration and instantiation of separate Agentforce clients. To learn more, see Create an Agent from a Template in Salesforce Help.
For guidance on gathering information for the agent configuration object, see Agent Type Setup in Before You Begin.
The following snippets illustrate how to configure your agent for each agent type.
Create and retain an instance of AgentforceClient
. It's best to hold this in a lifecycle-aware component, like a ViewModel
, to ensure the conversation state persists across configuration changes.
Once you've initialized the AgentforceClient
, you can start a conversation with an agent using the startAgentforceConversation
method.
This method returns an AgentforceConversation
object, which represents a single conversation with an agent.
- Prebuilt UI: See Use Prebuilt UI for ready-to-use chat interface
- Headless: See Build a Headless Experience for custom UI implementation
- Customization: See Branding and Theming for visual customization