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

Confirmation request message

Copy link

With Confirmation request message, you can ask your customers for confirmation of ticket closing by providing two different options such as the confirm or decline buttons. The message is customizable in Settings > Triggers on the Sendbird Dashboard.

Note: Depending on the permissions set in Settings > Automation on the Sendbird Dashboard, agents can directly close a ticket or close a ticket after sending the confirmation request message.


Message types

Copy link

Confirmation request messages can have three types of states as below:

Confirmation states

Copy link
StateDescription

WAITING

Set when an agent sends a confirmation request message.

CONFIRMED

Set when a customer confirms to close a ticket.

DECLINED

Set when a customer declines to close a ticket.


Send confirmation of ticket closing

Copy link

To reply to a confirmation request message, call the SBDSKTicket.confirmEndOfChat() method on a client app. When a customer chooses one of the two options, the response true or false is sent to the Desk server as CONFIRMED or DECLINED, respectively.

SBDSKTicket.confirmEndOfChat(with: USER_MESSAGE, confirm: true|false) { (ticket, error) in
    guard error == nil else {
        // Handle error.
    }

    // You can implement your code here to customize the UI of the message.
}

Update the confirmation request message

Copy link

The Sendbird server notifies the updates to your app through the channel(_:didUpdate:) method of BaseChannelDelegate. You can implement your code to customize the UI of the updated message depending on the confirmation 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 isClosureInquired = (type == "SENDBIRD_DESK_INQUIRE_TICKET_CLOSURE")
            if isClosureInquired {
                let closureInquiry = dataObject?["body"] as? [String: Any]
                let state = closureInquiry?["state"] as? String

                switch state {
                    case "CONFIRMED":
                    // Implement your code for the UI when a customer confirms to close a ticket.
                    case "DECLINED":
                    // Implement your code for the UI when a customer declines to close a ticket.
                    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_INQUIRE_TICKET_CLOSURE",
    "body": {
        "state": "CONFIRMED"
    }
}