Flyreel Android SDK
Requirements
Minimum Android SDK version: - 23
Installation
- Add Flyreel maven repository to your project's
settings.gradle.ktsfile:
dependencyResolutionManagement {
// ...
repositories {
// ...
maven("https://flyreelsdk.jfrog.io/artifactory/flyreel-androidsdk")
}
}
- Add the following dependency to your app's
build.gradle.ktsfile:
dependencies {
// ...
implementation("lexisnexis.flyreel:android-sdk:$flyreelVersion")
}
Legacy
- Add Flyreel maven repository to your project's
build.gradlefile:
allprojects {
repositories {
// ...
maven {
url "https://flyreelsdk.jfrog.io/artifactory/flyreel-androidsdk"
}
}
}
- Add the following dependency to your app's
build.gradlefile:
dependencies {
// ...
implementation "lexisnexis.flyreel:android-sdk:$flyreelVersion"
}
Usage
Initialization
To use the Flyreel SDK, you must provide a configuration with the following parameters:
organizationId: Identifier of your organization.
Then you need to call Flyreel.initalize() method in your Application's onCreate() method. (Don't
forget to register your application class in AndroidManifest.xml)
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
val configuration = FlyreelConfiguration(
organizationId = "7d3899f1421a7650241516475",
)
Flyreel.initialize(
application = this,
configuration = configuration
)
}
}
NOTE: Setting up the configuration is mandatory. Attempting to open the SDK flow without it will result in a fatal error.
How to open Flyreel chat
Invoke openFlyreel() method with a context
Flyreel.openFlyreel(context = requireContext())
Deep Linking
If you're launching the Flyreel flow from a deep link, push notification, or a custom solution where user details can be provided automatically, use:
fun openFlyreel(
context: Context,
zipCode: String,
accessCode: String,
shouldSkipLoginPage: Boolean = true
)
fun openFlyreel(
context: Context,
deeplinkUri: Uri? = null,
shouldSkipLoginPage: Boolean = true
)
Custom fonts
If you want to use custom fonts in the Flyreel chat, you have two options:
- add your font ttf file to the assets folder
- add your font ttf file to the res/font folder
Then, you can use the font's name in the dashboard panel. For example, if you have added font my_font.ttf to the assets folder, you can use my_font as a font name in the Flyreel dashboard.
Debug Logs
Enable debug logging for troubleshooting purposes:
Flyreel.enableLogs()
Flyreel status check
You can manually check Flyreel status
///This function makes a network request to retrieve the status of Flyreel for the specified zip code and access code
fun fetchFlyreelStatus(zipCode: String, accessCode: String, onSuccess: (FlyreelStatus) -> Unit, onError: (FlyreelError) -> Unit)
Events
The Flyreel SDK emits events throughout the conversation flow that you can observe and integrate with your analytics platform (e.g., Firebase Analytics, Mixpanel, Segment). This allows you to track user behavior, measure engagement, and gain insights into how users interact with the Flyreel flow.
FlyreelEvent Data Structure
The SDK emits events as FlyreelEvent objects with the following structure:
data class FlyreelEvent(
val user: FlyreelAnalyticUser, // User and session information
val name: String, // Event type identifier
val timestamp: String, // ISO 8601 timestamp of the event
val activeTime: Long?, // Time user has been actively engaged (in milliseconds)
val coordination: FlyreelCoordination?, // User's location coordinates (if available)
val deviceData: FlyreelDeviceData?, // Device and app information
val messageDetails: FlyreelMessageDetails?, // Details about questions/messages (for question events)
)
Supporting Data Classes
data class FlyreelAnalyticUser(
val id: String, // Unique user identifier
val name: String, // User's name
val email: String, // User's email
val botId: String, // Bot configuration ID
val botName: String, // Bot name
val organizationId: String, // Organization identifier
val status: String, // Current user status
val loginType: FlyreelLoginType // How the user logged in (MANUAL or DEEPLINK)
)
data class FlyreelDeviceData(
val phoneManufacturer: String, // Device manufacturer (e.g., "Samsung", "Google")
val phoneModel: String, // Device model (e.g., "SM-G998B", "Pixel 6")
val appVersion: String, // Device OS version
val appName: String // Your app's name
)
data class FlyreelCoordination(
val lat: Double, // Latitude
val lng: Double // Longitude
)
data class FlyreelMessageDetails(
val message: String?, // The question or message text
val messageType: String?, // Type of message (e.g., "text", "image")
val moduleKey: String?, // Module identifier (e.g., "intro", "wrap_up")
val messageKey: String?, // Unique message identifier
val phase: String // Derived phase (e.g., "beginning")
)
Event Types
The SDK emits the following event types (identified by event.name):
| Event Name | Description | When It's Triggered |
|---|---|---|
user_logged_in | User successfully authenticated | After user enters valid credentials |
question_asked | Flyreel bot asks a question | When a new question is presented to the user |
question_answered | User responds to a question | After user submits an answer |
flyreel_completed | User completes the Flyreel flow | When user finishes & successfully submits a Flyreel |
sdk_closed | User exits the SDK | When user closes the SDK |
Observing Events
Subscribe to the event stream to receive all Flyreel events in real-time:
Flyreel.observeFlyreelEvents { event ->
// Forward to your analytics provider
YourAnalyticsProvider.trackEvent(event.name, mapOf(
"user_id" to event.user.id,
"timestamp" to event.timestamp,
"active_time_ms" to event.activeTime
))
}
Usage Example
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// Subscribe to Flyreel events
Flyreel.observeFlyreelEvents { event ->
when (event.name) {
"user_logged_in" -> {
Log.d("Analytics", "User ${event.user.name} logged in")
}
"question_asked" -> {
event.messageDetails?.let { details ->
Log.d("Analytics", "Question asked: ${details.message} (Phase: ${details.phase})")
}
}
"question_answered" -> {
Log.d("Analytics", "User answered question at ${event.timestamp}")
}
"flyreel_completed" -> {
Log.d("Analytics", "Flow completed! Active time: ${event.activeTime}ms")
}
"sdk_closed" -> {
Log.d("Analytics", "User exited SDK")
}
}
}
}
}
Sandbox
Verify your implementation in the sandbox mode. Initialize Flyreel with an additional parameter:
val configuration = FlyreelConfiguration(
organizationId = "7d3899f1421a7650241516475",
environment = FlyreelEnvironment.Sandbox
)
Flyreel.initialize(
application = this,
configuration = configuration
)