Desk SDKs JavaScript v1
Desk SDKs JavaScript
Desk SDKs
JavaScript
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 request message 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 Ticket.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. Meanwhile, the instanceConfirmEndOfChat method can also be used when closing a ticket.

// confirmEndOfChat
Ticket.confirmEndOfChat(USER_MESSAGE, 'yes'|'no', (ticket, error) => {
    if (error) {
        // Handle error.
    }

    ...

// instanceConfirmEndOfChat
const t = new Ticket();
t.instanceConfirmEndOfChat(msg, 'yes', (ticket, error) => {
  console.log(ticket, error);
});

Update the confirmation request message

Copy link

Sendbird server notifies the updates to your app through the onMessageUpdate() method of the channel event handler. You can implement your code to customize the UI of the updated message depending on the confirmation status.

channelHandler.onMessageUpdated = (channel, message) => {
    SendBirdDesk.Ticket.getByChannelUrl(channel.url, (ticket, error) => {
        if (error) {
            // Handle error.
        }

        let data = JSON.parse(message.data);
        const isClosureInquired = data.type === SendBirdDesk.Message.DataType.TICKET_INQUIRE_CLOSURE;
        if (isClosureInquired) {
            const closureInquiry = data.body;
            switch (closureInquiry.state) {
                case SendBirdDesk.Message.ClosureState.WAITING:
                    // Implement your code for the UI when there is no response from a customer.
                    break;
                case SendBirdDesk.Message.ClosureState.CONFIRMED:
                    // Implement your code for the UI when a customer confirms to close the ticket.
                    break;
                case SendBirdDesk.Message.ClosureState.DECLINED:
                    // Implement your code for the UI when a customer declines to close the ticket.
                    break;
            }
        }
    });
};

message.data

Copy link

You can find the stringified JSON object of the following in the message.data property within the onMessageUpdate() of the channel event handler.

{
    "type": "SENDBIRD_DESK_INQUIRE_TICKET_CLOSURE",
    "body": {
        "state": "CONFIRMED"
    }
}