Desk / Android
Home
/
Desk
/
Android

Create your first ticket

Once the Desk SDK is installed into your client app, you can now create a ticket that indicates a customer inquiry and where an agent and a customer can chat with each other. Follow the step-by-step instructions below to create your first ticket.


Step 1: Initialize the Desk SDK

First, aSendBirdDesk instance must be initialized when launching a client app. Call the SendBird.init() and SendBirdDesk.init() methods within the Application.onCreate(). The Sendbird.init() should be called first by the APP_ID of your Sendbird application in the dashboard. However, if you initiate the SendBirdDesk again with a SendBird instance initiated by a different APP_ID, all existing Desk-related data in the client app will be cleared.

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: Built with Sendbird Chat SDK, Sendbird Desk SDK is a plugin that handles customer inquiries through tickets. Messages within tickets are dealt with by Sendbird Chat platform, and every ticket is mapped to a group channel in Sendbird Chat. Because of this interaction, the same APP_ID should be used for both Desk and Chat SDKs.


Step 2: Authenticate a customer

If a customer comes from Sendbird Chat platform, authenticate them using the authenticate() method with their user IDs. If a customer comes from social media such as Instagram or Facebook, they are automatically registered in the dashboard with their social media accounts without any authentication process.

Light Color Skin
Copy
// The USER_ID below should be 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 3: Create a 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 in 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 in 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 agents can chat with each other by sending a message through the ticket.channel.sendUserMessage() or sendFileMessage().
        ...
    }
});