Skip to content

About

Hailbell for Android: in-app support chat and push notifications (Kotlin, Compose)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Hailbell for Android

In-app support chat and push notifications for Android 7 (API 24) and later, in Kotlin and Jetpack Compose. Customers write from a native chat screen inside your app; you answer from the Hailbell dashboard, Discord or Telegram, and your reply reaches them live or as a push notification. It mirrors the iOS SDK: the same API names, the same screens and the same server.

When the support AI hands a chat to your team while nobody is around, the chat shows a reply time card saying when to expect a reply, in the customer's own time, with a button to turn on notifications. The card arrived in 1.3.0; earlier versions show the same words as a normal message.

Install

The library is published through JitPack. Add the JitPack repository in settings.gradle.kts:

dependencyResolutionManagement {
    repositories {
        google()
        mavenCentral()
        maven { url = uri("https://jitpack.io") }
    }
}

Then the dependency in the app's build.gradle.kts:

dependencies {
    implementation("com.github.vidursaini:hailbell-android:1.2.0")
}

Requirements:

  • minSdk 24, compileSdk 36 or later, Java 17.
  • The library brings OkHttp, Coil, Compose and lifecycle-process. A review card's button opens your Play Store listing.
  • It has no Firebase dependency. The app passes FCM tokens and messages in.
  • Its manifest adds INTERNET, POST_NOTIFICATIONS and the chat activity, and Gradle merges them.

Quick start

  1. Create an app at app.hailbell.com with platform Android. Copy its App ID (app_...). The App ID is public and belongs in your code. For push, enter the Firebase project ID from your google-services.json in the dashboard's push settings.
  2. Configure once in Application.onCreate(), then open the chat from a button:
import com.hailbell.Hailbell

Hailbell.configure(this, "app_XXXXXXXX")
Hailbell.setMetadata(mapOf("plan" to "free"))   // shown beside the chat in the dashboard

// A "Chat with us" button
Hailbell.open(activity)
  1. For replies as push notifications, pass FCM tokens and messages from your FirebaseMessagingService:
class SupportPushService : FirebaseMessagingService() {
    override fun onNewToken(token: String) = Hailbell.setPushToken(token)
    override fun onMessageReceived(message: RemoteMessage) {
        val handled = HailbellPush.handleMessage(this, message.data, message.notification?.title, message.notification?.body)
        if (!handled) {
            // your own pushes
        }
    }
}

Pass every message to handleMessage. Campaign pushes are data-only and the SDK shows them itself, and some Hailbell data messages are silent checks that must show nothing.

  1. On sign-out call Hailbell.reset(). When a user deletes their account, call Hailbell.deleteData() and stop if it throws.

The full guide, with entry points, signed-in users, offers, the Play data safety answers and a checklist, is at hailbell.com/docs. AI coding agents can install the Hailbell skill from https://hailbell.com/skills/hailbell/SKILL.md.

Hailbell

API Use
Hailbell.configure(context, appId, baseUrl) Call once in Application.onCreate(). Also creates the reply notification channel.
Hailbell.open(activity) Opens the chat as a full-height sheet in its own activity.
Hailbell.unreadCount: StateFlow<Int> Replies not yet read; use it for a badge.
Hailbell.teamPhoto: Bitmap? Deprecated: set the photo in the dashboard. A bundled photo shows only until the chat hears from Hailbell, and never once the dashboard signs replies as the team, turns photos off or sets a photo for this app.
Hailbell.identify(userId, name, email, identityToken) Who the user is. Only identityToken, an HS256 JWT signed with the app's identity secret, links the chat across devices.
Hailbell.identify(name, email) { firebaseIdToken } For apps on Firebase Auth: the lambda returns the current ID token. Hailbell verifies it and uses the Firebase uid as the user id.
Hailbell.asksForNotifications Default true. After the first message, the chat offers to turn on notifications if they're off.
Hailbell.darkMode Default null, which follows the phone. Set true for an always-dark app so the chat matches it.
Hailbell.setMetadata(map) Context shown beside the chat, merged with what you sent before. appVersion, os and locale are sent automatically.
Hailbell.track(event, properties) A signal shown beside the chat, such as paywall_decline or chat_opened.
Hailbell.setPaywallPlacements(list) The placements an offer can open.
Hailbell.onPaywall (placement, purchased) -> Unit: open the paywall, and call purchased() if they buy.
Hailbell.setPushToken(token) The FCM registration token.
Hailbell.reset() On sign-out: clears the identity and the cached chat.
Hailbell.shakeToReport Default false. When true, shaking the phone opens the bug report screen.
Hailbell.trackScreen(name) Remembers the screen the user is on. A bug report carries the last 10.
Hailbell.reportBug(activity) Takes a screenshot and opens the bug report screen, for a "Report a problem" button.
Hailbell.log(message) Adds a line to the app's log. A bug report carries the last 50, cleaned of secrets.
Hailbell.logRequest(method, url, status) Records a failed request (status 0 for no answer, or 400 and up). A bug report carries the last 10.
Hailbell.networkInterceptor An OkHttp interceptor that calls logRequest for you.
suspend Hailbell.deleteData() Deletes the user's chat, images and details from Hailbell. Throws if the server can't be reached.

