Desk / JavaScript
Home
/
Desk
/
JavaScript

Authentication

In order to use features of the Desk SDK in your client apps, the SendBirdDesk instance should be connected with Sendbird server, and customers from Sendbird Chat should go through the user authentication with the Desk server using the SendBirdDesk.authenticate(). Once authenticated, customers can live-chat with agents based on Sendbird Chat platform.

Note: Customers can request support from various types of channels. They can submit tickets from in-app chats or social media such as Facebook, Instagram and Twitter. Customers from social media are automatically registered in your dashboard with their social media accounts without any authentication process.


Initialize the Desk SDK with APP_ID

First, a SendBirdDesk instance must be initialized when launching a client app. Pass the SendBird instance that is already initialized 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.
SendBirdDesk.init(SendBird);

Note: Built with Sendbird Chat platform, 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 of Sendbird Chat. Because of this interaction, the same APP_ID should be used for both Desk and Chat SDKs.

It is possible to use the Chat SDK only or both Chat and Desk SDKs together in your client app depending on the chat service you want to provide.

Usage of SDKs

SDKUsed for

Chat SDK

In-app messenger where customers can chat with each other.

Chat and Desk SDKs

Tickets where customers can chat with agents.


Authenticate to the Desk server

To use the interfaces and methods provided in the SendBirdDesk instance, a customer from Sendbird Chat must be connected to Sendbird server by using the authenticate() method. If a customer comes from social media such as Instagram and Facebook, they are automatically registered in your dashboard with their social media accounts without any authentication process.

Note: Customers from Sendbird Chat platform signifies users who are already authenticated with the Chat SDK. If you’re implementing Chat SDK and Desk SDK at the same time, connect a user to Sendbird server with their user ID and access token first.

Light Color Skin
Copy
// The USER_ID below should be unique to your Sendbird application.
const sb = new SendBird({ appId: APP_ID });
sb.connect(USER_ID, ACCESS_TOKEN, (user, error) => {
    if (error) {
        // Handle error.
    }

    SendBirdDesk.init(SendBird);
    SendBirdDesk.authenticate(USER_ID, ACCESS_TOKEN, (user, error) => {
        if (error) {
            // Handle error.
        }

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

    ...
});