A lightweight React Native sample application demonstrating Service Agent integration with Salesforce Agentforce SDK for both iOS and Android.
This sample app demonstrates how to integrate the Agentforce Mobile SDK with Service Agents in your React Native applications for both iOS and Android.
The Agentforce Mobile SDK empowers you to integrate Salesforce's trusted AI platform directly into your mobile applications. Service Agents provide AI-powered conversational experiences for customer support scenarios.
- Service Agent Configuration - Configure and initialize the SDK with Service Agent settings
- Employee Agent Configuration - The bridge layer supports conversion to an Employee Agent configuration
- Full UI Experience - Use the pre-built chat interface provided by the Agentforce SDK
- Cross-Platform - Single codebase for both iOS and Android with native SDK integration
- Persistent Configuration - Settings are saved and restored automatically
- Conversation Continuity - Conversations persist across app launches
This app uses the AgentforceSDK-ReactNative-Bridge (in-repo under AgentforceSDK-ReactNative-Bridge/) for all Agentforce functionality. The app has no separate in-repo Agentforce native code; the bridge provides the JS API and native modules.
- Agentforce: Provided by the bridge library
react-native-agentforce(in-repo atAgentforceSDK-ReactNative-Bridge/android). React Native autolinking registers the package; no manual registration in the app. - App: React Native shell; Agentforce conversation UI and SDK are in the bridge.
- Agentforce: Provided by the bridge pod
ReactNativeAgentforce(in-repo atAgentforceSDK-ReactNative-Bridge/ios). - App: React Native shell; Agentforce conversation UI and SDK are in the bridge.
- Framework: React Native + TypeScript
- Navigation: React Navigation
- Agentforce API:
AgentforceServicefromreact-native-agentforce(bridge package) - Screens: Home, Settings, About
- Node.js (LTS recommended; 18+ required, 20.19.4+ preferred). Install and verify:
- macOS:
brew install node(requires Homebrew). Or use nvm:nvm install --lts. - Windows: Install from nodejs.org or
choco install nodejs-lts. Or use nvm-windows. - Linux: Use your distro’s package manager or nvm. Run
node -vto confirm.
- macOS:
- Watchman (recommended for better performance and fewer filesystem issues). Install and verify:
- macOS:
brew install watchman. - Windows/Linux: Optional; see Watchman if needed. Run
watchman -vto confirm.
- macOS:
- Git
- Android Studio
- Android SDK 24+
- Gradle 8.0+
- JDK 17 (required for building; higher versions may cause issues). Recommended setup:
- macOS: Install Azul Zulu JDK 17 (e.g.
brew install --cask zulu@17), then set in~/.zshrcor~/.bash_profile:export JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-17.jdk/Contents/Home - Windows: Install JDK 17 (e.g. Microsoft OpenJDK 17 or
choco install microsoft-openjdk17). - Linux: Install OpenJDK 17 via your package manager.
- Run
java -versionto confirm. Full details: React Native – Set up your environment (Android).
- macOS: Install Azul Zulu JDK 17 (e.g.
- macOS
- Xcode 15+
- CocoaPods
- iOS 17.0+
# Clone the repository (bridge is in-repo; no submodules)
git clone <repository-url>
cd AgentforceSDK-ReactNative
# Install JavaScript dependencies
npm install# Install CocoaPods dependencies (includes bridge pod)
node installios.js
# Run on iOS
npm run ios# Android setup is automatic with Gradle
# Just run the app directly
npx react-native run-androidInstructions for deploying Enhanced Chat In-App available here. This includes instructions on retrieving all these values.
When you first launch the app, navigate to Settings and configure:
-
Service API URL (required)
- Your Salesforce Service Agent URL
- Example:
https://your-domain.my.salesforce-scrt.com
-
Organization ID (required)
- Your 15 or 18 character Enhanced Chat Org ID
- Example:
00D000000000000
-
ES Developer Name (required)
- The API name of your Enhanced Chat Service Agent
- Example:
Your_Service_Agent_Name
-
Save the configuration
- From the Home screen, tap Launch Agentforce
- The SDK will initialize with your configuration
- Native conversation UI will appear
- Start chatting with your Service Agent!
AgentforceSDK-ReactNative/
├── AgentforceSDK-ReactNative-Bridge/ # In-repo: JS API + native bridge
├── src/ # React Native JavaScript/TypeScript
│ ├── screens/
│ │ ├── HomeScreen.tsx # Home screen; uses AgentforceService from react-native-agentforce
│ │ ├── SettingsScreen.tsx # Service Agent configuration
│ │ └── AboutScreen.tsx # App information
│ └── types/
│ └── agentforce.types.ts # TypeScript types
├── android/ # Android app; Agentforce from bridge library
├── ios/ # iOS app; Agentforce from bridge pod
└── App.tsx # Root component with navigation
Follow the instructions in the Developer Guide
Explore the Employee Agent Demo App branch
# Start Metro bundler
npm start
# In another terminal, run Android
npx react-native run-android
# View logs
npx react-native log-android# Start Metro bundler
npm start
# In another terminal, run iOS
npm run ios
# View logs
npx react-native log-ios- React Native Debugger: Use Flipper or React Native Debugger
- Native Android: Use Android Studio logcat
- Native iOS: Use Xcode console
- JavaScript logs: Check Metro bundler output
-
Configuration Test
- Open Settings
- Fill in all Service Agent fields
- Save and verify success message
-
Initialization Test
- Return to Home screen
- Tap "Launch Agentforce"
- Verify "Initializing..." message appears
-
Conversation Test
- Wait for conversation UI to load
- Send a test message
- Verify response from Service Agent
-
Error Handling Test
- Try launching without configuration
- Verify appropriate error message
Pod install fails
cd ios
pod deintegrate
pod cache clean --all
pod install --repo-updateBuild fails in Xcode
# Clean build folder
cd ios
xcodebuild clean -workspace ReactAgentforce.xcworkspace -scheme ReactAgentforce
# Rebuild
npm run iosGradle sync fails
cd android
./gradlew clean
./gradlew buildApp crashes on launch
- Check Android logcat:
npx react-native log-android - Verify SDK dependencies in
build.gradle - Ensure minimum SDK version is 24+
Metro bundler errors
npm start -- --reset-cacheNavigation not working
- Verify
react-native-gesture-handleris imported inindex.js - Check that
GestureHandlerRootViewwraps the app