@microsoft/omnichannel-chat-sdk 0.2.1-main.c6982c2 → 0.3.1-main.31aff70

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.
Files changed (33) hide show
  1. package/CHANGELOG.md +28 -1
  2. package/README.md +135 -9
  3. package/lib/OmnichannelChatSDK.d.ts +9 -1
  4. package/lib/OmnichannelChatSDK.js +342 -136
  5. package/lib/OmnichannelChatSDK.js.map +1 -1
  6. package/lib/api/createVoiceVideoCalling.d.ts +1 -0
  7. package/lib/api/createVoiceVideoCalling.js +91 -83
  8. package/lib/api/createVoiceVideoCalling.js.map +1 -1
  9. package/lib/config/settings.d.ts +2 -2
  10. package/lib/config/settings.js +2 -2
  11. package/lib/core/ChatReconnectContext.d.ts +4 -0
  12. package/lib/core/ChatReconnectContext.js +3 -0
  13. package/lib/core/ChatReconnectContext.js.map +1 -0
  14. package/lib/core/ChatReconnectOptionalParams.d.ts +3 -0
  15. package/lib/core/ChatReconnectOptionalParams.js +3 -0
  16. package/lib/core/ChatReconnectOptionalParams.js.map +1 -0
  17. package/lib/core/ConversationMode.d.ts +5 -0
  18. package/lib/core/ConversationMode.js +9 -0
  19. package/lib/core/ConversationMode.js.map +1 -0
  20. package/lib/core/IChatSDKConfig.d.ts +10 -1
  21. package/lib/core/IStartChatOptionalParams.d.ts +1 -0
  22. package/lib/core/MessageTags.d.ts +1 -0
  23. package/lib/core/MessageTags.js +5 -0
  24. package/lib/core/MessageTags.js.map +1 -0
  25. package/lib/telemetry/AriaTelemetry.js +10 -5
  26. package/lib/telemetry/AriaTelemetry.js.map +1 -1
  27. package/lib/telemetry/TelemetryEvent.d.ts +3 -1
  28. package/lib/telemetry/TelemetryEvent.js +2 -0
  29. package/lib/telemetry/TelemetryEvent.js.map +1 -1
  30. package/lib/tsconfig.tsbuildinfo +396 -379
  31. package/lib/validators/SDKConfigValidators.js +15 -0
  32. package/lib/validators/SDKConfigValidators.js.map +1 -1
  33. package/package.json +9 -9
package/CHANGELOG.md CHANGED
@@ -2,14 +2,41 @@
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
4
  ## [Unreleased]
