Skip to content

Commit 653b2c2

Browse files
committed
v1.0.8
1 parent a289cd4 commit 653b2c2

File tree

5 files changed

+72
-6
lines changed

5 files changed

+72
-6
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## Change Log
22

3+
### v1.0.8(Aug 23, 2019)
4+
* Added `setCustomerCustomFields()` in `SendBirdDesk`.
5+
* Added `submitFeedback()` in `Ticket`.
6+
37
### v1.0.7(Jul 12, 2019)
48
* Added `customFields` property to `Ticket`.
59

README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,22 @@ sb.connect(userId, accessToken, (res, err) => {
4848

4949
Now your customers are ready to create tickets and start inquiry with your agents!
5050

51+
## Setting customer customFields
52+
53+
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.
54+
```js
55+
SendBirdDesk.setCustomerCustomFields({
56+
gender: 'male',
57+
age: 20
58+
},
59+
err => {
60+
if (!err) {
61+
// customer's customFields is rightly set
62+
// (or a certain key could get ignored if the key is not defined yet)
63+
}
64+
});
65+
```
66+
5167
## Creating a new ticket
5268

5369
Creating a new ticket is as simple as calling `Ticket.create()`. Once you create the ticket, you can access to created ticket and channel in callback. Channel object can be found at `ticket.channel` so that you can send messages to the channel. For more information in sending messages to channel, see [SendBird SDK guide docs](https://docs.sendbird.com/android#group_channel_3_sending_messages).
@@ -163,6 +179,44 @@ channelHandler.onMessageUpdated = (channel, message) => {
163179
}
164180
```
165181

182+
### Ticket Feedback
183+
184+
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.
185+
186+
```js
187+
{
188+
"type": "SENDBIRD_DESK_CUSTOMER_SATISFACTION",
189+
"body": {
190+
"state": "WAITING" // also can have "CONFIRMED",
191+
"customerSatisfactionScore": null, // or a number ranged in [1, 5]
192+
"customerSatisfactionComment": null // or a string (optional)
193+
}
194+
}
195+
```
196+
197+
Once the customer inputs the score and the comment, the data could be submitted by calling `SendBirdDesk.Ticket.submitFeedback(message, score, comment, callback)`. Then updated message is going to be sent in `channelHandler.onMessageUpdate(channel, message)`.
198+
199+
```js
200+
channelHandler.onMessageUpdated = (channel, message) => {
201+
SendBirdDesk.Ticket.getByChannelUrl(channel.url, (ticket, err) => {
202+
if(err) throw err;
203+
let data = JSON.parse(message.data);
204+
const isFeedbackMessage = (data.type === SendBirdDesk.Message.DataType.TICKET_FEEDBACK);
205+
if(isFeedbackMessage) {
206+
const feedback = data.body;
207+
switch(feedback.state) {
208+
case SendBirdDesk.Message.FeedbacState.WAITING:
209+
// do something on WAITING
210+
break;
211+
case SendBirdDesk.Message.FeedbacState.CONFIRMED:
212+
// do something on CONFIRMED
213+
break;
214+
}
215+
}
216+
});
217+
}
218+
```
219+
166220
### URL preview
167221

168222
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:

SendBird.Desk.d.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Type Definitions for SendBird Desc SDK v1.0.7
2+
* Type Definitions for SendBird Desc SDK v1.0.8
33
* homepage: https://sendbird.com/
44
*/
55
export = SendBirdDesk;
@@ -19,6 +19,7 @@ interface SendBirdDeskStatic {
1919
authenticate(userId: String, accessToken: String, callback: SendBirdDesk.Callback): void;
2020
isDeskChannel(channel: SendBirdDesk.GroupChannel): Boolean;
2121
setDebugMode(): void;
22+
setCustomerCustomFields(customFields: Object, callback: SendBirdDesk.Callback): void;
2223
}
2324

2425
declare namespace SendBirdDesk {
@@ -54,6 +55,7 @@ declare namespace SendBirdDesk {
5455
getClosedList(offset: Number, customFieldFilter: Object, callback: TicketArrayCallback): void;
5556
getUrlPreview(url: String, callback: Callback): void;
5657
confirmEndOfChat(message: Object, confirmYN: String, callback: Callback): void;
58+
submitFeedback(message: Object, score: Number, comment: String, callback: Callback): void;
5759
new (json: Object): TicketInstance;
5860
}
5961
type TicketStatus = {
@@ -82,6 +84,7 @@ declare namespace SendBirdDesk {
8284
CustomType: MessageCustomType;
8385
DataType: MessageDataType;
8486
ClosureState: MessageClosureState;
87+
FeedbackState: MessageFeedbackState;
8588
};
8689
type MessageCustomType = {
8790
RICH_MESSAGE: String;
@@ -92,12 +95,17 @@ declare namespace SendBirdDesk {
9295
TICKET_ASSIGN: String;
9396
TICKET_TRANSFER: String;
9497
TICKET_CLOSE: String;
98+
TICKET_FEEDBACK: String;
9599
URL_PREVIEW: String;
96100
};
97101
type MessageClosureState = {
98102
WAITING: String;
99103
CONFIRMED: String;
100104
DECLINED: String;
101105
};
106+
type MessageFeedbackState = {
107+
WAITING: String;
108+
CONFIRMED: String;
109+
};
102110
interface SendBirdDeskErrorStatic {}
103111
}

SendBird.Desk.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sendbird-desk",
3-
"version": "1.0.7",
3+
"version": "1.0.8",
44
"description": "SendBird Desk SDK Integration Guide for JavaScript =========== SendBird Desk is a chat customer service platform built on SendBird SDK and API.",
55
"main": "SendBird.Desk.min.js",
66
"scripts": {
@@ -24,7 +24,7 @@
2424
},
2525
"homepage": "https://sendbird.com",
2626
"dependencies": {
27-
"sendbird": "^3.0.55"
27+
"sendbird": "^3.0.106"
2828
},
2929
"typings": "SendBird.Desk.d.ts"
3030
}

0 commit comments

Comments
 (0)