Customerly is a customer service platform that helps businesses provide better support to their customers. The React Native SDK allows you to integrate Customerly's features directly into your React Native application, including:
- Live chat support
- Help center articles
- User profiling
- Event tracking
- Lead generation
- Surveys
- Real-time video calls
Add the SDK to your project:
yarn add react-native-customerly-sdkThis library needs these dependencies to be installed in your project before you can use it:
yarn add react-native-webview react-native-safe-area-context @notifee/react-native react-native-device-infoUsing Expo?
npx expo install expo-build-properties react-native-webview react-native-safe-area-context @notifee/react-native react-native-device-infoIMPORTANT
I want to save you a lot of time here: it seems that the
@notifee/react-nativepackage is not building correctly with the latest versions of Expo (more info here and here). To ensure it builds correctly, add the following to yourapp.json:
{
"expo": {
"plugins": [
[
"expo-build-properties",
{
"android": {
"extraMavenRepos": ["../../node_modules/@notifee/react-native/android/libs"]
}
}
]
]
}
}Before continuing, run the following command to ensure all native code is rebuilt correctly:
npx expo prebuild --cleanThis helps avoid build issues, especially after adding or updating native dependencies.
Wrap your app with CustomerlyProvider (it must be wrapped in a SafeAreaProvider) and use the Customerly API:
import React from "react";
import { CustomerlyProvider, Customerly } from "react-native-customerly-sdk";
import { SafeAreaProvider } from "react-native-safe-area-context";
export default function App() {
return (
<SafeAreaProvider>
<CustomerlyProvider appId="YOUR_APP_ID">
{/* Your app content */}
</CustomerlyProvider>
</SafeAreaProvider>
);
}You can then use the Customerly API anywhere in your app:
import { Customerly } from "react-native-customerly-sdk";
Customerly.show();
Customerly.update({
appId: "YOUR_APP_ID",
userId: "123",
email: "user@example.com",
name: "John Doe",
});To enable notifications, call:
Customerly.requestNotificationPermissionIfNeeded();| Prop | Type | Required | Description | Default |
|---|---|---|---|---|
appId |
string |
Yes | The Customerly app ID | |
colorScheme |
"light" | "dark" |
No | Your app's current color scheme | System color scheme |
notificationChannelId |
string |
No | The ID of the notification channel to use for notifications (Android only) | customerly-notification-channel |
notificationChannelName |
string |
No | The name of the notification channel to use for notifications (Android only) | Customerly Notification Channel |
userId |
string |
No | The user ID | - |
name |
string |
No | The user name | - |
email |
string |
No | The user email | - |
accentColor |
string |
No | The accent color | The messenger accent color configured in your project settings |
contrastColor |
string |
No | The contrast color | The messenger contrast color configured in your project settings |
attachmentsAvailable |
boolean |
No | Whether attachments are available | true |
Updates the Customerly SDK settings.
Customerly.update({ appId: "YOUR_APP_ID" });Requests notification permissions if not already granted (uses Notifee).
Customerly.requestNotificationPermissionIfNeeded();Shows the Customerly chat interface.
Customerly.show(withoutNavigation?: boolean);Hides the Customerly chat interface.
Customerly.hide();Navigates back in the chat interface.
Customerly.back();Logs out the current user.
Customerly.logout();Registers a new lead with the provided email and optional attributes.
Customerly.registerLead("user@example.com", { name: "John Doe" });Shows the chat interface with a pre-filled message.
Customerly.showNewMessage("Hello, how can I help you?");Sends a new message and shows the chat interface.
Customerly.sendNewMessage("Hello, how can I help you?");Navigates to a specific conversation.
Customerly.navigateToConversation(123);Shows an article from the help center.
Customerly.showArticle("collection", "article");Tracks a custom event.
Customerly.event("event_name");Sets a custom attribute for the current user.
Customerly.attribute("attribute_name", "attribute_value");Gets the count of unread messages.
await Customerly.getUnreadMessagesCount();Gets the count of unread conversations.
await Customerly.getUnreadConversationsCount();The SDK provides various callbacks for different events. Here are the main callback setters:
Customerly.setOnChatClosed(() => {});
Customerly.setOnChatOpened(() => {});
Customerly.setOnHelpCenterArticleOpened((article) => {});
Customerly.setOnLeadGenerated((lead) => {});
Customerly.setOnMessageRead((conversationId, conversationMessageId) => {});
Customerly.setOnMessengerInitialized(() => {});
Customerly.setOnNewConversation((conversationId, attachments) => {});
Customerly.setOnNewMessageReceived((message) => {});
Customerly.setOnNewConversationReceived((conversationId) => {});
Customerly.setOnProfilingQuestionAnswered((question, answer) => {});
Customerly.setOnProfilingQuestionAsked((question) => {});
Customerly.setOnRealtimeVideoAnswered((realtimeCall) => {});
Customerly.setOnRealtimeVideoCanceled(() => {});
Customerly.setOnRealtimeVideoReceived((realtimeCall) => {});
Customerly.setOnRealtimeVideoRejected(() => {});
Customerly.setOnSurveyAnswered(() => {});
Customerly.setOnSurveyPresented((survey) => {});
Customerly.setOnSurveyRejected(() => {});Each callback has a corresponding remove method:
Customerly.removeOnChatClosed();
Customerly.removeOnChatOpened();
// ... and so on for all callbacksYou can also remove all callbacks at once:
Customerly.removeAllCallbacks();The repository includes a sample project (example) that demonstrates how to integrate and use the Customerly SDK in a Expo application. The example shows:
- Basic SDK initialization
- Messenger presentation
- User management
- Event tracking
- Message handling
- Notification handling
- Callback usage
To run the example:
- Run
yarn installto install the dependencies - Run
yarn example:iosto start the iOS simulator - Run
yarn example:androidto start the Android emulator
The sample app provides a complete reference implementation of all SDK features and can be used as a starting point for your integration.
To release a new version of the SDK, you need to:
- Go to GitHub Actions and run the
Releaseworkflow - The workflow will build the SDK and release it to npm
This SDK is licensed under the GNU GPLv3 License. See the LICENSE file for more details.