Initialize Sprinklr Live Chat
Updated
The takeOff method initializes the Sprinklr Messenger Client SDK. This step prepares Live Chat to work based on the type of user using your app. It can be used to initialize the SDK for the following type of users:
This diagram illustrates how to initialize and present Sprinklr Live Chat:
Initialize for Anonymous Users
For anonymous users (unauthenticated users), you can initialize the messenger using the takeOff method without specifying any user details. Behind the scenes, an anonymous user is automatically created for the messenger and the flow for anonymous user is initialized.
Note:
The takeOff method must be called only once in the application lifecycle.
For optimal performance, call the takeOff method at the root of the application or as early as possible in your application flow.
Syntax
import MessengerClient from '@sprinklrjs/chat-native-client'
MessengerClient.takeOff({
appId: '<SPR_APP_ID>', // This will be provided by Sprinklr
environment: '<SPR_ENVIRONMENT>', // This will be provided by Sprinklr
pushAppId: '<SPR_PUSH_APP_ID>', // Should be Unique id, if not sure pass same as device ID
deviceId: '<UNIQUE_DEVICE_ID>',
skin: 'MODERN', // default value is MODERN, options: CLASSIC | MODERN
locale: '<SPR_LOCALE>', // default value is en
themeMode: 'DEFAULT' // default value is DEFAULT, options DEFAULT | DARK
})
Parameters
Parameter | Description | Required/Optional |
appId | Unique identifier of the Live Chat app. This will be provided by Sprinklr. | Required |
environment | This will be provided by Sprinklr. | Required |
pushAppId | Unique identifier for push notifications. If unsure, use the same value as deviceId. | Optional |
deviceId | Unique identifier for the device. | Optional |
skin | Defines the messenger UI skin. Supported Values: CLASSIC, MODERN Default Value: MODERN | Optional |
locale | Sets the language/locale for the messenger. Default Value: en | Required |
themeMode | Defines the theme mode. Supported Values: DEFAULT, DARK Default Value: DEFAULT | Optional |
Initialize for Authenticated Users
For authenticated users, initialize the messenger using the takeOff method with user details. The takeOff method will consider the provided user details for the messenger and initialize the flow accordingly.
Note:
The takeOff method must be called only once in the application lifecycle. For updating the user details or other information in the messenger, you can use the dedicated methods explained in the Configure Live Chat section.
For optimal performance, call the takeOff method at the root of the application or as early as possible in your application flow.
Syntax
import MessengerClient from '@sprinklrjs/chat-native-client'
MessengerClient.takeOff({
appId: '<SPR_APP_ID>', // This will be provided by sprinklr
environment: '<SPR_ENVIRONMENT>', // This will be provided by sprinklr
pushAppId: '<SPR_PUSH_APP_ID>', // Should be Unique id, if not sure pass same as device ID
deviceId: '<UNIQUE_DEVICE_ID>',
locale: '<SPR_LOCALE>', // default value is en
skin: 'MODERN', // default value is MODERN, options: CLASSIC | MODERN
themeMode: 'DEFAULT', // default value is DEFAULT, options: DEFAULT | DARK
user: {
userId: '12345',
firstName: 'John',
lastName: 'Doe',
phoneNo: '9876543210',
email: 'John.Doe@example.com',
profileImageUrl: 'https://example.com/profilePic.jpg',
hash: 'f30c3b0835ecd378a134c74bce8cea866df8c5b6e12a8c219c9bb288f7270e22'
}
})
Parameters
Parameter | Description | Required/Optional |
appId | Unique identifier of the Live Chat app. This will be provided by Sprinklr. | Required |
environment | This will be provided by Sprinklr. | Required |
pushAppId | Unique identifier for push notifications. If unsure, use the same value as deviceId | Optional |
deviceId | Unique identifier for the device. | Optional |
skin | Defines the messenger UI skin. Supported Values: CLASSIC, MODERN Default Value: MODERN | Optional |
locale | Sets the language/locale for the messenger. Default Value: en | Required |
themeMode | Defines the theme mode. Supported Values: DEFAULT, DARK Default Value: DEFAULT | Optional |
user | Specifies user details. For more details, see the User Object table. | Required (for authenticated chats) |
User Object
Parameter | Description | Required/Optional |
userId | Unique identifier of the user. | Required |
firstName | First name of the user. | Optional |
lastName | Last name of the user. | Optional |
phoneNo | Phone number of the user. | Optional |
Email ID of the user. | Optional | |
profileImageUrl | URL to the profile image of the user. | Optional |
hash | To know the steps to generate a hash, see How to generate Hash?
| Required |
Initialize for Custom Authenticated Users
You can create a custom user with custom parameters and pass them to the takeOff method.
Note:
The takeOff method must be called only once in the application lifecycle. For updating the user details or other information in the messenger, you can use the dedicated methods explained in other sections.
For optimal performance, call the takeOff method at the root of the application or as early as possible in your application flow.
If you want to implement a custom user authentication flow, contact the Sprinklr Support team at tickets@sprinklr.com to discuss the implementation process.
Syntax
import MessengerClient from '@sprinklrjs/chat-native-client'
MessengerClient.takeOff({
appId: '<SPR_APP_ID>', // This will be provided by sprinklr
environment: '<SPR_ENVIRONMENT>', // This will be provided by sprinklr
pushAppId: '<SPR_PUSH_APP_ID>', // Should be Unique id, if not sure pass same as device ID
deviceId: '<UNIQUE_DEVICE_ID>',
locale: '<SPR_LOCALE>', // default value is en
skin: 'MODERN', // default value is MODERN, options: CLASSIC | MODERN
themeMode: 'DEFAULT', // default value is DEFAULT, options: DEFAULT | DARK
customUser: {
customAttribute1: 'value1', //Add your custom attribute
customAttribute2: ‘value2’, //Add your custom attribute
hash: 'f30c3b0835ecd378a134c74bce8cea866df8c5b6e12a8c219c9bb288f7270e22'
}
})
Parameters
Parameter | Description | Required/Optional |
appId | Unique identifier of the Live Chat app. This will be provided by Sprinklr. | Required |
environment | This will be provided by Sprinklr. | Required |
pushAppId | Unique identifier for push notifications. If unsure, use the same value as deviceId | Optional |
deviceId | Unique identifier for the device. | Optional |
skin | Defines the messenger UI skin. Supported Values: CLASSIC, MODERN Default Value: MODERN | Optional |
locale | Sets the language/locale for the messenger. Default Value: en | Required |
themeMode | Defines the theme mode. Supported Values: DEFAULT, DARK Default Value: DEFAULT | Optional |
customUser | User details containing custom parameters and hash. For more details, see the Custom User Object table. | Required (for custom users) |
Custom User Object
Parameter | Description | Required/Optional |
Custom Attribute | This is a custom attribute that could be defined by you. You can define multiple custom attributes. | Required |
hash | To know the steps to generate a hash, see How to generate Hash? | Required |