The Copilot SDK is a robust framework designed for seamless integration into Android applications, offering a streamlined experience for developers. The minimum deployment target SDK is 21.
- Login to the Copilot Platform
- Open your Copilot and Navigate to the Deploy section to retrieve the integration token. Refer to the Mobile SDK Documentation for more details.
- Easy integration with Maven dependency.
- Compatible with Android 5 and later.
- Modular and extensible design.
- Lightweight and optimized for performance.
- Provides conversation interfaces, deep linking capabilities, and **voice call assistance **.
- Supports user authentication, telemetry observability, and **UI appearance customization **.
The Copilot SDK allows you to dynamically register and unregister custom tools (actions) that the LLM can invoke during a conversation. This enables you to extend the assistant's capabilities at runtime.
You can register a tool by creating a CopilotTool and passing it to Copilot.registerTool:
val addToCartTool = CopilotTool(
name = "add_to_cart",
description = "Add a product to the cart",
parameters = CopilotSchema(
properties = mapOf(
"product_id" to CopilotSchemaField(
type = "string",
description = "The ID of the product"
),
"quantity" to CopilotSchemaField(
type = "number",
description = "How many units to add"
)
),
required = listOf("product_id", "quantity")
),
handler = { params ->
Timber.tag("TAG").e("add_to_cart: $params")
val productId = params?.get("product_id") as? String
?: return@CopilotTool CopilotToolResult(false, "Missing product_id")
val quantity = (params["quantity"] as? Number)?.toInt() ?: 1
CopilotToolResult(true, "Added $quantity of $productId to cart")
}
)
val openCartTool = CopilotTool(
name = "open_cart",
description = "Opens the user's cart screen",
handler = { params ->
Timber.tag("TAG").e("open_cart: $params")
CopilotToolResult(true, "Cart opened successfully")
}
)
Copilot.registerTool(addToCartTool)
Copilot.registerTool(openCartTool)To remove a single tool:
Copilot.unregisterTool("add_to_cart")To remove multiple tools:
Copilot.unregisterTools(listOf("add_to_cart", "open_cart"))To remove all tools:
Copilot.unregisterAllTools()Note: Registering tools at runtime allows the LLM to call your app's business logic in response to user requests, making the assistant highly extensible and interactive.
- Android Version: minSdk 21+
- Languages: Kotlin
To integrate the Copilot SDK to your project:
- Add the Maven URL to the root
build.gradle:
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
}- Add the following dependency to your app module's
build.gradlefile:
dependencies {
implementation 'live.copilot.client:sdk:{{latest-version}}'
}Replace {{latest-version}} with the latest version from:
Add the following inside your MainActivity or early app lifecycle method:
val userData = CopilotUser(
fullName = "",
phoneNumber = "",
profileImageUrl = "",
emailAddress = "",
userIdentifier = "",
additionalFields = Map<String, Any>
)
val appearance = CopilotAppearance(
toolbarColor = "#E9FBFB",
backgroundColor = "#E9FBFB",
toolbarTintColor = "#000000",
titleText = "Copilot Assistant"
)
val config = CopilotConfig(
token = "YOUR_COPILOT_TOKEN",
user = userData,
appearance = appearance,
option = Map<String, Any>
)
Copilot.initialize(config = config)If using Jetpack Navigation:
<include app:graph="@navigation/copilot_nav" />Add to your AndroidManifest.xml:
<uses-permission android:name="android.permission.INTERNET" /><uses-permission
android:name="android.permission.RECORD_AUDIO" />val user = CopilotUser(
userIdentifier = "",
fullName = "",
phoneNumber = "",
profileImageUrl = "",
emailAddress = "",
)Set user:
Copilot.setUser(user)
Copilot.notifyLoginSuccess(user)UnsetUser:
Copilot.unsetUser()Set Context:
const val context = Map<String, Any>
Copilot.setContext(context)UnsetUser:
Copilot.unsetUser()val appearance = CopilotAppearance(
toolbarColor = "#E9FBFB",
backgroundColor = "#E9FBFB",
toolbarTintColor = "#000000",
titleText = "Copilot Assistant"
)
Copilot.setAppearance(appearance)Copilot.open(
navController = navController,
callback = copilotCallback,
initialMessage = "Hi there!"
)Copilot.close()Copilot.makeCall(
navController = navController,
callback = copilotCallback
)The SDK provides comprehensive telemetry and analytics capabilities to help you monitor and understand user interactions with the Copilot assistant. This section covers how to observe and handle various telemetry events.
The SDK provides a sealed class TelemetryEvent that categorizes different types of events that can
be observed:
-
WidgetEvent: Events related to the Copilot widget UI
Open: When widget is openedClose: When widget is closedload: When widget is loaded
-
UserEvent: Events related to user actions
Message: When user sends a messageMessageStop: When user stop a message
-
AssistantEvent: Events related to assistant actions
Message: When assistant sends a messageCompoent: When assistant send ComponentComponentItemView: When assistant send viewed ComponentSuggestion: When suggestions are shown
-
CallEvent: Events related to voice calls
Connected: When call connectsDisconnected: When call disconnects
-
CTAEvent: Events related to Call-To-Action interactions
Clicked: When a CTA button is clicked
-
Other: Events that are not explicitly mapped to known types
Other: Triggered when the telemetry type does not match any predefined event category.
val copilotCallback = object : CopilotCallback {
override fun hideToolBar() {
Timber.d("Toolbar hidden")
}
override fun onError(error: String) {
Timber.e("Conversation load error: $error")
}
override fun onReceiveTelemetry(event: TelemetryEvent) {
Timber.tag("onReceiveTelemetry")
.e("Event: ${event.name} Parameters: ${event.parameters.raw()}")
}
override fun onDeepLinkReceived(url: String) {
Timber.d("Deep link received: $url")
}
}| Method | Description |
|---|---|
initialize(config) |
Initialize SDK with token, user, and UI config |
setUser(user) |
Set user dynamically |
notifyLoginSuccess(user) |
Notify SDK of a successful login |
setAppearance(appearance) |
Update Copilot UI styling |
open() |
Launch conversation UI |
makeCall() |
Start voice-based assistant call |
onReceiveTelemetry() |
Observe telemetry events |
See MainActivity.kt
in this
repo for a complete working example integrating telemetry observers, conversation UI, and voice
call. This ensures full lifecycle management and feature exposure from Copilot SDK.
For additional setup help, refer to Mobile SDK Docs.
For issues or feature requests, please reach out via your Copilot dashboard support.
© Copilot.live – All rights reserved.