Message, Attachment, Card and BugReport are public, for apps that read the conversation.

Bug reports

Bug reports are opt-in. Turn on shake to report, name your screens, and add a "Report a problem" button if you like:

Hailbell.shakeToReport = true          // shaking the phone opens the report screen
Hailbell.trackScreen("Settings")       // call when each screen appears
Hailbell.reportBug(activity)           // for a "Report a problem" button
Hailbell.log("Restore tapped")         // a line for the report's log

The report screen shows a screenshot of the current screen, which the user can mark up with their finger or remove, and a box for what went wrong. When they tap Send, the report carries the screenshot, their text, the app version and build, the device model, the Android version, the language and the last 10 screens from trackScreen. It lands in the normal chat inbox, tagged as a bug report, and the inbox has a Bugs filter. There is no session replay, and nothing is captured or sent until the user taps Send. The accelerometer is only used while shakeToReport is on and the app is on screen.

Reports can also carry the app's own log and its failed network requests, so you can see what went wrong without asking. Both are opt-in and kept in memory only, on the phone, until the user sends a report:

Hailbell.log("Restore tapped")                                   // keeps the last 50 lines
Hailbell.logRequest("POST", "https://api.example.com/v1/receipt", 422)  // keeps the last 10 failures

// Or let OkHttp record failed requests for you:
val client = OkHttpClient.Builder().addInterceptor(Hailbell.networkInterceptor).build()

logRequest ignores requests that worked. A failed one is status 400 or more, or 0 when there was no answer (offline, timed out); the interceptor records those and passes the error on. Only the method, the address and the status are kept, never bodies or headers. Before anything is kept, addresses lose their query strings and secret-looking parts (emails, tokens, long ids), and log lines lose passwords, tokens, keys and "Bearer" values. The server runs the same cleanup again.

A teammate (from the dashboard, Discord, Telegram or Slack) or the support AI can also ask for a report in the chat: the customer sees a "Send a bug report" button, which opens the report screen without a screenshot, since a screenshot of the chat would show nothing useful. They can add one from their photos with "Add a screenshot".

HailbellPush

API Use
handleMessage(context, data, title, body): Boolean Call from FirebaseMessagingService.onMessageReceived. Shows a reply that arrived with the app open, unless the chat is on screen. Returns false for pushes that aren't Hailbell's.
isHailbell(data) True when an FCM data map came from Hailbell.
canNotify(context) Whether notifications are allowed for the app and the reply channel.
setTags(map) Key/value data for segments; null removes a tag.
setMarketing(enabled) / optOut() Promotional opt-in, or stop all pushes to this device.
offersChannel The channel for campaign pushes. Set it before Hailbell.configure to reuse a channel your app already has.

Files

File What it holds
Hailbell.kt Public entry point, session and retry
Client.kt, Models.kt HTTP client, install id, public models
ChatModel.kt Chat state: cache, paging, sending, uploads, ticks, typing, presence, cards, the WebSocket
ChatActivity.kt, ChatScreen.kt The sheet and the chat screen, with the header
MessageRow.kt, Components.kt, Topics.kt, Composer.kt Bubbles, cards, avatars, topics, ticks and the composer
ChatTheme.kt Colours from the dashboard's Chat design
ImageEncoder.kt Photo resizing to JPEG under 1.4 MB
NotifyAsk.kt, Push.kt The notification offer, the reply channel and HailbellPush
BugReports.kt, BugReportActivity.kt Tracked screens, shake detection, the screenshot and the report screen with markup
L10n.kt The chat's own words in 14 languages

Building from source

./gradlew :hailbell:assembleRelease builds the library with JDK 17 or later and the Android SDK. ./gradlew :hailbell:testReleaseUnitTest runs the unit tests.

Edited and deleted replies

Your team can edit or delete a reply after sending it (dashboard). The chat shows the new wording, with "Edited" under it when the customer had already read the old one, and "This message was deleted" in place of a deleted reply, in the customer's language. Both arrived in 1.4.0; earlier versions show the new wording without the label, and a deleted reply as that line in English. Message.edited and Message.deleted carry the two flags. Nothing to set up.

Support and license

Questions: [email protected], or the chat on hailbell.com.

MIT. See LICENSE.

About

Hailbell for Android: in-app support chat and push notifications (Kotlin, Compose)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages