Skip to content

Latest commit

 

History

History
96 lines (65 loc) · 3.24 KB

File metadata and controls

96 lines (65 loc) · 3.24 KB

Agentforce React Native Bridge

This directory contains the Agentforce bridge module: JavaScript API layer, sample app, and native iOS/Android code. It has no Mobile SDK dependency; a host app that adds the Mobile SDK can use the included auth bridge for Employee Agent.

Installation

iOS (CocoaPods)

In your app’s Podfile:

pod 'ReactNativeAgentforce', :path => '../node_modules/react-native-agentforce/ios'

Your app must also include the Agentforce iOS SDK in the Podfile so the bridge can link. For Employee Agent, the host app must additionally include the Salesforce Mobile SDK and perform bootconfig + SDK initialization.

Android

  • Link the Android library and register AgentforcePackage in your app.
  • For Employee Agent (see below), the host app must add the Salesforce React dependency and bootconfig + SDK init.

JavaScript

Import the API from this package when the native module is linked:

import { AgentforceService } from 'react-native-agentforce';

Use the sample app in app/ as reference or replace with your own UI.


Employee Agent: host app requirements

For Employee Agent (authenticated) mode, the host app must provide the Salesforce Mobile SDK and initialize it. This bridge does not bundle the SDK.

Android

Add the Salesforce React dependency in your app’s build.gradle (e.g. app/build.gradle):

implementation "com.salesforce.mobilesdk:SalesforceReact:13.1.1"

You must also configure bootconfig and perform SDK initialization (e.g. via react-native-force or your existing Salesforce Mobile SDK setup). Without these, Employee Agent auth will not work.

iOS

Include the Salesforce Mobile SDK pods in your Podfile and perform bootconfig and SDK initialization as required for your app. The bridge’s Employee Agent auth layer relies on the SDK being initialized at runtime.


API Reference

Core Methods

Configure and launch:

import { AgentforceService } from ‘react-native-agentforce’;

await AgentforceService.configure(config);
await AgentforceService.launchConversation();

Additional Context: Provide contextual data to personalize agent responses (must be called after launching conversation):

await AgentforceService.setAdditionalContext({
  variables: [
    { name: ‘userId’, type: ‘Text’, value: ‘005xx0000001234’ },
    { name: ‘accountId’, type: ‘Text’, value: ‘001xx0000001234’ },
    { name: ‘priority’, type: ‘Text’, value: ‘high’ },
    { name: ‘score’, type: ‘Number’, value: 95.5 },
    { name: ‘isVIP’, type: ‘Boolean’, value: true },
    { name: ‘createdDate’, type: ‘DateTime’, value: ‘2026-03-06T10:00:00Z’ }
  ]
});

Supported types:

  • Text - String values
  • Number - Numeric values
  • Boolean - Boolean values
  • Date, DateTime - ISO date strings
  • Object - Object/map values
  • List - Array values
  • Json, Money, Ref, Variable - Additional Android SDK types

Platform notes:

  • Android: Uses AgentforceContextVariable with case-sensitive type names
  • iOS: Uses AgentforceVariable with JSEncodableValue enum; type is just a label
  • Context persists for the current conversation session