The first thing you need to do is adding the SDK in your project.

Alli SDK requires Android 4.4 (API level 19) or above.

Step 1. Download and import the SDK

  1. Download the SDK here.
  2. In Android Studio, go to File > New > New Module and import Alli SDK into your project:
  3. Add allisdk as a dependency in File > Project Structure > Dependencies.

Step 2. Add Alli SDK as dependency

Go to the build.gradle file for your app module and add Alli SDK as a dependency:

  dependencies {
    implementation project(":allisdk")

Step 3. Add app permissions and activities

  1. Add the following to the AndroidManifest.xml:
    <uses-permission android:name="android.permission.INTERNET"/>
  1. Add these activities to the application block in AndroidManifest.xml:
      android:configChanges="orientation|screenSize" />

Step 4. Configure Java 8 language feature

Make sure your Android plugin is 3.0.0 or higher and configure it as the following in the corresponding build.gradle file:

  android {
    // Configure only for each module that uses Java 8
    // language features (either in its source code or
    // through dependencies).
    compileOptions {
      sourceCompatibility JavaVersion.VERSION_1_8
      targetCompatibility JavaVersion.VERSION_1_8

Steps 5. Initialize Alli SDK

  1. Make sure the Alli SDK are imported in your main file:
  import ai.allganize.allisdk.Alli;
  import ai.allganize.allisdk.AlliErrorCode;
  import ai.allganize.allisdk.AlliEventHandler;
  1. Initialize the Alli library with your API Key by adding the following in onCreate() method in your application's first Activity class:
  protected void onCreate(Bundle savedInstanceState) {
    // new Alli(String apiKey, WebView webView, AlliEventHandler eventHandler, boolean showHeader, boolean showFooter, boolean showBackButton)
    // showHeader - optional, default: true, If you want to remove the header, turn off this option.
    // showFooter - optional, default: true, If you want to remove the footer, turn off this option.
    // showBackButton - optional, default: true, If you want to remove the back button on the header, turn off this option.
    alli = new Alli("YOUR_API_KEY", webView, this, true, true, false);

You can find your API Key by selecting “Settings” from the left navigation:

Step 6. Identify your users

For users logged into your app and you know who they are, you can tell Alli who they are. You can also set a temporary id for users who are not logged in.

In this example, the user id is USER-123 at the LANDING page:

  protected void onCreate(Bundle savedInstanceState) {
    notify.setText("NOT INITIALIZED");

    alli = new Alli("YOUR_API_KEY", webView, this);

Step 7. Create chat window

To create the chat window and start a conversation with your customer, make the following call:

alli.event(userId, placement, context);

You should implement the Alli chat window in the parent view controller and assign the parent view controller as the delegate property. It is vitally important that the ViewController passed to this call be the top-most view and that it be unobstructed by other views.

Parent view should have a minimum height and width.

Step 8: Delegate methods to handle Alli events

The following delegate methods will provide feedback on the chat conversation status:

  public protocol AlliEventHandler {
    // Called when initialized successfully. 
    // You may receive NOT_INITIALIZE_YET error if 
    // called before this event.
    void onInitialized(WebView view);

    // Called when chat started successfully.
    void onConversationStarted(WebView view, String userId, String placement, Object context);

    // Called when conversation did not start 
    // even when Alli.event was called.
    void onConversationNotStarted(_ view: WKWebView!, userId: String, placement: String, context: Any?)

    // Called when user has closed the chat 
    // window or Alli.close() is called.
    void onConversationClosed(WebView view, String userId, String placement, Objective context)

    void onError(WebView view, AlliErrorCode errorCode, String userId, String placement, Object context)

Step 9: Display chat interface

By default, the chat window should be set to hidden when no conversation is engaged:

  public void onConversationClosed(WebView view, String userId, String placement, Object context) { -> view.setVisibility(View.INVISIBLE));

When you receive AlliEventHandler.onConversationStarted event, changes the chat window to visible:

  public void onConversationStarted(WebView view, String userId, String placement, Object context) { -> view.setVisibility(View.VISIBLE));