React Native Development

This section provides reference documentation for the Agentforce Mobile SDK for React Native.

Overview

The Agentforce Mobile SDK for React Native is a bridge to the native iOS and Android SDKs, providing a JavaScript API to configure and launch Agentforce conversations. Import the SDK as:

import { AgentforceService } from "@salesforce/react-native-agentforce";

AgentforceService is a singleton instance. All methods are called directly on this object.

Reference Topics

AgentforceService Methods

All methods are available on the AgentforceService singleton.

Configuration Methods

Method Description
configure(config) Configure the SDK with Service or Employee Agent settings
isConfigured() Check if the SDK is configured and ready
getConfigurationInfo() Get detailed configuration information including mode

Conversation Methods

Method Description
launchConversation() Open the conversation UI (preserves existing conversation)
startNewConversation() Close existing conversation and start fresh
closeConversation() Close the current conversation and dismiss UI

Delegate Methods

Method Description
setLoggerDelegate(delegate) Register a logger delegate for SDK log messages
clearLoggerDelegate() Remove the logger delegate
setNavigationDelegate(delegate) Register a navigation delegate
clearNavigationDelegate() Remove the navigation delegate
setViewProviderDelegate(delegate) Register a view provider delegate
clearViewProviderDelegate() Clear the view provider delegate

Context and Prechat Methods

Method Description
setAdditionalContext(context) Set additional context for the current conversation
registerHiddenPreChatFields(fields) Pre-register hidden prechat field values
clearHiddenPreChatFields() Clear all hidden prechat fields
getHiddenPreChatFields() Get currently registered hidden prechat fields

Feature Flags and Settings Methods

Method Description
getFeatureFlags() Read persisted feature flags from native storage
setFeatureFlags(flags) Save feature flags to native storage
getEmployeeAgentId() Get the stored Employee Agent ID
setEmployeeAgentId(agentId) Set the Employee Agent ID in native storage
resetSettings() Clear all SDK state

Lifecycle Methods

Method Description
destroy() Clean up all resources (call on app shutdown)

Related Guides