5
+
6
+ ### Changed
7
+ - Uptake [@microsoft/ocsdk@0.3.0](https://www.npmjs.com/package/@microsoft/ocsdk/v/0.3.0)
8
+ - Use `lockfileVersion: 2` in `package-lock.json` via npm v7
9
+
10
+ ### Fixed
11
+ - `onNewMessage` with `rehydrate` flag set to `true` crashing when `getMessages` returns `undefined`
12
+ - Fix `AriaTelemetry` unable to read property `logEvent` of undefined on `React Native`
13
+ - Fix `Escalation to Voice & Video` library not being imported properly
14
+
15
+ ## [0.3.0] - 2021-09-03
16
+ ### Added
17
+ - Persistent Chat Support
18
+ - Chat Reconnect Support
19
+ - Operating Hours Documentation
20
+
5
21
  ### Changed
6
22
  - Uptake [@microsoft/ocsdk@0.2.0](https://www.npmjs.com/package/@microsoft/ocsdk/v/0.2.0)
7
23
  - Add `getCallingToken`
24
+ - Send `ChannelId-lcw` message tag
25
+ - Uptake [IC3Client@2021.08.14.1](https://comms.omnichannelengagementhub.com/release/2021.08.14.1/Scripts/SDK/SDK.min.js)
26
+ - Uptake [botframework-webchat-adapter-ic3@0.1.0-master.2dba07b](https://www.npmjs.com/package/botframework-webchat-adapter-ic3/v/0.1.0-master.2dba07b)
27
+ - Uptake [jest@27.1.0](https://www.npmjs.com/package/jest/v/27.1.0)
28
+ - Update [@types/jest@27.0.1](https://www.npmjs.com/package/@types/jest/v/27.0.1)
29
+ - Uptake [ts-jest@27.0.5](https://www.npmjs.com/package/ts-jest/v/27.0.5)
30
+
31
+ ### Fixed
32
+ - `msdyn_enablechatreconnect` not being parsed properly
33
+ - Fix unable to start multiple conversations with same instance due to chat client being disposed
34
+ - Pass logger to adapter
8
35
 
9
36
  ## [0.2.0] - 2021-04-30
10
37
  ### Added
11
38
  - React Native sample app using Omnichannel Chat SDK with [react-native-gifted-chat](https://github.com/FaridSafi/react-native-gifted-chat)
12
- - Escalation to Voice & View support (Web Only)
39
+ - Escalation to Voice & Video support (Web Only)
13
40
  - React sample app using Omnichannel Chat SDK with [BotFramework-WebChat](https://github.com/microsoft/BotFramework-WebChat)
14
41
  - Expose `sessiontInit`'s `initContext` on `startChat`'s optional paramaters
15
42
  - Add ability to use custom `ic3Config` & `chatAdapterConfig`
package/README.md CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  [![npm version](https://badge.fury.io/js/%40microsoft%2Fomnichannel-chat-sdk.svg)](https://badge.fury.io/js/%40microsoft%2Fomnichannel-chat-sdk)
4
4
  ![Release CI](https://github.com/microsoft/omnichannel-chat-sdk/workflows/Release%20CI/badge.svg)
5
+ ![npm](https://img.shields.io/npm/dm/@microsoft/omnichannel-chat-sdk)
5
6
 
6
7
  Headless Chat SDK to build your own chat widget against Dynamics 365 Omnichannel Services.
7
8
 
@@ -16,6 +17,7 @@ Please make sure you have a chat widget configured before using this package or
16
17
  - [Common Scenarios](#common-scenarios)
17
18
  - [Feature Comparisons](#feature-comparisons)
18
19
  - [Telemetry](#telemetry)
20
+ - [Troubleshooting Guide](docs/TROUBLESHOOTING_GUIDE.md)
19
21
 
20
22
  ## Live Chat Widget vs. Chat SDK
21
23
 
@@ -46,6 +48,9 @@ Omnichannel offers an live chat widget (LCW) by default. You can use the Chat SD
46
48
  | File Attachments | ✔ | ✔ |
47
49
  | Custom Context | ✔ | ✔ |
48
50
  | Proactive Chat | ✔ | BYOI **\*** |
51
+ | Persistent Chat | ✔ | ✔ |
52
+ | Chat Reconnect | ✔ | ✔ |
53
+ | Operating Hours | ✔ | ✔ |
49
54
 
50
55
  **\*** BYOI: Bring Your Own Implementation
51
56
 
@@ -66,6 +71,7 @@ Omnichannel offers an live chat widget (LCW) by default. You can use the Chat SD
66
71
  | OmnichannelChatSDK.getLiveChatConfig() | Get live chat config | |
67
72
  | OmnichannelChatSDK.getDataMaskingRules() | Get active data masking rules | |
68
73
  | OmnichannelChatSDK.getCurrentLiveChatContext() | Get current live chat context information to reconnect to the same chat | |
74
+ | OmnichannelChatSDK.getChatReconnectContext() | Get current reconnectable chat context information to reconnect to a previous existing chat session | |
69
75
  | OmnichannelChatSDK.getConversationDetails() | Get details of the current conversation such as its state & when the agent joined the conversation | |
70
76
  | OmnichannelChatSDK.getChatToken() | Get chat token | |
71
77
  | OmnichannelChatSDK.getCallingToken() | Get calling token | |
@@ -113,6 +119,15 @@ Omnichannel offers an live chat widget (LCW) by default. You can use the Chat SD
113
119
  const liveChatContext = await chatSDK.getCurrentLiveChatContext();
114
120
  ```
115
121
 
122
+ ### Get Current Chat Reconnect Context
123
+ ```ts
124
+ const optionalParams = {
125
+ reconnectId: '', // reconnect Id
126
+ };
127
+
128
+ const chatReconnectContext = await chatSDK.getChatReconnectContext(optionalParams);
129
+ ```
130
+
116
131
  ### Get Conversation Details
117
132
  ```ts
118
133
  const conversationDetails = await chatSDK.getConversationDetails();
@@ -351,6 +366,125 @@ Omnichannel offers an live chat widget (LCW) by default. You can use the Chat SD
351
366
  // from this point, this acts like a regular chat widget
352
367
  ```
353
368
 
369
+ ### Persistent Chat
370
+
371
+ ```ts
372
+ const chatSDKConfig = {
373
+ persistentChat: {
374
+ disable: false,
375
+ tokenUpdateTime: 21600000
376
+ },
377
+ getAuthToken: async () => {
378
+ const response = await fetch("http://contosohelp.com/token");
379
+ if (response.ok) {
380
+ return await response.text();
381
+ }
382
+ else {
383
+ return null
384
+ }
385
+ }
386
+ }
387
+
388
+ const chatSDK = new OmnichannelChatSDK.OmnichannelChatSDK(omnichannelConfig, chatSDKConfig);
389
+ await chatSDK.initialize();
390
+
391
+ // from this point, this acts like a persistent chat
392
+ ```
393
+ ### Chat Reconnect with Authenticated User
394
+
395
+ ```ts
396
+ const chatSDKConfig = {
397
+ chatReconnect: {
398
+ disable: false,
399
+ },
400
+ getAuthToken: async () => {
401
+ const response = await fetch("http://contosohelp.com/token");
402
+ if (response.ok) {
403
+ return await response.text();
404
+ }
405
+ else {
406
+ return null
407
+ }
408
+ }
409
+ }
410
+
411
+ const chatSDK = new OmnichannelChatSDK.OmnichannelChatSDK(omnichannelConfig, chatSDKConfig);
412
+ await chatSDK.initialize();
413
+
414
+ ...
415
+
416
+ const chatReconnectContext = await chatSDK.getChatReconnectContext();
417
+
418
+ if (chatReconnectContext.reconnectId) {
419
+ // Add UX with options to reconnect to previous existing chat or start new chat
420
+ }
421
+
422
+ // Reconnect chat option
423
+ const optionalParams = {};
424
+ optionalParams.reconnectId = chatReconnectContext.reconnectId;
425
+ chatSDK.startChat(optionalParams);
426
+
427
+ // Start new chat option
428
+ chatSDK.startChat();
429
+ ```
430
+
431
+ ### Chat Reconnect with Unauthenticated User
432
+
433
+ ```ts
434
+ const chatSDKConfig = {
435
+ chatReconnect: {
436
+ disable: false,
437
+ },
438
+ }
439
+
440
+ const chatSDK = new OmnichannelChatSDK.OmnichannelChatSDK(omnichannelConfig, chatSDKConfig);
441
+ await chatSDK.initialize();
442
+
443
+ ....
444
+
445
+ const optionalParams: any = {};
446
+
447
+ // Retrieve reconnect id from the URL
448
+ const urlParams = new URLSearchParams(window.location.search);
449
+ const reconnectId = urlParams.get('oc.reconnectid');
450
+
451
+ const params = {
452
+ reconnectId
453
+ };
454
+
455
+ // Validate reconnect id
456
+ const chatReconnectContext = await chatSDK.getChatReconnectContext(params);
457
+
458
+ // If the reconnect id is invalid or expired, redirect URL if there is any URL set in the configuration
459
+ if (chatReconnectContext.redirectURL) {
460
+ window.location.replace(chatReconnectContext.redirectURL);
461
+ }
462
+
463
+ // Valid reconnect id, reconnect to previous chat
464
+ if (chatReconnectContext.reconnectId) {
465
+ await chatSDK.startChat({
466
+ reconnectId: chatReconnectContext.reconnectId
467
+ });
468
+ } else { // Reconnect id from URL is not valid, start new chat session
469
+ await chatSDK.startChat();
470
+ }
471
+ ```
472
+
473
+ ### Operating Hours
474
+
475
+ ```ts
476
+ const chatConfig = await chatSDK.getLiveChatConfig();
477
+ const {LiveWSAndLiveChatEngJoin: liveWSAndLiveChatEngJoin} = liveChatConfig;
478
+ const {OutOfOperatingHours: outOfOperatingHours} = liveWSAndLiveChatEngJoin;
479
+
480
+ if (outOfOperatingHours === "True") {
481
+ // Handles UX on Out of Operating Hours
482
+ } else {
483
+ await chatSDK.startChat();
484
+ // Renders Custom Chat Widget
485
+ }
486
+ ```
487
+
354
488
  ### Use [BotFramework-WebChat](https://github.com/microsoft/BotFramework-WebChat)
355
489
 
356
490
  **NOTE**: Currently supported on web only
@@ -370,20 +504,12 @@ Omnichannel offers an live chat widget (LCW) by default. You can use the Chat SD
370
504
  await chatSDK.startChat(optionalParams);
371
505
  const chatAdapter = await chatSDK.createChatAdapter();
372
506
 
373
- // Subscribes to incoming message (OPTION 1)
507
+ // Subscribes to incoming message
374
508
  chatSDK.onNewMessage((message) => {
375
509
  console.log(`[NewMessage] ${message.content}`); // IC3 protocol message data
376
510
  console.log(message);
377
511
  });
378
512
 
379
- // Subscribes to incoming message (OPTION 2)
380
- (chatAdapter as any).activity$.subscribe((activity: any) => {
381
- if (activity.type === "message") {
382
- console.log("[Message activity]");
383
- console.log(activity); // DirectLine protocol activity data
384
- }
385
- });
386
-
387
513
  ...
388
514
 
389
515
  <ReactWebChat
@@ -11,8 +11,10 @@ import IOmnichannelConfig from "./core/IOmnichannelConfig";
11
11
  import IRawMessage from "@microsoft/omnichannel-ic3core/lib/model/IRawMessage";
12
12
  import IRawThread from "@microsoft/omnichannel-ic3core/lib/interfaces/IRawThread";
13
13
  import IStartChatOptionalParams from "./core/IStartChatOptionalParams";
14
- import OnNewMessageOptionalParams from "./core/OnNewMessageOptionalParams";
15
14
  import LiveWorkItemDetails from "./core/LiveWorkItemDetails";
15
+ import OnNewMessageOptionalParams from "./core/OnNewMessageOptionalParams";
16
+ import ChatReconnectOptionalParams from "./core/ChatReconnectOptionalParams";
17
+ import ChatReconnectContext from "./core/ChatReconnectContext";
16
18
  declare class OmnichannelChatSDK {
17
19
  private debug;
18
20
  OCSDKProvider: unknown;
@@ -35,9 +37,14 @@ declare class OmnichannelChatSDK {
35
37
  private scenarioMarker;
36
38
  private ic3ClientLogger;
37
39
  private ocSdkLogger;
40
+ private isPersistentChat;
41
+ private isChatReconnect;
42
+ private reconnectId;
43
+ private refreshTokenTimer;
38
44
  constructor(omnichannelConfig: IOmnichannelConfig, chatSDKConfig?: IChatSDKConfig);
39
45
  setDebug(flag: boolean): void;
40
46
  initialize(): Promise<IChatConfig>;
47
+ getChatReconnectContext(optionalParams?: ChatReconnectOptionalParams): Promise<ChatReconnectContext>;
41
48
  startChat(optionalParams?: IStartChatOptionalParams): Promise<void>;
42
49
  endChat(): Promise<void>;
43
50
  getCurrentLiveChatContext(): Promise<ILiveChatContext | {}>;
@@ -67,5 +74,6 @@ declare class OmnichannelChatSDK {
67
74
  private getChatConfig;
68
75
  private resolveIC3ClientUrl;
69
76
  private resolveChatAdapterUrl;
77
+ private updateChatToken;
70
78
  }
71
79
  export default OmnichannelChatSDK;