Desk SDKs iOS v1
Desk SDKs iOS
Desk SDKs
iOS
Version 1

CSAT message

Copy link

Customer satisfaction rating (CSAT) message enables your customers to give a score or leave a comment on the support provided within a ticket. The satisfaction rating scale ranges from 1 to 5, and the average CSAT score an agent or a team received can be found in Reports on the Sendbird Dashboard.


Prerequisite

Copy link

To send a CSAT message to a client app, turn on the Customer satisfaction rating feature on your dashboard first. The message is customizable in Settings > Automation on the dashboard.


Message types

Copy link

CSAT messages can have two types of states as below:

Confirmation states

Copy link
StateDescription

WAITING

Set when an agent sends a CSAT message.

CONFIRMED

Set when a customer sends a response to a CSAT message.


Submit feedback

Copy link

To submit feedback from a client app, call the ticket.submitFeedback() method on the client app. When a customer replies to the CSAT message, the state of the message changes from WAITING to CONFIRMED.

ticket.submitFeedback(with: USER_MESSAGE, score: SCORE, comment: COMMENT) { (ticket, error) in
    guard error == nil else {
        // Handle error.
    }
    ...
}
Arguments
RequiredTypeDescription

USER_MESSAGE

string

Specifies a text message for a CSAT message.

SCORE

int

Specifies the score of a satisfaction rating scale. The value ranges from 1 to 5 and can be nil.

COMMENT

string

Specifies a comment on the provided support. The value can be nil.


Update the CSAT message

Copy link

The Sendbird server notifies the updates to client apps through the channel(_:didUpdate:) delegate method of BaseChannelDelegate. You can implement your code to customize the UI of the updated message depending on the request status.

func channel(_ channel: BaseChannel, didUpdate message: BaseMessage) {
    SBDSKTicket.getByChannelURL(channel.channelURL) { (ticket, error) in
        guard error == nil else {
            // Handle error.
        }

        if let data = Data(base64Encoded: message.data), data.isEmpty == false {
            let dataObject = try? JSONSerialization.jsonObject(with: data, options: []) as? [String: Any]
            let type = dataObject?["type"] as? String

            let isFeedbackMessage = (type == "SENDBIRD_DESK_CUSTOMER_SATISFACTION")
            if isFeedbackMessage {
                let closureInquiry = dataObject?["body"] as? [String: Any]
                let state = closureInquiry?["state"] as? String

                switch state {
                    case "CONFIRMED":
                    // Implement your code for the UI when there is a response from a customer.
                    case "WAITING":
                    // Implement your code for the UI when there is no response from a customer.
                    default: break
                }
            }
        }
    }
}

message.data

Copy link

You can find the stringified JSON object in the message.data property as shown below within the channel(_:didUpdate:) delegate method of BaseChannelDelegate.

{
    "type": "SENDBIRD_DESK_CUSTOMER_SATISFACTION",
    "body": {
        "state": "CONFIRMED",
        "customerSatisfactionScore": 3,                             // Score ranges from 1 to 5
        "customerSatisfactionComment": "It was really helpful :)."  // Comment is optional.
    }
}