Integrate Agentforce SDK
To use the SDK, be sure to import the Agentforce SDK package.
The Agentforce Mobile SDK has to make API calls back to your org to leverage the Agentforce Platform. In order to do so, it requires authenticated credentials, and delegates this responsibility to the app. A specific app might be using the Salesforce Mobile SDK to authenticate, or may have implemented their own OAuth client. The consuming app must implement the AgentforceAuthCredentialProviding
protocol and provide these credentials to the SDK.
AgentforceAuthCredentialProviding: Supplies the SDK with the authentication token required to communicate securely with Salesforce APIs.
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.
AgentforceClient
must be retained for the duration of the conversation. If it's deallocated, the session will be lost. Instantiate it in an object with an appropriate lifecycle for your needs.
Once you have initialized AgentforceClient
, you can start a conversation with an agent using the startAgentforceConversation
method, this method is slightly different depending on whether you're targeting a Service Agent or an Employee Agent. For guidance on getting values for the createAgentforceChatView
method, see Agent Type Setup.
This method returns an AgentConversation
object, which represents a single conversation with an agent. The AgentConversation
object can be used for headless or bring your own UI experiences, and is also the central input when using one of the built-in UIs.
- 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