Home
/
Desk
/
iOS

Create your first ticket

Sendbird Desk SDK for iOS 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 iOS are as below:

  • iOS 8.0 or higher
  • SendBird iOS SDK 3.0.90 or higher

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 from different platforms but can't support customers from different Sendbird applications because all data is limited to the scope of a single application.


Get started

Step 1 Install using CocoaPods

You can install the Desk SDK for iOS using CocoaPods.

  1. Add SendBirdDesk into your Podfile in Xcode as below:
Light Color Skin
Copy
platform :ios, '9.0'

target 'YourTarget' do

    use_frameworks!

    pod 'SendBirdDesk' // Add this line.
end
  1. Run pod install.
  2. Open YOUR_PROJECT.xcworkspace.

Step 2 Initialize the Desk SDK

  1. Initialize a SBDSKMain 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 SBDMain.initWithApplicationId() method using the copied APP_ID within the applicationDidFinishLaunching().
  4. Call the SBDSKMain.initializeDesk() method within the applicationDidFinishLaunching().
Light Color Skin
Copy
class AppDelegate: UIApplicationDelegate {
    func applicationDidFinishLaunching(_ application: UIApplication) {
        SBDMain.initWithApplicationId(APP_ID)
        SBDSKMain.initializeDesk()
    }
}

Note: If you initiate the SBDSKMain again with a SBDMain instance initiated by a different APP_ID, all existing Desk-related data in the client app is 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 customer using the SBDMain.connect() and the SBDMain.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.
SBDMain.connect(withUserId: USER_ID, accessToken: ACCESS_TOKEN) { (user, error) in
    guard error == nil else {
        // Handle error.
    }

    // Use the same user ID and access token used in the SBDMain.connect().
    SBDSKMain.authenticate(withUserId: USER_ID, accessToken: ACCESS_TOKEN) { (error) in
        guard error == nil else {
            // Handle error.
        }

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

Step 4 Create your first ticket

Implement the SBDSKTicket.createTicket() method to create a new 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.channel 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
SBDSKTicket.createTicket(withTitle: TITLE, userName: USER_NAME) { (ticket, error) in
    guard error == nil else {
        // 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 SBDMain instance in a client app is connected to Sendbird server, Desk related events are delivered to the Chat SDK's event delegates. The event delegates receive callbacks from the server through the channel:didReceiveMessage:, channel:userDidEnter:, and other event callback methods.