Skip to content

Integration guide

Asklify + Android (Kotlin)

A WebView pointed at the hosted chat page gives you the full assistant inside a native activity or fragment.

Prerequisite: an Asklify project with some knowledge added — the quickstart covers that in a couple of minutes. You'll need your public project ID (pub_...) from Widget → Install.
1

Add the INTERNET permission

AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET" />
2

Add the chat activity

Register SupportChatActivity in your manifest and start it from a “Help” menu item.

Ready-to-use template

Copy, paste, replace the project ID — that's the whole integration:

SupportChatActivity.kt
package com.example.app

import android.annotation.SuppressLint
import android.os.Bundle
import android.webkit.WebView
import android.webkit.WebViewClient
import androidx.appcompat.app.AppCompatActivity

class SupportChatActivity : AppCompatActivity() {

    private lateinit var webView: WebView

    @SuppressLint("SetJavaScriptEnabled")
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        webView = WebView(this).apply {
            settings.javaScriptEnabled = true
            settings.domStorageEnabled = true // persists the visitor's conversation
            webViewClient = WebViewClient()
            loadUrl("https://app.asklify.in/widget/pub_YOUR_PROJECT_ID")
        }
        setContentView(webView)
    }

    override fun onBackPressed() {
        if (webView.canGoBack()) webView.goBack() else super.onBackPressed()
    }
}

Customization

All appearance and behavior — name, greeting, colors, theme, position, suggested questions — is configured in your dashboard under Widget settings and applies instantly without redeploying. See the widget configuration reference.

Event handling

To react to what happens in conversations — a chat starting, a customer requesting a human, feedback submitted — subscribe to webhooks. For fully custom experiences, the REST API exposes chat with streaming, knowledge search, and conversation transcripts.

Best practices

  • domStorageEnabled keeps the visitor's conversation history across sessions.
  • For Jetpack Compose, wrap the same WebView in an AndroidView composable.
  • Native UI instead? Call the REST /chat API from your backend service, not directly from the app.
Never bundle a secret API key (sk_...) in a mobile app — extractable in minutes. Mobile apps should use the hosted chat page (as above) or talk to your own backend, which holds the key.

Troubleshooting

  • Blank page — javaScriptEnabled must be true; the chat UI requires JS.
  • Input focus issues — add android:windowSoftInputMode="adjustResize" to the activity in the manifest.

Still stuck? Check the error reference or email hello@asklify.in.