You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SendBird Desk SDK Integration Guide for JavaScript
2
-
===========
1
+
# SendBird Desk SDK Integration Guide for JavaScript
2
+
3
3
SendBird Desk is a chat customer service platform built on SendBird SDK and API.
4
4
5
5
Desk JavaScript SDK provides customer-side integration on your own application, so you can easily implement **ticketing system with chat inquiry**. Desk JavaScript SDK requires **SendBird JavaScript SDK 3.0.55 or higher**.
-[Count of opened tickets](#count-of-opened-tickets)
16
+
-[Loading ticket list](#loading-ticket-list)
17
+
-[Handling ticket event](#handling-ticket-event)
18
+
-[Rich messages](#rich-messages)
19
+
-[Confirm end of chat](#confirm-end-of-chat)
20
+
-[Reopen a closed ticket](#reopen-a-closed-ticket)
21
+
-[Ticket Feedback](#ticket-feedback)
22
+
-[URL preview](#url-preview)
23
+
20
24
## Installation
21
25
22
26
Before setup, you need to get SendBird App ID at [SendBird Dashboard](https://dashboard.sendbird.com). For using Desk solution, you may upgrade the plan. For more information, please contact [sales team](https://sendbird.com/contact-sales).
23
27
24
28
Installing the Desk SDK is straightforward if you're familiar with npm. Run the following command at the project path.
29
+
25
30
```
26
31
~$ cd /path/to/your-project
27
32
~$ npm install --save sendbird-desk
@@ -31,39 +36,42 @@ Installing the Desk SDK is straightforward if you're familiar with npm. Run the
31
36
32
37
> Basically SendBird Desk SDK is a plugin to handle tickets. You have to handle chat messages through SendBird SDK. Ticket is newly introduced in SendBird Desk SDK to support customer service ticketing system. Every ticket will be assigned to the appropriate agents and it will be mapped to a SendBird SDK channel, so you can implement real-time messaging on tickets with SendBird SDK.
33
38
34
-
35
39
## Authentication
36
40
37
41
Connecting to SendBird platform via SendBird SDK is essential for real-time messaging. The official guide to SendBird SDK authentication is [here](https://docs.sendbird.com/android#authentication_2_authentication).
38
42
Authentication in SendBird Desk is done by calling `SendBirdDesk.authenticate()`. The following is an example for SendBird SDK connection and SendBird Desk SDK authentication.
Now your customers are ready to create tickets and start inquiry with your agents!
52
57
53
58
## Setting customer customFields
54
59
55
60
Customer information could be kept in `customFields`. `setCustomerCustomFields()` in `SendBirdDesk` lets the SDK set the `customFields` of the current customer. The `customFields` columns should be defined in SendBird Dashboard beforehand. Otherwise, the setting would be ignored.
61
+
56
62
```js
57
-
SendBirdDesk.setCustomerCustomFields({
58
-
gender:'male',
59
-
age:20
60
-
},
61
-
err=> {
62
-
if (!err) {
63
-
// customer's customFields is rightly set
64
-
// (or a certain key could get ignored if the key is not defined yet)
65
-
}
66
-
});
63
+
SendBirdDesk.setCustomerCustomFields(
64
+
{
65
+
gender:"male",
66
+
age:20
67
+
},
68
+
err=> {
69
+
if (!err) {
70
+
// customer's customFields is rightly set
71
+
// (or a certain key could get ignored if the key is not defined yet)
`Ticket.create()` has 2 more parameters `groupKey` and `customFields`. The values could be evaluated when a ticket is created though it's used only in Dashboard currently. `groupKey` is the key of an agent group so that the ticket is assigned to the agents in that group. `customFields` holds customizable data for the individual ticket. The below is an example.
83
91
84
92
```js
85
-
Ticket.create(ticketTitle, userName,
86
-
'cs-team-1', // groupKey
87
-
{
88
-
'text':'hello',
89
-
'number':14,
90
-
'select':'option2'
91
-
}, // customFields
92
-
(ticket, err) => {
93
+
Ticket.create(
94
+
ticketTitle,
95
+
userName,
96
+
"cs-team-1", // groupKey
97
+
{
98
+
text:"hello",
99
+
number:14,
100
+
select:"option2"
101
+
}, // customFields
102
+
(ticket, err) => {
93
103
// Ticket is created with groupKey 'cs-team-1' and customFields.
94
-
});
104
+
}
105
+
);
95
106
```
96
107
97
108
> Note: each key in `customFields` should be preregistered in Dashboard. Otherwise, the key would be ignored.
98
109
99
110
## Count of opened tickets
111
+
100
112
When you need to display opened ticket count in your application, use `Ticket.getOpenCount()`.
113
+
101
114
```js
102
115
Ticket.getOpenCount((res, err) => {
103
-
constcount= res;
104
-
// do something with the value
116
+
constcount= res;
117
+
// do something with the value
105
118
});
106
119
```
107
120
108
121
## Loading ticket list
122
+
109
123
Retrieving ticket list is essential for inbox. SendBird Desk SDK provides `Ticket.getOpenedList()` and `Ticket.getClosedList()` to get the list of open/closed ticket. Open ticket list and closed ticket list can be loaded as below:
124
+
110
125
```js
111
126
Ticket.getOpenedList(offset, (res, err) => {
112
-
consttickets= res;
113
-
// offset += tickets.length; for the next tickets.
114
-
// here is to display tickets on inbox.
127
+
consttickets= res;
128
+
// offset += tickets.length; for the next tickets.
129
+
// here is to display tickets on inbox.
115
130
});
116
131
```
117
132
118
133
```js
119
134
Ticket.getClosedList(offset, (res, err) => {
120
-
consttickets= res;
121
-
// offset += tickets.length; for the next tickets.
122
-
// here is to display tickets on inbox.
135
+
consttickets= res;
136
+
// offset += tickets.length; for the next tickets.
137
+
// here is to display tickets on inbox.
123
138
});
124
139
```
125
140
126
141
> Note: Once you set `customFields` to tickets, you can put `customFieldFilter` to `getOpenedList()` and `getClosedList()` in order to filter the tickets by `customFields` values.
127
142
128
143
## Handling ticket event
144
+
129
145
SendBird Desk SDK uses predefined AdminMessage custom type which can be derived by calling `message.customType`. Custom type for Desk AdminMessage is set to `SENDBIRD_DESK_ADMIN_MESSAGE_CUSTOM_TYPE`. And there are sub-types which indicate ticket events: assign, transfer, and close. Each event type is located in `message.data` which looks like below.
You can check out these messages in `ChannelHandler.onMessageReceived()`.
137
154
138
155
## Rich messages
@@ -142,7 +159,7 @@ Rich message is a special message that holds custom content. You can distinguish
142
159
-**`Confirm end of chat`** message notifies that the agent sent a confirm-end-of-chat request. When the user agrees with the closure, the ticket would be closed.
143
160
-**`URL preview`** message contains web URL which is filled with image and description.
144
161
145
-
###Confirm end of chat
162
+
## Confirm end of chat
146
163
147
164
Confirm end of chat message is initiated from the agent to inquire closure of ticket. The message has 3 states which are `WAITING`, `CONFIRMED`, `DECLIEND`. When agent sends confirm end of chat message, its state is set to `WAITING`. Customer can answer to the inquiry as `YES` or `NO` which leads to `CONFIRMED` state and `DECLINED` state accordingly. You can check the state by looking `message.data`. The format looks like below:
148
165
@@ -159,29 +176,39 @@ Once customer replies to the inquiry, the message would be updated. `SendBirdDes
The closed ticket could be reopened with `reopen()` function in `Ticket`.
204
+
205
+
```js
206
+
closedTicket.reopen((openTicket, err) => {
207
+
// update the ticket list here
208
+
});
182
209
```
183
210
184
-
###Ticket Feedback
211
+
## Ticket Feedback
185
212
186
213
If Desk satisfaction feature is on, a message would come after closing the ticket. The message is for getting customer feedback including score and comment. The data of satisfaction form message looks like below.
187
214
@@ -200,26 +227,26 @@ Once the customer inputs the score and the comment, the data could be submitted
To send URL preview message, you should send a text message with URL, extract preview data, and update it with the preview data. Use `channel.updateUserMessage(messageId, text, messageData, customType, callback)` for the update operation. The format of `messageData` looks like below:
225
252
@@ -237,4 +264,4 @@ To send URL preview message, you should send a text message with URL, extract pr
237
264
}
238
265
```
239
266
240
-
You may get the preview message in `ChannelHandler.onMessageUpdated()` or `channel.getPreviousMessagesByTimestamp()` for URL preview rendering.
267
+
You may get the preview message in `ChannelHandler.onMessageUpdated()` or `channel.getPreviousMessagesByTimestamp()` for URL preview rendering.
Copy file name to clipboardExpand all lines: package.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
{
2
2
"name": "sendbird-desk",
3
-
"version": "1.0.10",
3
+
"version": "1.0.11",
4
4
"description": "SendBird Desk SDK Integration Guide for JavaScript =========== SendBird Desk is a chat customer service platform built on SendBird SDK and API.",
0 commit comments