Method return behavior
Setup
SagepilotChat.configure(config): initializes the SDK, loads channel config, creates or resumes a customer session, and starts unread polling unless disabled.SagepilotChat.destroy(): stops polling, clears in-memory SDK state, and removes listeners.SagepilotChat.getChannel(): returns the loaded channel bootstrap data.
Identity and session
SagepilotChat.identify(identity): links the active session to a known customer.SagepilotChat.logout(): removes known-customer identity from the active session.SagepilotChat.getSession(): fetches the current session and returns safe session metadata. It does not expose the session token.SagepilotChat.getSessionState(): returns safe local session metadata. It does not expose the session token.SagepilotChat.getIdentityState(): returns local identity state, includingidentified,pending, andcustomer.SagepilotChat.onIdentify(callback): subscribes to successful identify events.
Hosted chat UI
SagepilotChat.present(): opens the hosted chat home screen.SagepilotChat.presentMessages(): opens the hosted conversations/messages screen.SagepilotChat.presentMessageComposer(message?, options?): returnsbooleanand opens immediately unlessbehavior.waitForIdentifyBeforeComposeris enabled and anidentify()call is in flight. If both are true, it returnsPromise<boolean>and waits up to 60 seconds for a successful identify response before opening.{ mode: "auto" }is the default and lets Sagepilot reuse an existing conversation when one is available. Pass{ mode: "new" }to force a fresh conversation, or{ chatId }to open a specific conversation. It does not auto-send.SagepilotChat.dismiss(): closes the hosted chat modal.SagepilotChat.hide(): alias fordismiss().SagepilotChat.toggle(): opens the chat when closed and closes it when open.SagepilotChat.isPresented(): returns whether the hosted chat modal is open.SagepilotChat.onConversationCreated(callback): subscribes to hosted conversations created from the React Native widget and returnschat_idplus any composer metadata.SagepilotChatProvider: renders the hosted Sagepilot chat inside a React Native modal WebView.
SagepilotChatProvider is mounted, the SDK preloads a hidden hosted WebView after configure() so the first visible open can reuse warmed network/cache state. Disable this with behavior.preloadWebView: false.
Unread state
SagepilotChat.getUnreadCount(): fetches and returns the current unread count.SagepilotChat.onUnreadChange(callback): subscribes to unread count changes.SagepilotChat.startUnreadPolling(intervalMs?): starts unread polling.SagepilotChat.stopUnreadPolling(): stops unread polling.
Lifecycle events
SagepilotChat.onReady(callback): fires when SDK configuration completes.SagepilotChat.onPresent(callback): fires when chat opens.SagepilotChat.onDismiss(callback): fires when chat closes.SagepilotChat.onError(callback): subscribes to SDK errors.SagepilotChat.onStateChange(callback): subscribes to local SDK state changes.
React hook
useSagepilotChat(): returns presentation helpers, unread count, identity state, and common actions for app-owned launchers and badges.
Storage helpers
createKeychainTokenStorage(keychain, options?): adaptsreact-native-keychainfor secure session token storage.createAsyncStorageCacheStorage(asyncStorage): adapts AsyncStorage for SDK cache features such as native file-picker batch recovery.
Attachment helpers
createSagepilotFilePicker(options): creates a native camera, gallery, and document picker adapter from app-provided picker modules.createSagepilotFileStore(blobUtil, options?): creates durable app-private storage for picked-file bytes.SagepilotFilePickerError: typed error class surfaced when the picker fails for permission, camera, file-size, encoding, read, or unknown errors.
@sagepilot-ai/react-native-camera-addon package exports createSagepilotCameraXFilePicker(options?) for Android CameraX attachments.
Push add-on
This reference describes matching 0.4.2 base and push add-on packages. Start with the step-by-step integration guide; use this page to look up inputs, timing and return values.push below means either brandPush.push on a standalone client or SagepilotChat.push after SagepilotChat.configure(...) succeeds with a push configuration. Both expose the same API. Do not run both clients for the same installation and push channel.
The guide’s fetchPushProof, connectPush and disconnectPush are example functions implemented by your app, not SDK exports. You can supply the backend proof through your existing login/session response or a separate authenticated request.
Import map
Client setup and identity
The backend identity proof contains the external customer ID and optional email/phone authorized by your brand. Your brand chooses how to verify its users; Sagepilot checks the signed proof and resolves the supplied customer identity. Use the same external ID as webhook
client_customer_id and chat userId. A chat userHash, brand proof, FCM token and SDK session token have different purposes and are not interchangeable.
A proof is valid for at most five minutes. Push authorization lasts 24 hours; your app must obtain a fresh proof from its backend to renew it. Do not embed the signing secret in the app.
Configuration fields used in the guide
Permission, registration and consent
Permission values are
authorized, provisional, denied and not_determined. Registration requires authorized or provisional. Provisional permission does not guarantee banners or sound.
There is no separate public push.upsert() method. Upsert describes the server’s registration behavior: create an installation registration when absent, otherwise update it. sync() and register() use that behavior; neither requires a customer object because the session already identifies the customer.
Manual registration input, for an already identified/authorized client:
currentDeviceToken is supplied by your native provider integration. The Firebase adapter obtains it automatically. installation_id, customer identity and SDK version metadata are managed by the SDK; capabilities is an optional registration override normally supplied by the native adapter. Do not advertise SDK rendering without native forwarding installed.
Preferences accept this shape; all fields are optional:
enabled: true, marketing_enabled: false, support_enabled: true. Existing saved consent is preserved. Top-level enabled: false blocks all push; a platform’s enabled: false blocks that platform. An app/web category value overrides the matching top-level category value, so changing only marketing_enabled will not replace a saved app.marketing_enabled override. Keep the settings screen consistent with the scope you use.
Preferences apply to the customer’s devices, not just the phone on which the switch changed. Device permission and channel policy must also allow delivery. Legacy webhook customers retain their existing behavior during SDK rollout.
Adapters and automatic callbacks
The native adapter defaults to
displayMode: 'provider', channelName: 'Notifications' and notificationSettingsPrompt: true. onError is required. Android advertises provider and SDK display support; iOS retains OS alert presentation in both modes. The channel policy can override the installation preference where supported.
The Firebase adapter automatically subscribes to token refresh, foreground messages and taps once the client starts. Your app installs the one background handler and native forwarding. Avoid also wiring the same event into a second presenter or analytics implementation.
The optional onOpen(message) in push configuration is your navigation callback. It does not create screens or configure app links. Preserve the original message for destination tracking and defer routing until authentication/navigation is ready.
Notification settings
These helpers are exported by the push add-on in 0.4.2:
The adapter’s default guidance offers pop-up/lock-screen setup once after notification access is granted and the signed-in app is active.
notificationSettingsPrompt: false disables that guidance if your app owns it. push.storage remembers dismissal. No separate permission dialog can guarantee banners, lock-screen content or a manufacturer’s Cards/Icons layout. See display setup.
Analytics and explicit outcomes
Receipt, tap and other native observations are captured by the configured add-on. Do not manufacture them after a provider send response. Firebase/provider rendering retains Sagepilot analytics when callbacks are forwarded; token registration alone does not report engagement.
V1 deduplicates by notification delivery and event type. Actions/conversions also use
actionId: use a stable order/action ID for each distinct outcome and reuse it when retrying that outcome. For example, in your confirmed purchase callback:
originalPushMessage must be the notification your app actually associates with that purchase, and order must be the confirmed order from your own flow. This does not implement attribution or general app event tracking for you. A generic action event does not create custom notification buttons. See metric availability and routing.
Lifecycle hooks you normally leave to the client
push.start(), push.stop(), push.pauseAndRevoke() and push.resume() support the client lifecycle. Normal apps call the standalone or chat client methods above and let that client manage these hooks. Do not use them as substitutes for authenticated login/logout.
Runtime notes
The React Native UI usesreact-native-webview to show the Sagepilot-owned hosted conversation. The SDK injects mobile WebView polish for viewport scaling, text selection, tap highlighting, native bridge message forwarding, and secure hosted-auth handoff.
Customers should depend on the public SDK methods and components, not WebView internals or hosted route implementation details.