Android SDK
Install agent44 in a Kotlin and Jetpack Compose app: configure it, identify signed-in users with a signature, open the chat and help center, show update prompts and set up push.
AAgent44Updated 7 min read
On this page
- Quick start
- 1. Get your SDK key
- 2. Add the dependency
- 3. Start the SDK
- 4. Add a chat button
- Tell agent44 who your users are
- Verify your users
- Keep the signature out of backups (recommended with verification)
- Everything you can open
- Update prompts and What's New
- Push notifications (optional)
- Not yet in this version
Add customer support to your Android app in a few minutes: a chat with your team and AI agent, a help center, "update your app" screens and What's New. You manage all of it from your agent44 dashboard.
Native Kotlin and Jetpack Compose, for apps built with Compose or Views. It's the Android counterpart of agent44 for Flutter: the same screens, talking to agent44 in the same way.
Other platforms: Flutter · iOS · React Native
The full reference, with every option, is the SDK's README on GitHub: harithwick/agent44-android.
Quick start#
1. Get your SDK key#
In agent44, open Settings › Apps, pick your Android app (or Add app) and click Create SDK key. Copy it: it starts with a44_pub_ and is shown only once.
2. Add the dependency#
The SDK is published with JitPack. Add the repository in settings.gradle.kts:
dependencyResolutionManagement {
repositories {
google()
mavenCentral()
maven("https://jitpack.io")
}
}and the SDK in your app's build.gradle.kts:
dependencies {
implementation("com.github.harithwick:agent44-android:0.1.0")
}It needs minSdk 24 (Android 7.0), compileSdk 36 and Java 17. It brings OkHttp, Kotlin coroutines, kotlinx.serialization and Jetpack Compose; the screens use their own theme, so nothing in your app's theme changes.
The SDK's manifest adds the INTERNET permission and its two activities; you don't need to add anything.
3. Start the SDK#
In your Application:
class MyApp : Application() {
override fun onCreate() {
super.onCreate()
Agent44.configure(this, publicKey = "a44_pub_YOUR_ANDROID_KEY")
}
}(Register it with android:name=".MyApp" on <application> if you don't have one yet.)
configure never waits on the disk or the network. Calls made while it's starting wait for it.
4. Add a chat button#
In Compose, put the round chat button in a corner of any screen. It shows the unread count, and a tap opens the chat:
import ai.agent44.ui.Agent44Launcher
import ai.agent44.ui.launcherAlignment
Box(Modifier.fillMaxSize()) {
// … your screen …
Agent44Launcher(Modifier.align(Agent44.launcherAlignment).padding(16.dp)) // left or right, as set in agent44
}With Views:
<ai.agent44.ui.Agent44LauncherView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="16dp" />Or open the chat from your own button:
Agent44.openChat(context)That's it. Run your app, tap the button and send a message. It appears in your agent44 inbox, and the "Install the SDK" step in your dashboard's setup checklist ticks itself off.
Before you submit to Google Play, see "Data the SDK collects" in the SDK's README for the Data safety form.
Tell agent44 who your users are#
Call this after your user signs in (from a coroutine), so your team knows who they're talking to and the user sees their conversations on every device:
lifecycleScope.launch {
try {
Agent44.identify(
Agent44User(
userId = user.id, // your app's own user id
email = user.email, // everything else is optional
name = user.name,
phone = user.phone,
avatarUrl = user.photoUrl,
company = Agent44Company(
name = "Acme",
url = "https://acme.com",
employment = Agent44Employment(title = "CTO"),
geolocation = Agent44Geolocation(city = "London", country = "GB"),
),
signature = user.agent44Hash, // see "Verify your users" below
),
)
} catch (e: Agent44Exception) {
// agent44 couldn't be reached or refused it: the previous identity stays. Try again later.
}
}And when they sign out (also a suspend function):
lifecycleScope.launch { Agent44.logout() }identify throws an Agent44Exception when agent44 can't be reached or refuses the sign-in; nothing is kept on the device until it works. logout never throws for network errors. From Java, use the overloads that take an Agent44Callback.
People can chat before they sign in too. Their conversations move to their account when you call identify.
Verify your users#
Without verification, agent44 trusts the id you send. Anyone with your app's key and a user's id could then read that user's conversations. Identity verification stops that, and new workspaces start with it enforced: until your server signs user ids, identify is refused (401) and signed-in screens show their error state, while people who haven't signed in chat as usual.
In agent44, open Settings › Identity verification and click Generate secret. The secret starts with
a44_idv_and is shown only once: copy it into your server's configuration. It belongs on your server only. One secret covers every app in the workspace (iOS, Android and web).When your app signs in, have your server compute the HMAC-SHA256 of the user's id, keyed with the whole secret (the
a44_idv_included). Return it as lowercase hex.Pass it as
signaturetoAgent44.identify. The SDK sends it with every request (X-A44-User-Hash).If Enforce is off in your workspace, click Turn on Enforce once your app version with signatures is live.
// Node, on your server
crypto.createHmac('sha256', process.env.AGENT44_IDENTITY_SECRET).update(user.id).digest('hex');While Enforce is off, a missing or wrong signature is ignored and the id is trusted as sent. While it's on, a user id with a missing or wrong signature gets a 401: identify throws an Agent44Exception with statusCode 401. Either way, use ids that can't be guessed: your database id or a UUID, not an email address or a number like 42.
Keep the signature out of backups (recommended with verification)#
With your app's key, the user id and signature are enough to act as that user, and the signature doesn't expire until you rotate the secret. By default the SDK keeps its values in the SharedPreferences file agent44.xml, which Android's auto-backup copies to a new phone.
Keep the user id and signature encrypted with a key in the Android Keystore instead:
Agent44.configure(this, publicKey = "a44_pub_…", storage = Agent44Storage.secureIdentity(this))Only the user id and signature move to
agent44_secure.xml, encrypted with AES-GCM under a Keystore key that never leaves the device. Everything else stays inagent44.xml.A user signed in before you switched stays signed in: their id moves to the secure file on the next launch.
A backup restored on another phone can't be decrypted there (the Keystore key isn't backed up), so the SDK starts signed out instead of acting as the previous phone's user.
logout()clears both.
Leave the secure file out of backups too. Add res/xml/backup_rules.xml (Android 11 and lower):
<full-backup-content>
<exclude domain="sharedpref" path="agent44_secure.xml" />
</full-backup-content>and res/xml/data_extraction_rules.xml (Android 12 and later):
<data-extraction-rules>
<cloud-backup>
<exclude domain="sharedpref" path="agent44_secure.xml" />
</cloud-backup>
<device-transfer>
<exclude domain="sharedpref" path="agent44_secure.xml" />
</device-transfer>
</data-extraction-rules>then point your manifest at both: <application android:fullBackupContent="@xml/backup_rules" android:dataExtractionRules="@xml/data_extraction_rules" …>. Without the secure storage you can exclude agent44.xml the same way; your app's own preferences aren't affected, since the SDK uses its own file.
Everything you can open#
Each of these is one line, called from any button or menu:
What | Code |
|---|---|
The chat (latest open conversation, or a new one) |
|
Messenger (home, messages, help and updates tabs) |
|
Start a new message |
|
The user's conversations |
|
Help center |
|
Search help |
|
Ask AI a question |
|
One help article |
|
What's new (changelog) |
|
The article id is the 10 characters after /articles/ in the article's web address. Screens slide up over your app in the SDK's own activity, so they work from Compose and View-based apps alike. Asking for the screen already on top (a double tap) does nothing.
Update prompts and What's New#
By default, configure checks for this launch's in-app message as soon as an activity is on screen and shows the most important one: a force update (full screen, can't be dismissed, with "Contact support" for people who can't update), a recommended update, What's New after an update, an announcement (modal, sheet or banner) or a chat message from a teammate. The check runs once per launch, and again when the app comes back if it didn't finish (offline).
A force update is only shown with a store page to send people to: the link set in agent44 (
https://only), else Google Play's page for your package name.The SDK sends the device's Android version and API level, so an update people can't install isn't shown to them.
To show them yourself, pass
onInAppMessage = InAppMessageHandler { message -> myUi.show(message); true }and report what happened withAgent44.trackInAppMessage(message.id, InAppMessageEvent.CLICKED). To decide when to check, passshowInAppMessages = falseand callAgent44.checkInAppMessages().
Push notifications (optional)#
agent44 sends replies from your team and AI agent, and push campaigns, through Firebase Cloud Messaging. Upload your Firebase service account in Settings › Apps (your Android app's Push notifications tab). The SDK doesn't depend on Firebase: hand it the token and the messages.
class MyMessagingService : FirebaseMessagingService() {
override fun onNewToken(token: String) = Agent44.registerPushToken(token)
override fun onMessageReceived(message: RemoteMessage) {
// Shows agent44's notifications (except a reply to the conversation on screen) and opens them when tapped.
if (Agent44.handlePush(this, message.data, message.notification?.title, message.notification?.body)) return
// … your own notifications …
}
}At start-up, register the current token (FirebaseMessaging.getInstance().token.addOnSuccessListener { Agent44.registerPushToken(it) }), and pass enabled = false when the user has turned notifications off. On Android 13 and later, ask for POST_NOTIFICATIONS as usual.
When the app is in the background, Android shows agent44's notifications itself and a tap opens your launcher activity with the notification's data. Hand that to the SDK:
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Agent44.handlePushIntent(this, intent)
}
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
Agent44.handlePushIntent(this, intent)
}A reply opens its conversation (also when the tap launched the app and
configureis still starting).A campaign counts as opened and opens its link: an
https://link or a deep link with one of yourdeepLinkSchemes. PassonOpenUrlto route it yourself.logout()removes the token from the user; it's registered again for the next person.
Their data carries a44_type (reply or campaign), a44_conversation_id, a44_message_id and a44_url; Agent44.isAgent44Push(data) tells them from your own.
Not yet in this version#
Compared with agent44 for Flutter, 0.1.0 doesn't have these yet:
Tablets: the messenger keeps its phone layout (centred, at most 600dp wide); there's no navigation rail at the side.
GIFs in the chat show their first frame only, and audio messages open as a link.
Images in changelog updates and posts can't be opened full screen.
Ask AI answers are plain text with tappable
[n]citations, not formatted text.Wording is changed through string resources (
a44_*), not a strings object passed toconfigure.