Configure the Agentforce SDK for React Native
Learn how to configure the Agentforce Mobile SDK for your React Native application. The SDK supports two modes: Service Agent for anonymous customer support, and Employee Agent for authenticated internal use.
The configure() method accepts a configuration object with a type field that determines the SDK's operating mode:
Both modes share organizationId and optional featureFlags. Other fields are specific to each mode.
Service Agent mode is for anonymous/guest access, typically for customer-facing support scenarios. No OAuth authentication is required.
| Field | Type | Required | Description |
|---|---|---|---|
type | 'service' | Yes | Must be 'service' |
serviceApiURL | string | Yes | The Service API URL for your deployment. Found in Setup > Embedded Service Deployments > Settings. Must be a valid URL (for example, https://your-site.salesforce.com). |
organizationId | string | Yes | Your Salesforce Organization ID. Found in Setup > Company Information. Can be 15 or 18 characters. |
esDeveloperName | string | Yes | The developer name of your Embedded Service deployment. Found in Setup > Embedded Service Deployments. |
featureFlags | FeatureFlags | No | Optional feature flags. If omitted, persisted flags (or defaults) are used. |
Employee Agent mode is for authenticated, internal-use scenarios. Users must be authenticated with a valid Salesforce OAuth token.
| Field | Type | Required | Description |
|---|---|---|---|
type | 'employee' | Yes | Must be 'employee' |
instanceUrl | string | Yes | Your Salesforce instance URL (for example, https://myorg.my.salesforce.com). |
organizationId | string | Yes | Salesforce Organization ID. |
userId | string | Yes | The Salesforce User ID of the authenticated user (for example, 005xx0000001234). |
agentId | string | No | The Agentforce Agent ID. If omitted and enableMultiAgent is true, the SDK picks the first available agent. |
agentLabel | string | No | A display label shown in the conversation UI title bar (Android). |
accessToken | string | No | OAuth access token. Can be provided directly or obtained via Mobile SDK auth. |
featureFlags | FeatureFlags | No | Optional feature flags. |
When using the Mobile SDK for authentication, obtain credentials first and then pass them to configure():
See Employee Agent Authentication for details on the Mobile SDK auth integration.
The agentId field determines which agent the conversation uses:
- If
agentIdis provided, the conversation starts with that specific agent. - If
agentIdis omitted andenableMultiAgentistrue(the default), the SDK bootstraps and picks the first available agent. - If
agentIdis omitted andenableMultiAgentisfalse, the conversation will likely fail. A warning is logged on both platforms.
You can read and write the agentId independently of configuration:
Platform Difference
On iOS, calling setEmployeeAgentId() with a different agent ID triggers an immediate conversation close and client cleanup. The new agent ID takes effect right away.
On Android, the method only persists the value. The change takes effect on the next configure() or launchConversation() call.
Feature flags control optional SDK capabilities. They can be provided inline with the config or set independently.
| Flag | Default | Description |
|---|---|---|
enableMultiAgent | true | When true and no agentId is specified, the SDK bootstraps and picks from available agents. When false, an agentId must be provided. |
enableMultiModalInput | false | Enables camera and image attachment capabilities in the conversation UI. Requires camera/photo permissions. |
enablePDFUpload | false | Enables PDF file upload in the conversation. |
enableVoice | false | Enables voice input (microphone) in the conversation UI. Requires microphone permission. |
enableCustomViewProvider | false | Enables the custom view provider system. When true and a ViewProviderDelegate is registered, the SDK delegates rendering of matched component types to your React Native components. |
Inline with configure():
Independently (persisted):
Changing feature flags via setFeatureFlags() does not take effect immediately. You must call configure() again (or restart the app) for changes to apply.
When configure() is called, feature flags are resolved in this order:
- If
featureFlagsis provided in theconfigure()call, those values are used. - If
featureFlagsis omitted, the bridge reads persisted flags from native storage. - If no persisted flags exist, hard-coded defaults are used (
enableMultiAgent: true, all othersfalse).
A typical configuration lifecycle:
- Set delegates (logger, navigation, view provider) - optional, but do before
configure() - Set hidden prechat fields - optional, Service Agent only, before launch
- Call
configure()- required - Check
isConfigured()- optional verification - Call
launchConversation()- opens UI - Call
setAdditionalContext()- optional, after launching - Call
closeConversation()orstartNewConversation()- as needed - Call
destroy()- on app shutdown
When switching between modes (for example, from Service to Employee), calling configure() again with a different type automatically cleans up the previous client and conversation.