Home
/
Desk
/
Android

Create your first ticket

Sendbird Desk SDK for Android lets you easily initialize, configure, and build the customer-support related functionalities to a client app. When a customer asks for help through live, in-app support built with the Desk SDK, agents receive those messages as tickets and can start a conversation on the Sendbird Dashboard. This page walks you through the quick steps to create your first ticket by installing and initializing the Desk SDK.

Note: As Sendbird Desk works based on Sendbird Chat, the interaction between users is built and provided by Sendbird Chat.


Requirements

The requirements of the Desk SDK for Android are as below:

  • Android 4.0 (API level 14) or later
  • Java 7 or later
  • Gradle 3.4.0 or later

Prerequisite

Before installing Sendbird Desk SDK, contact our sales team to enable Sendbird Desk on your dashboard. If you don't have an account for the Sendbird Dashboard, sign up to create a Sendbird application first.

Note: A Sendbird application gets paired up with one client app. Agents can support customers across all platforms, but customers from different Sendbird applications are excluded because all data is limited to the scope of a single application.


Get started

Step 1 Install using Gradle

You can install the Desk SDK for Android using Gradle.

  1. Add the following code block to your root build.gradle file.
build.gradle
Light Color Skin
Copy
allprojects {
    repositories {
        ...
        maven { url "https://repo.sendbird.com/public/maven" }
    }
}

Note: Make sure the above code block isn't added to your module bundle.gradle file.

  1. Add the following dependency to your module build.gradle file.
build.gradle
Light Color Skin
Copy
dependencies {
    implementation 'com.sendbird.sdk:sendbird-android-sdk:3.0.165'
    implementation 'com.sendbird.sdk:sendbird-desk-android-sdk:1.0.14'
}

Step 2 Initialize the Desk SDK

  1. Initialize a SendBirdDesk instance when launching a client app.
  2. Copy the APP_ID of your Sendbird application from the dashboard. The same APP_ID must be used for both Chat and Desk SDKs.
  3. Call the SendBird.init() method using the copied APP_ID within the Application.onCreate().
  4. Call the SendBirdDesk.init() method within the Application.onCreate().
Light Color Skin
Copy
// Initialize SendBirdDesk instance to use APIs in your app.
public class MyApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        SendBird.init(APP_ID, this);
        SendBirdDesk.init();
    }
}

Note: If you call the SendBirdDesk.init() again after calling the SendBird.init() with a different APP_ID, all existing Desk-related data in the client app will be deleted.

Step 3 Authenticate a customer from Sendbird Chat

Every ticket in Sendbird Desk is mapped to a group channel in Sendbird Chat because the Desk SDK handles messages within a ticket based on Sendbird Chat. Therefore, to receive a message sent by a customer from Sendbird Chat, you need to authenticate the user using the SendBird.connect() and the SendBird.authenticate() methods with their user ID used in Sendbird Chat.

Light Color Skin
Copy
// Use a user ID that is unique to your Sendbird application.
SendBird.connect(USER_ID, ACCESS_TOKEN, new SendBird.ConnectHandler() {
    @Override
    public void onConnected(User user, SendBirdException e) {
        if (e != null) {
            // Handle error.
        }

        // Use the same user ID and access token used in the SendBird.connect().
        SendBirdDesk.authenticate(USER_ID, ACCESS_TOKEN, new SendBirdDesk.AuthenticateHandler() {
            @Override
            public void onResult(SendBirdException e) {
                if (e != null) {
                    // Handle error.
                }

                // SendBirdDesk is now initialized,
                // and the customer is authenticated and connected to Sendbird server.
                ...
            }
        });

        ...
    }
});

Step 4 Create your first ticket

Implement the Ticket.create() method to create a ticket either before or after the customer’s initial message. Once a ticket is successfully created on the Desk server, you can access the ticket and its channel in the ticket.getChannel() through the callback from the server. Until a customer sends the first message, agents can’t see the ticket on the dashboard. When a conversation starts, the ticket is assigned to an available agent by the Desk server while messages are sent and received through the Chat SDK.

Light Color Skin
Copy
Ticket.create(TICKET_TITLE, USER_NAME, new Ticket.CreateHandler() {
    @Override
    public void onResult(Ticket ticket, SendBirdException e) {
        if (e != null) {
            // Handle error.
        }

        // The ticket is created.
        // The customer and agent can chat with each other by sending a message through the ticket.channel.sendUserMessage() or sendFileMessage().
        ...
    }
});

Note: Because the SendBird instance in a client app is connected to Sendbird server, Desk related events are delivered to the Chat SDK's event handlers. The event handlers receive callbacks from the server through the onMessageDelivered(), onUserJoined(), and other event callback methods.