@livechat/customer-sdk 2.0.4 → 3.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Introduction
2
2
 
3
- **LiveChat Customer SDK** is a set of tools that helps you build a custom chat widget. Under the hood, it makes use of the [LiveChat Customer Chat API](https://developers.livechatinc.com/docs/messaging/customer-chat-api/). Customer SDK lets you communicate with LiveChat services directly from the browser environment using JavaScript without the need to develop your backend.
3
+ **LiveChat Customer SDK** is a set of tools that helps you build a custom chat widget. Under the hood, it makes use of the [LiveChat Customer Chat API](https://developers.livechat.com/docs/messaging/customer-chat-api/). Customer SDK lets you communicate with LiveChat services directly from the browser environment using JavaScript without the need to develop your backend.
4
4
 
5
5
  ## Is it for me?
6
6
 
@@ -11,8 +11,8 @@ brave, dive into LiveChat Customer SDK. We provide [methods](#methods) and
11
11
 
12
12
  Keep in mind that interacting with this API requires **some development skills**.
13
13
 
14
- Customer SDK allows you to create frontend apps, so if you're looking for server-side solutions, you should explore the [LiveChat Customer Chat API](https://developers.livechatinc.com/docs/messaging/customer-chat-api/) instead.
15
- If you want to dive deeper into the LiveChat Platform, you might find the [Platform Overview](https://developers.livechatinc.com/docs/getting-started/) article handy.
14
+ Customer SDK allows you to create frontend apps, so if you're looking for server-side solutions, you should explore the [LiveChat Customer Chat API](https://developers.livechat.com/docs/messaging/customer-chat-api/) instead.
15
+ If you want to dive deeper into the LiveChat Platform, you might find the [Platform Overview](https://developers.livechat.com/docs/getting-started/) article handy.
16
16
 
17
17
  ## About LiveChat Customer SDK
18
18
 
@@ -42,7 +42,7 @@ This tutorial is here to help you get started with LiveChat Customer SDK.
42
42
  ## Create an application
43
43
 
44
44
  First, you need to create an application in
45
- [Developer Console](https://developers.livechatinc.com/console) (select the _Web app (frontend,
45
+ [Developer Console](https://developers.livechat.com/console) (select the _Web app (frontend,
46
46
  e.g. JavaScript)_ type). Then, you will have to give it the access to the `customers:own` scope and the correct URI to the `Redirect URI whitelist`.
47
47
 
48
48
  ## Install Customer SDK
@@ -63,12 +63,12 @@ Or use the node-style `require` call:
63
63
 
64
64
  ### Using a script tag - UMD module hosted on unpkg's CDN
65
65
 
66
- `<script src="https://unpkg.com/@livechat/customer-sdk@2.0.1"></script>`
66
+ `<script src="https://unpkg.com/@livechat/customer-sdk@3.1.1"></script>`
67
67
 
68
68
  If you just want to look around and play with the SDK, check out our
69
69
  [sample chat widget implementation](https://codesandbox.io/s/rm3prxw88n).
70
70
 
71
- For the time being you need to register your application in the <a href="https://developers.livechatinc.com/console" target="_blank">Developers Console</a>
71
+ For the time being you need to register your application in the <a href="https://developers.livechat.com/console" target="_blank">Developers Console</a>
72
72
  as a "Web app (frontend, eg. JavaScript)" type. Then, you have to pass the configured `redirectUri` to the `init`, along with the regular required properties (`licenseId` and `clientId`).
73
73
 
74
74
  ## Using the API
@@ -78,15 +78,17 @@ You will need to provide your licenseId and clientId when creating a Customer SD
78
78
 
79
79
  Other optional configuration parameters are also available:
80
80
 
81
- | parameters | type | default | description |
82
- | -------------------- | ------------------ | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
83
- | licenseId | number | | Your license number, you receive this value when creating a new livechat account. |
84
- | clientId | string | | Your client id, you receive this value when you register your application in the LiveChat developer console. |
85
- | autoConnect | boolean | true | Optional; should the library try to reconnect on it's own. |
86
- | groupId | number | 0 | Optional; the id of the group you wish to connect to. |
87
- | region | 'dal' \| 'fra' | 'dal' | Optional; the server region your license is at. |
88
- | redirectUri | string | | Optional; should only be used inside ReactNative, this is the URI which your webview is redirected to after authorization. |
89
- | customerDataProvider | () => CustomerData | | Optional; should only be used if you need to send customer data during login. In general, [`updateCustomer()`](#updateCustomer) should be prefered for sending customer data. |
81
+ | parameters | type | default | description |
82
+ | -------------------- | ------------------ | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
83
+ | licenseId | number | | Your license number, you receive this value when creating a new livechat account. |
84
+ | clientId | string | | Your client id, you receive this value when you register your application in the LiveChat Developer Console. |
85
+ | autoConnect | boolean | true | Optional; should the library try to reconnect on it's own. |
86
+ | groupId | number | | Optional; the id of the group you wish to connect to. |
87
+ | uniqueGroups | boolean | false | Optional; by default, the customer's identity is the same for all groups. If you want to create a separate customer identity for each group, set this parameter to `true`. When set to `true`, passing a `groupId` is required. |
88
+ | region | 'dal' \| 'fra' | 'dal' | Optional; the server region your license is at. |
89
+ | redirectUri | string | | Optional; should only be used inside ReactNative, this is the URI which your webview is redirected to after authorization. |
90
+ | customerDataProvider | () => CustomerData | | Optional; should only be used if you need to send customer data during login. In general, [`updateCustomer()`](#updateCustomer) should be prefered for sending customer data. |
91
+ | identityProvider | () => CustomerAuth | | Optional; allows for providing own instance of the CustomerAuth object which contains the customer access token handlers. See [Custom Identity Provider](https://developers.livechat.com/docs/extending-chat-widget/custom-identity-provider) for more information. |
90
92
 
91
93
  CustomerData:
92
94
 
@@ -96,6 +98,15 @@ CustomerData:
96
98
  | email | string | Optional |
97
99
  | sessionFields | object | Key: value pairs |
98
100
 
101
+ CustomerAuth:
102
+
103
+ | parameters | type | description |
104
+ | ------------- | ---------------------- | -------------------------------------------------------------------------------------- |
105
+ | getFreshToken | () => Promise<Token> | Should resolve with freshly requested customer access token. |
106
+ | getToken | () => Promise<Token> | Should resolve with currently stored customer access token. |
107
+ | hasToken | () => Promise<boolean> | Should resolve with a boolean value representing if a token has been already acquired. |
108
+ | invalidate | () => Promise<void> | Should handle token invalidation and/or clearing the locally cached value. |
109
+
99
110
  The `init` function will return a Customer SDK instance:
100
111
 
101
112
  ```js
@@ -186,7 +197,7 @@ Handling operations such as loading archival events from the chat history can be
186
197
  Customer SDK provides wrappers for common tasks and most methods expect to receive chat IDs.
187
198
  You will only get notified about thread metadata if you explicitly ask for it.
188
199
 
189
- You can read more about key concepts of the LiveChat messaging in the [Messaging Overview](https://developers.livechatinc.com/docs/messaging/#key-concepts).
200
+ You can read more about key concepts of the LiveChat messaging in the [Messaging Overview](https://developers.livechat.com/docs/messaging/#key-concepts).
190
201
 
191
202
  ## User
192
203
 
@@ -198,7 +209,7 @@ You can read more about key concepts of the LiveChat messaging in the [Messaging
198
209
  type: 'agent',
199
210
  name: 'Jane Doe',
200
211
  jobTitle: 'Agent',
201
- avatar: 'https://cdn.livechatinc.com/cloud/?uri=https://livechat.s3.amazonaws.com/default/avatars/a7.png',
212
+ avatar: 'https://cdn.livechat.com/cloud/?uri=https://livechat.s3.amazonaws.com/default/avatars/a7.png',
202
213
  }
203
214
  ```
204
215
 
@@ -209,7 +220,7 @@ You can read more about key concepts of the LiveChat messaging in the [Messaging
209
220
  id: 'ed9d0195-45d6-428d-5093-f8ec7f1471b9',
210
221
  type: 'customer',
211
222
  name: 'Jon Doe',
212
- avatar: 'https://cdn.livechatinc.com/cloud/?uri=https://livechat.s3.amazonaws.com/default/avatars/a6.png',
223
+ avatar: 'https://cdn.livechat.com/cloud/?uri=https://livechat.s3.amazonaws.com/default/avatars/a6.png',
213
224
  fields: {
214
225
  custom_property: 'BasketValue=10usd',
215
226
  }
@@ -295,44 +306,6 @@ Parameters:
295
306
 
296
307
  - `GREETING_NOT_FOUND` - a given `uniqueId` couldn't be found on the server
297
308
 
298
- ## activateChat
299
-
300
- Activates an archived chat.
301
-
302
- ```js
303
- customerSDK
304
- .activateChat({
305
- chat: {
306
- id: 'OU0V0P0OWT',
307
- thread: {
308
- events: [],
309
- },
310
- },
311
- })
312
- .then(chat => {
313
- console.log(chat)
314
- })
315
- .catch(error => {
316
- console.log(error)
317
- })
318
- ```
319
-
320
- Parameters:
321
-
322
- | parameters | type | description |
323
- | --------------------------- | ------- | ----------------------------------------------------------------------------------------------- |
324
- | data.continuous | boolean | Optional |
325
- | data.chat.id | string | |
326
- | data.chat.access | Access | Optional |
327
- | data.chat.properties | object | Optional |
328
- | data.chat.thread.events | Event[] | Optional; you can pass initial events which will immediately become part of the created thread. |
329
- | data.chat.thread.properties | object | Optional |
330
-
331
- ### Errors
332
-
333
- - `CHAT_ALREADY_ACTIVE` - the chat is already active and you can't activate it again.
334
- - `GROUPS_OFFLINE` - a group in the targeted chat is offline. It can happen for licenses without continuous chats enabled.
335
-
336
309
  ## cancelGreeting
337
310
 
338
311
  Cancels a greeting (an invitation to the chat). For example, Customers could cancel greetings by clicking close icon on the displayed greeting.
@@ -386,14 +359,35 @@ customerSDK
386
359
 
387
360
  Starts the connection process to our servers. It is needed when:
388
361
 
389
- - the argument `autoConnect: false` has been passed to the `init` method
390
- - you get disconnected for a reason that suspends reconnection attempts (e.g. [`inactivity_timeout`](#inactivity_timeout))
362
+ - The `autoConnect: false` argument has been passed to the `init` method.
363
+
364
+ ```js
365
+ const customerSDK = CustomerSDK.init({
366
+ licenseId: LICENSE_ID,
367
+ clientId: CLIENT_ID,
368
+ autoConnect: false,
369
+ })
370
+
371
+ /* later in the code... */
372
+
373
+ customerSDK.connect()
374
+ ```
375
+
376
+ - You get disconnected for a reason that suspends reconnection attempts (e.g. [`inactivity_timeout`](#inactivity_timeout)).
377
+
378
+ ```js
379
+ customerSDK.on('disconnected', ({ reason }) => {
380
+ if (reason === 'inactivity_timeout') {
381
+ customerSDK.connect()
382
+ }
383
+ })
384
+ ```
391
385
 
392
386
  ## deactivateChat
393
387
 
394
388
  ```js
395
389
  customerSDK
396
- .deactivateChat({ chatId: 'ON0X0R0L67' })
390
+ .deactivateChat({ id: 'ON0X0R0L67' })
397
391
  .then(response => {
398
392
  console.log(response)
399
393
  })
@@ -406,7 +400,7 @@ Parameters:
406
400
 
407
401
  | parameters | type | description |
408
402
  | ---------- | ------ | ----------------------------------------- |
409
- | chatId | string | Chat ID in which thread should get closed |
403
+ | id | string | Chat ID in which thread should get closed |
410
404
 
411
405
  Returned value:
412
406
 
@@ -421,7 +415,7 @@ Deletes given chat properties.
421
415
  ```js
422
416
  customerSDK
423
417
  .deleteChatProperties({
424
- chatId: 'ON0X0R0L67',
418
+ id: 'ON0X0R0L67',
425
419
  properties: {
426
420
  property_namespace: ['sample'],
427
421
  },
@@ -438,7 +432,7 @@ Parameters:
438
432
 
439
433
  | parameters | type | description |
440
434
  | ---------- | ------ | --------------------------------------------------- |
441
- | chatId | string | ID of the chat whose properties you want to delete. |
435
+ | id | string | ID of the chat whose properties you want to delete. |
442
436
  | properties | object | Chat properties to delete |
443
437
 
444
438
  Returned value:
@@ -704,10 +698,22 @@ Parameters:
704
698
  | ---------- | ------ | ----------- |
705
699
  | groupId | number | Optional |
706
700
 
701
+ Returned value:
702
+
703
+ | properties | type | description |
704
+ | -------------- | ------- | ------------------------------------------------------------- |
705
+ | agent | object | |
706
+ | agent.id | string | |
707
+ | agent.name | string | |
708
+ | agent.jobTitle | string | |
709
+ | agent.type | 'agent' | |
710
+ | agent.isBot | boolean | |
711
+ | queue | boolean | True when the current group has reached concurrent chat limit |
712
+
707
713
  ### Errors
708
714
 
709
715
  - `GROUP_OFFLINE` - the requested group is offline, and it was not possible to return a predicted Agent for it.
710
- - `GROUP_UNAVAILABLE` - there are no available slots in the requested group, so it is not possible to return a predicted Agent for it. If you call `startChat` or `activateChat` accordingly, you are most likely to end up in the queue.
716
+ - `GROUP_UNAVAILABLE` - thrown when manual routing is enabled for the group and a predicted Agent is requested for it. If you call `startChat` or `resumeChat` accordingly, you'll end up in the queue.
711
717
 
712
718
  ## getUrlInfo
713
719
 
@@ -715,7 +721,7 @@ It returns the info on a given URL.
715
721
 
716
722
  ```js
717
723
  customerSDK
718
- .getUrlInfo({ url: 'https://www.livechatinc.com' })
724
+ .getUrlInfo({ url: 'https://www.livechat.com' })
719
725
  .then(urlDetails => {
720
726
  if (urlDetails.title) {
721
727
  console.log(`The title of requested URL is: ${urlDetails.title}`)
@@ -960,6 +966,45 @@ Returned value:
960
966
 
961
967
  - `MISSING_CHAT_THREAD` - the targeted chat cannot be rated because it has no threads.
962
968
 
969
+ ## resumeChat
970
+
971
+ Resumes an archived chat.
972
+
973
+ ```js
974
+ customerSDK
975
+ .resumeChat({
976
+ chat: {
977
+ id: 'OU0V0P0OWT',
978
+ thread: {
979
+ events: [],
980
+ },
981
+ },
982
+ })
983
+ .then(chat => {
984
+ console.log(chat)
985
+ })
986
+ .catch(error => {
987
+ console.log(error)
988
+ })
989
+ ```
990
+
991
+ Parameters:
992
+
993
+ | parameters | type | description |
994
+ | --------------------------- | ------- | ----------------------------------------------------------------------------------------------------------------- |
995
+ | data.active | boolean | Optional; defaults to `true` but can be used to create threads that are immediately inactive |
996
+ | data.continuous | boolean | Optional |
997
+ | data.chat.id | string | |
998
+ | data.chat.access | Access | Optional |
999
+ | data.chat.properties | object | Optional, [Default properties docs](https://developers.livechat.com/docs/messaging/references/default-properties) |
1000
+ | data.chat.thread.events | Event[] | Optional; you can pass initial events which will immediately become part of the created thread. |
1001
+ | data.chat.thread.properties | object | Optional, [Default properties docs](https://developers.livechat.com/docs/messaging/references/default-properties) |
1002
+
1003
+ ### Errors
1004
+
1005
+ - `CHAT_ALREADY_ACTIVE` - the chat is already active and you can't activate it again.
1006
+ - `GROUPS_OFFLINE` - a group in the targeted chat is offline. It can happen for licenses without continuous chats enabled.
1007
+
963
1008
  ## sendEvent
964
1009
 
965
1010
  Sends a provided object as an event with a specified type.
@@ -1114,7 +1159,7 @@ Parameters:
1114
1159
 
1115
1160
  ## setSneakPeek
1116
1161
 
1117
- You can use it to update the [sneak peek](https://www.livechatinc.com/blog/customer-message-sneak-peak/) in the Agent App.
1162
+ You can use it to update the [sneak peek](https://www.livechat.com/blog/customer-message-sneak-peak/) in the Agent App.
1118
1163
  It is sent to the server only if the target chat is active. This method doesn't return a promise.
1119
1164
 
1120
1165
  ```js
@@ -1134,7 +1179,7 @@ Parameters:
1134
1179
  ## startChat
1135
1180
 
1136
1181
  Starts a new chat. For one Customer, you can only start one chat.
1137
- In order to activate a previously started chat, use [`activateChat`](#activateChat).
1182
+ In order to activate a previously started chat, use [`resumeChat`](#resumeChat).
1138
1183
 
1139
1184
  ```js
1140
1185
  customerSDK
@@ -1155,13 +1200,14 @@ customerSDK
1155
1200
 
1156
1201
  Parameters:
1157
1202
 
1158
- | parameters | type | description |
1159
- | ---------------------- | ------- | ----------------------------------------------------------------------------------- |
1160
- | continuous | boolean | Optional |
1161
- | chat.access | access | Optional |
1162
- | chat.properties | object | Optional |
1163
- | chat.thread.events | event[] | Optional; initial events that will immediately become a part of the created thread. |
1164
- | chat.thread.properties | object | Optional |
1203
+ | parameters | type | description |
1204
+ | ---------------------- | ------- | ----------------------------------------------------------------------------------------------------------------- |
1205
+ | active | boolean | Optional, defaults to `true` but can be used to create threads that are immediately inactive |
1206
+ | continuous | boolean | Optional |
1207
+ | chat.access | access | Optional |
1208
+ | chat.properties | object | Optional, [Default properties docs](https://developers.livechat.com/docs/messaging/references/default-properties) |
1209
+ | chat.thread.events | event[] | Optional; initial events that will immediately become a part of the created thread. |
1210
+ | chat.thread.properties | object | Optional, [Default properties docs](https://developers.livechat.com/docs/messaging/references/default-properties) |
1165
1211
 
1166
1212
  ### Errors
1167
1213
 
@@ -1177,7 +1223,7 @@ const properties = {
1177
1223
  },
1178
1224
  }
1179
1225
  customerSDK
1180
- .updateChatProperties({ chatId: 'ON0X0R0L67', properties })
1226
+ .updateChatProperties({ id: 'ON0X0R0L67', properties })
1181
1227
  .then(response => {
1182
1228
  console.log(response)
1183
1229
  })
@@ -1188,10 +1234,10 @@ customerSDK
1188
1234
 
1189
1235
  Parameters:
1190
1236
 
1191
- | parameters | type | description |
1192
- | ---------- | ------ | --------------------------------------------------- |
1193
- | chatId | string | ID of the chat whose properties you want to update. |
1194
- | properties | object | |
1237
+ | parameters | type | description |
1238
+ | ---------- | ------ | ------------------------------------------------------------------------------------------------------- |
1239
+ | id | string | ID of the chat whose properties you want to update. |
1240
+ | properties | object | [Default properties docs](https://developers.livechat.com/docs/messaging/references/default-properties) |
1195
1241
 
1196
1242
  ## updateCustomer
1197
1243
 
@@ -1228,7 +1274,7 @@ Updates information about the Customer page using the provided page object.
1228
1274
 
1229
1275
  ```js
1230
1276
  const page = {
1231
- url: 'https://developers.livechatinc.com/',
1277
+ url: 'https://developers.livechat.com/',
1232
1278
  title: 'LiveChat for Developers',
1233
1279
  }
1234
1280
  customerSDK.updateCustomerPage(page)
@@ -1269,12 +1315,12 @@ customerSDK
1269
1315
 
1270
1316
  Parameters:
1271
1317
 
1272
- | parameters | type | description |
1273
- | ---------- | ------ | ----------------------------------------------------- |
1274
- | chatId | string | ID of the chat whose properties you want to update. |
1275
- | threadId | string | ID of the thread whose properties you want to update. |
1276
- | eventId | string | ID of the event whose properties you want to update. |
1277
- | properties | object | |
1318
+ | parameters | type | description |
1319
+ | ---------- | ------ | ------------------------------------------------------------------------------------------------------- |
1320
+ | chatId | string | ID of the chat whose properties you want to update. |
1321
+ | threadId | string | ID of the thread whose properties you want to update. |
1322
+ | eventId | string | ID of the event whose properties you want to update. |
1323
+ | properties | object | [Default properties docs](https://developers.livechat.com/docs/messaging/references/default-properties) |
1278
1324
 
1279
1325
  ## updateThreadProperties
1280
1326
 
@@ -1300,11 +1346,11 @@ customerSDK
1300
1346
 
1301
1347
  Parameters:
1302
1348
 
1303
- | parameters | type | description |
1304
- | ---------- | ------ | ----------------------------------------------------- |
1305
- | chatId | string | ID of the chat whose properties you want to update. |
1306
- | threadId | string | ID of the thread whose properties you want to update. |
1307
- | properties | object |
1349
+ | parameters | type | description |
1350
+ | ---------- | ------ | -------------------------------------------------------------------------------------------------------- |
1351
+ | chatId | string | ID of the chat whose properties you want to update. |
1352
+ | threadId | string | ID of the thread whose properties you want to update. |
1353
+ | properties | object | [Default properties docs](https://developers.livechat.com/docs/messaging/references/default-properties). |
1308
1354
 
1309
1355
  ## uploadFile
1310
1356
 
@@ -1547,18 +1593,18 @@ The Customer moved to another page, for example by following a link on your webs
1547
1593
 
1548
1594
  ```js
1549
1595
  customerSDK.on('customer_page_updated', payload => {
1550
- const { url, title, timestamp } = payload
1551
- console.log('customer_page_updated', ({ url, title, timestamp })
1596
+ const { url, title, openedAt } = payload
1597
+ console.log('customer_page_updated', { url, title, openedAt })
1552
1598
  })
1553
1599
  ```
1554
1600
 
1555
1601
  Payload:
1556
1602
 
1557
- | properties | type | |
1558
- | ---------- | ------ | ------------------------------------- |
1559
- | url | string | URL of the Customer current website |
1560
- | title | string | Title of the Customer current website |
1561
- | timestamp | string | Timestamp of the latest change |
1603
+ | properties | type | |
1604
+ | ---------- | ------ | ---------------------------------------------------- |
1605
+ | url | string | URL of the Customer current website |
1606
+ | title | string | Title of the Customer current website |
1607
+ | openedAt | string | Date of the last update in RFC 3339 date-time format |
1562
1608
 
1563
1609
  ## Customer updated
1564
1610
 
@@ -1566,32 +1612,31 @@ Informs that Customer's data was updated.
1566
1612
  Each property in payload is available only if it was updated.
1567
1613
 
1568
1614
  ```js
1569
- customerSDK.on('customer_updated', payload => {
1570
- if (payload.customer.name) {
1571
- console.log(`Name got updated to: ${payload.customer.name}`)
1615
+ customerSDK.on('customer_updated', customer => {
1616
+ if (customer.name) {
1617
+ console.log(`Name got updated to: ${customer.name}`)
1572
1618
  }
1573
- if (payload.customer.email) {
1574
- console.log(`Email got updated to: ${payload.customer.email}`)
1619
+ if (customer.email) {
1620
+ console.log(`Email got updated to: ${customer.email}`)
1575
1621
  }
1576
- if (payload.customer.avatar) {
1577
- console.log(`Avatar got updated to: ${payload.customer.avatar}`)
1622
+ if (customer.avatar) {
1623
+ console.log(`Avatar got updated to: ${customer.avatar}`)
1578
1624
  }
1579
- if (payload.customer.fields) {
1625
+ if (customer.fields) {
1580
1626
  console.log(`Fields got updated:`)
1581
- console.log(payload.customer.fields)
1627
+ console.log(customer.fields)
1582
1628
  }
1583
1629
  })
1584
1630
  ```
1585
1631
 
1586
1632
  Payload:
1587
1633
 
1588
- | properties | type |
1589
- | --------------- | ------ |
1590
- | customer | |
1591
- | customer.name | string |
1592
- | customer.email | string |
1593
- | customer.avatar | string |
1594
- | customer.fields | object |
1634
+ | properties | type |
1635
+ | ---------- | ------ |
1636
+ | name | string |
1637
+ | email | string |
1638
+ | avatar | string |
1639
+ | fields | object |
1595
1640
 
1596
1641
  ## Disconnected
1597
1642
 
@@ -2038,6 +2083,10 @@ The Customer didn't chat or change the page in the past 30 minutes. Customer SDK
2038
2083
 
2039
2084
  Internal error. Customer SDK reconnects on its own.
2040
2085
 
2086
+ ## License expired
2087
+
2088
+ The license with the specified ID has expired. You should make sure that there are no unpaid invoices for it.
2089
+
2041
2090
  ## License not found
2042
2091
 
2043
2092
  The license with the specified ID doesn't exist. You should check the options passed in to Customer SDK and make sure that the license parameter is correct.
@@ -2066,9 +2115,9 @@ This internally destroys the current instance of Customer SDK, so it won't be po
2066
2115
 
2067
2116
  ## Users limit reached
2068
2117
 
2069
- The maximum number of Customers connected at the same time has been reached. This can only be received immediately after we try to connect to our servers, because once you get authorized, you stay that way. The limit is different for each plan, and you can check the exact values on our [pricing page](https://www.livechatinc.com/pricing/).
2118
+ The maximum number of Customers connected at the same time has been reached. This can only be received immediately after we try to connect to our servers, because once you get authorized, you stay that way. The limit is different for each plan, and you can check the exact values on our [pricing page](https://www.livechat.com/pricing/).
2070
2119
 
2071
- This internally destroys the current instance of the Customer SDK, so it won't be possible to reuse it.
2120
+ This internally disconnects from the current instance of the Customer SDK. After that, the manual `connect()` call will be required, preferably linked to the user's action rather than automated.
2072
2121
 
2073
2122
  # Errors
2074
2123
 
@@ -2101,33 +2150,90 @@ You have sent out too many requests in a too short time period without waiting f
2101
2150
 
2102
2151
  The request has timed out.
2103
2152
 
2153
+ ## Service unavailable
2154
+
2155
+ The backend service is under heavy traffic and it had to restrict creation of a new resource.
2156
+
2104
2157
  ## Validation
2105
2158
 
2106
2159
  Wrong format of request, for example a `string` sent in the place of a `number`.
2107
2160
 
2161
+ # Recipes
2162
+
2163
+ ## Chat transcript feature
2164
+
2165
+ To implement [Chat transcript](https://www.livechat.com/features/engaging-customers/#Chat-transcript), you need to set the `transcript_email` thread property in the `routing` namespace. The value of this property should be set to the email address of the requester.
2166
+
2167
+ ```js
2168
+ customerSDK
2169
+ .updateThreadProperties({
2170
+ chatId: 'ON0X0R0L67',
2171
+ threadId: 'OS0C0W0Z1B',
2172
+ properties: {
2173
+ routing: {
2174
+ transcript_email: 'john.doe@example.com',
2175
+ },
2176
+ },
2177
+ })
2178
+ .then(response => {
2179
+ console.log(response)
2180
+ })
2181
+ .catch(error => {
2182
+ console.log(error)
2183
+ })
2184
+ ```
2185
+
2186
+ ## Hard limit error handling
2187
+
2188
+ In order to handle [hard limit error](https://developers.livechat.com/docs/extending-chat-widget/customer-sdk/#users-limit-reached) properly, you can listen for this specific disconnect reason and then react accordingly. In our case, we are showing simple information that our agents are not available at the moment.
2189
+
2190
+ ```js
2191
+ customerSDK.on('disconnected', ({ reason }) => {
2192
+ if (reason === 'users_limit_reached') {
2193
+ console.log('Our agents are not available at the moment')
2194
+ }
2195
+ })
2196
+ ```
2197
+
2108
2198
  # Changelog
2109
2199
 
2110
- ## [vX.X.X] - XXXX-XX-XX
2200
+ ## [v3.1.0] - 2021-10-7
2201
+
2202
+ ### Added
2203
+
2204
+ - New optional `config` property `identityProvider`, which allows for specifying own custom access token handlers.
2205
+ - Handle new event type `'form'` representing the optional custom forms sent from the server.
2206
+
2207
+ ## [v3.0.0] - 2021-05-25
2111
2208
 
2112
2209
  ### Fixed
2113
2210
 
2114
- - Threadless chat error handling.
2211
+ - Chat structures can now have `thread` set to `null` since it's possible for threads to be removed
2212
+ - Prevented additional connections to be created in the case when SDK gets destroyed in the middle of the `login` flow
2115
2213
 
2116
2214
  ### Changed
2117
2215
 
2118
- - In the `deactivateChat` method, the `chat_id` parameter was renamed to `id`.
2119
- - In the `updateChatProperties` method, the `chat_id` parameter was renamed to `id`.
2120
- - In the `deleteChatProperties` method, the `chat_id` parameter was renamed to `id`.
2121
- - In the `customer_page_updated` event the `timestamp` property has been replaced with `openedAt`.
2216
+ - Switched to using Customer API 3.3:
2217
+ - `activateChat` method has been renamed to `resumeChat`.
2218
+ - In the `deactivateChat` method, the `chat_id` parameter was renamed to `id`.
2219
+ - In the `updateChatProperties` method, the `chat_id` parameter was renamed to `id`.
2220
+ - In the `deleteChatProperties` method, the `chat_id` parameter was renamed to `id`.
2221
+ - In the `getPredictedAgent` method, agent properties are grouped in `agent` property and additional `queue` parameter is returned.
2222
+ - In the `customer_page_updated` event the `timestamp` property has been replaced with `openedAt`.
2223
+ - In the `customer_updated` event customer data is no longer grouped in the `customer` object but rather all properties are returned at the top level.
2224
+ - The communication with the server is done now using WebSocket endpoint, without the SockJS overhead.
2122
2225
  - Users limit handling changed from destroying the instance to disconnecting.
2123
2226
 
2124
2227
  ### Added
2125
2228
 
2229
+ - `active` parameter to the `startChat` & `resumeChat` methods. It defaults to `true` but can be used to create threads that are immediately inactive.
2230
+ - Greetings can now have a `subtype` property.
2126
2231
  - Support for `alternative_text` image property in:
2127
2232
  - image attachments
2128
2233
  - rich greetings
2129
2234
  - rich messages
2130
2235
  - `cancel` button type in rich messages.
2236
+ - Support for the events of type `"custom"`
2131
2237
 
2132
2238
  ## [v2.0.4] - 2020-10-28
2133
2239