@microsoft/omnichannel-chat-sdk 0.2.1-main.f5ff432 → 0.3.1-main.c474307
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/CHANGELOG.md +26 -0
- package/README.md +135 -9
- package/lib/OmnichannelChatSDK.d.ts +7 -1
- package/lib/OmnichannelChatSDK.js +285 -100
- package/lib/OmnichannelChatSDK.js.map +1 -1
- package/lib/config/settings.d.ts +2 -2
- package/lib/config/settings.js +2 -2
- package/lib/core/ChatReconnectContext.d.ts +4 -0
- package/lib/core/ChatReconnectContext.js +3 -0
- package/lib/core/ChatReconnectContext.js.map +1 -0
- package/lib/core/ChatReconnectOptionalParams.d.ts +3 -0
- package/lib/core/ChatReconnectOptionalParams.js +3 -0
- package/lib/core/ChatReconnectOptionalParams.js.map +1 -0
- package/lib/core/IChatSDKConfig.d.ts +5 -1
- package/lib/core/IStartChatOptionalParams.d.ts +1 -0
- package/lib/core/MessageTags.d.ts +1 -0
- package/lib/core/MessageTags.js +5 -0
- package/lib/core/MessageTags.js.map +1 -0
- package/lib/telemetry/AriaTelemetry.js +10 -5
- package/lib/telemetry/AriaTelemetry.js.map +1 -1
- package/lib/telemetry/TelemetryEvent.d.ts +3 -1
- package/lib/telemetry/TelemetryEvent.js +2 -0
- package/lib/telemetry/TelemetryEvent.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +387 -384
- package/lib/validators/SDKConfigValidators.js +11 -0
- package/lib/validators/SDKConfigValidators.js.map +1 -1
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
@@ -2,9 +2,35 @@
|
|
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
|
+
|
14
|
+
## [0.3.0] - 2021-09-03
|
15
|
+
### Added
|
16
|
+
- Persistent Chat Support
|
17
|
+
- Chat Reconnect Support
|
18
|
+
- Operating Hours Documentation
|
19
|
+
|
5
20
|
### Changed
|
6
21
|
- Uptake [@microsoft/ocsdk@0.2.0](https://www.npmjs.com/package/@microsoft/ocsdk/v/0.2.0)
|
7
22
|
- Add `getCallingToken`
|
23
|
+
- Send `ChannelId-lcw` message tag
|
24
|
+
- Uptake [IC3Client@2021.08.14.1](https://comms.omnichannelengagementhub.com/release/2021.08.14.1/Scripts/SDK/SDK.min.js)
|
25
|
+
- 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)
|
26
|
+
- Uptake [jest@27.1.0](https://www.npmjs.com/package/jest/v/27.1.0)
|
27
|
+
- Update [@types/jest@27.0.1](https://www.npmjs.com/package/@types/jest/v/27.0.1)
|
28
|
+
- Uptake [ts-jest@27.0.5](https://www.npmjs.com/package/ts-jest/v/27.0.5)
|
29
|
+
|
30
|
+
### Fixed
|
31
|
+
- `msdyn_enablechatreconnect` not being parsed properly
|
32
|
+
- Fix unable to start multiple conversations with same instance due to chat client being disposed
|
33
|
+
- Pass logger to adapter
|
8
34
|
|
9
35
|
## [0.2.0] - 2021-04-30
|
10
36
|
### Added
|
package/README.md
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
[](https://badge.fury.io/js/%40microsoft%2Fomnichannel-chat-sdk)
|
4
4
|

|
5
|
+

|
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
|
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;
|
@@ -36,10 +38,13 @@ declare class OmnichannelChatSDK {
|
|
36
38
|
private ic3ClientLogger;
|
37
39
|
private ocSdkLogger;
|
38
40
|
private isPersistentChat;
|
41
|
+
private isChatReconnect;
|
39
42
|
private reconnectId;
|
43
|
+
private refreshTokenTimer;
|
40
44
|
constructor(omnichannelConfig: IOmnichannelConfig, chatSDKConfig?: IChatSDKConfig);
|
41
45
|
setDebug(flag: boolean): void;
|
42
46
|
initialize(): Promise<IChatConfig>;
|
47
|
+
getChatReconnectContext(optionalParams?: ChatReconnectOptionalParams): Promise<ChatReconnectContext>;
|
43
48
|
startChat(optionalParams?: IStartChatOptionalParams): Promise<void>;
|
44
49
|
endChat(): Promise<void>;
|
45
50
|
getCurrentLiveChatContext(): Promise<ILiveChatContext | {}>;
|
@@ -69,5 +74,6 @@ declare class OmnichannelChatSDK {
|
|
69
74
|
private getChatConfig;
|
70
75
|
private resolveIC3ClientUrl;
|
71
76
|
private resolveChatAdapterUrl;
|
77
|
+
private updateChatToken;
|
72
78
|
}
|
73
79
|
export default OmnichannelChatSDK;
|