Chatbox SDKs
Give Feedback

Android SDK

Updated on September 21, 2021

The Android Chatbox SDK can be installed in a few lines of codes in any Android app. The Android SDK is native, and looks exactly the same as the Web-based chatbox.

Video Tutorial

Introduction Video


Installation

1. Get your Website ID

Go to your Crisp Dashboard, and copy your Website ID:

Copy your Website ID

2. Setup repositories

Add our bintray in your repositories:

repositories {
    // Keep your previous repositories
    mavenCentral()
    // Even with jcenter end of life, we still need it because we're using exoplayer 2.13.0 for compatibility issue,
    // which is not hosted on Google nor Central maven repos (see https://github.com/google/ExoPlayer/issues/5246)
    jcenter()
}

3. Add Crisp dependency

Add the Crisp SDK in your dependencies:

dependencies {
    implementation 'im.crisp:crisp-sdk:1.0.7'
}

4. Setup multidex

Configure your app for multidex:

android {
    defaultConfig {
        multiDexEnabled true
    }
}
dependencies {
    // If you're using AndroidX
    implementation 'androidx.multidex:multidex:2.0.1'
    // If you're not using AndroidX
    implementation 'com.android.support:multidex:1.0.3'
}

5. Initiate the application class

Initialize the library in your Application subclass:

public class Initializer extends MultiDexApplication {
    @Override
    public void onCreate() {
        super.onCreate();

        // Replace it with your WEBSITE_ID
        // Retrieve it using https://app.crisp.chat/website/[YOUR_WEBSITE_ID]/
        Crisp.configure(getApplicationContext(), "7598bf86-9ebb-46bc-8c61-be8929bbf93d");
    }
}

6. Include Crisp in your activity

You can for instance start Crisp after a click on a button:

Intent crispIntent = new Intent(this, ChatActivity.class);
startActivity(crispIntent);

Availables APIs

  • CrispSDK.configure(Context applicationContext, String websiteID) — Configures the next session with the websiteID
  • CrispSDK.setTokenID(String tokenID) — Assigns the next session with a tokenID
  • CrispSDK.resetChatSession() — Reset the session
  • CrispSDK.setUserAvatar(String avatar) — Sets the user avatar
  • CrispSDK.setUserCompany(Company company) — Sets the user company
  • CrispSDK.setUserEmail(String email) — Sets the user email (note: if email is invalid, this method will return false and the value will not be set)
  • CrispSDK.setUserNickname(String nickname) — Sets the user name
  • CrispSDK.setUserPhone(String phone) — Sets the user phone (note: if phone is invalid, this method will return false and the value will not be set)
  • CrispSDK.setSessionBool(String key, boolean value) — Sets a session data bool
  • CrispSDK.setSessionInt(String key, int value) — Sets a session data int
  • CrispSDK.setSessionString(String key, String value) — Sets a session data string
  • CrispSDK.setSessionSegment(String segment) — Sets a session segment
  • CrispSDK.pushSessionEvent(SessionEvent event) — Pushes a session event

Important notes

If a chat is ongoing, calls to Crisp.setUser, Crisp.setSession & Crisp.pushSessionEvent methods are performed right away. Otherwise, they will be performed when the session is joined unless either Crisp.resetChatSession or Crisp.configure (with a different websiteID than the current) has been called since.
If a chat is ongoing, calls to Crisp.configure, Crisp.setTokenID & Crisp.resetChatSession methods are postpone until the ChatActivity is closed either by the close or the back button.