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.

FieldTypeRequiredDescription
type'service'YesMust be 'service'
serviceApiURLstringYesThe 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).
organizationIdstringYesYour Salesforce Organization ID. Found in Setup > Company Information. Can be 15 or 18 characters.
esDeveloperNamestringYesThe developer name of your Embedded Service deployment. Found in Setup > Embedded Service Deployments.
featureFlagsFeatureFlagsNoOptional 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.

FieldTypeRequiredDescription
type'employee'YesMust be 'employee'
instanceUrlstringYesYour Salesforce instance URL (for example, https://myorg.my.salesforce.com).
organizationIdstringYesSalesforce Organization ID.
userIdstringYesThe Salesforce User ID of the authenticated user (for example, 005xx0000001234).
agentIdstringNoThe Agentforce Agent ID. If omitted and enableMultiAgent is true, the SDK picks the first available agent.
agentLabelstringNoA display label shown in the conversation UI title bar (Android).
accessTokenstringNoOAuth access token. Can be provided directly or obtained via Mobile SDK auth.
featureFlagsFeatureFlagsNoOptional 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 agentId is provided, the conversation starts with that specific agent.
  • If agentId is omitted and enableMultiAgent is true (the default), the SDK bootstraps and picks the first available agent.
  • If agentId is omitted and enableMultiAgent is false, 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.

FlagDefaultDescription
enableMultiAgenttrueWhen true and no agentId is specified, the SDK bootstraps and picks from available agents. When false, an agentId must be provided.
enableMultiModalInputfalseEnables camera and image attachment capabilities in the conversation UI. Requires camera/photo permissions.
enablePDFUploadfalseEnables PDF file upload in the conversation.
enableVoicefalseEnables voice input (microphone) in the conversation UI. Requires microphone permission.
enableCustomViewProviderfalseEnables 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:

  1. If featureFlags is provided in the configure() call, those values are used.
  2. If featureFlags is omitted, the bridge reads persisted flags from native storage.
  3. If no persisted flags exist, hard-coded defaults are used (enableMultiAgent: true, all others false).

A typical configuration lifecycle:

  1. Set delegates (logger, navigation, view provider) - optional, but do before configure()
  2. Set hidden prechat fields - optional, Service Agent only, before launch
  3. Call configure() - required
  4. Check isConfigured() - optional verification
  5. Call launchConversation() - opens UI
  6. Call setAdditionalContext() - optional, after launching
  7. Call closeConversation() or startNewConversation() - as needed
  8. 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.