@microsoft/omnichannel-chat-sdk 1.0.0 → 1.0.1-main.1e6bcff

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 (36) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +47 -15
  3. package/lib/OmnichannelChatSDK.d.ts +6 -3
  4. package/lib/OmnichannelChatSDK.js +135 -22
  5. package/lib/OmnichannelChatSDK.js.map +1 -1
  6. package/lib/config/settings.d.ts +1 -1
  7. package/lib/config/settings.js +1 -1
  8. package/lib/config/settings.js.map +1 -1
  9. package/lib/core/ChatConfig.d.ts +4 -0
  10. package/lib/core/PostChatContext.d.ts +5 -0
  11. package/lib/core/PostChatContext.js +3 -0
  12. package/lib/core/PostChatContext.js.map +1 -0
  13. package/lib/core/messaging/ACSClient.js +1 -1
  14. package/lib/core/messaging/ACSClient.js.map +1 -1
  15. package/lib/external/ACSAdapter/createFormatEgressTagsMiddleware.d.ts +2 -0
  16. package/lib/external/ACSAdapter/createFormatEgressTagsMiddleware.js +31 -0
  17. package/lib/external/ACSAdapter/createFormatEgressTagsMiddleware.js.map +1 -0
  18. package/lib/external/ACSAdapter/createFormatIngressTagsMiddleware.d.ts +2 -0
  19. package/lib/external/ACSAdapter/createFormatIngressTagsMiddleware.js +25 -0
  20. package/lib/external/ACSAdapter/createFormatIngressTagsMiddleware.js.map +1 -0
  21. package/lib/telemetry/AriaTelemetry.js +5 -0
  22. package/lib/telemetry/AriaTelemetry.js.map +1 -1
  23. package/lib/telemetry/ScenarioMarker.d.ts +2 -0
  24. package/lib/telemetry/ScenarioMarker.js +7 -3
  25. package/lib/telemetry/ScenarioMarker.js.map +1 -1
  26. package/lib/telemetry/TelemetryEvent.d.ts +2 -1
  27. package/lib/telemetry/TelemetryEvent.js +1 -0
  28. package/lib/telemetry/TelemetryEvent.js.map +1 -1
  29. package/lib/tsconfig.tsbuildinfo +1019 -1307
  30. package/lib/utils/locale.d.ts +3 -0
  31. package/lib/utils/locale.js +60 -0
  32. package/lib/utils/locale.js.map +1 -0
  33. package/lib/utils/loggers.d.ts +8 -0
  34. package/lib/utils/loggers.js +24 -0
  35. package/lib/utils/loggers.js.map +1 -1
  36. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -3,6 +3,24 @@ All notable changes to this project will be documented in this file.
3
3
 
4
4
  ## [Unreleased]
5
5
 
6
+ ### Added
7
+ - Add `getPostChatSurveyContext` API method
8
+ - Add `GetPostChatSurveyContext` telemetry event
9
+ - Add `widgetId` & `clientMessageId` as metadata on sending message
10
+ - Update `ChatConfig` interface with `LiveChatVersion`, `allowedFileExtensions` & `maxUploadFileSize` properties
11
+ - Add ability to automatically detect locale from chat config
12
+ - Add `runtimeId` attribute in `OmnichannelChatSDK` & `ChatSDKRuntimeId` field in telemetry
13
+
14
+ ### Fix
15
+ - Add `acs_webchat-chat-adapter` middlewares to format `channelData.tags`
16
+ - Skip `session init` call on existing conversation
17
+ - Fix `chat reconnect` not ending the conversation on calling `ChatSDK.endChat()`
18
+
19
+ ### Changed
20
+ - README: added examples on usages of the post chat APIs.
21
+ - Uptake [@azure/communication-chat@1.1.1](https://www.npmjs.com/package/@azure/communication-chat/v/1.1.1)
22
+ - Uptake [acs_webchat-chat-adapter@0.0.35-beta.2](https://unpkg.com/acs_webchat-chat-adapter@0.0.35-beta.2/dist/chat-adapter.js)
23
+
6
24
  ## [1.0.0] - 2021-10-08
7
25
  ### Added
8
26
  - Add `GetAuthToken` & `GetPreChatSurvey` telemetry events
package/README.md CHANGED
@@ -14,7 +14,7 @@ Please make sure you have a chat widget configured before using this package or
14
14
  - [Installation on React Native](#installation-on-react-native)
15
15
  - [API Reference](#api-reference)
16
16
  - [API Examples](#api-examples)
17
- - [Sample Apps](samples/)
17
+ - [Sample Apps](https://github.com/microsoft/omnichannel-chat-sdk-samples)
18
18
  - [Common Scenarios](#common-scenarios)
19
19
  - [Feature Comparisons](#feature-comparisons)
20
20
  - [Telemetry](#telemetry)
@@ -35,14 +35,12 @@ Omnichannel offers an live chat widget (LCW) by default. You can use the Chat SD
35
35
  | Bring Your Own Widget | ❌ | ✔ | |
36
36
  | Web Support | ✔ | ✔ |
37
37
  | React Native Support | ❌ | ✔ |
38
- | Escalation to Voice & Video | ✔ | Web Only |
39
- | Co-browse | ✔ | Web Only |
40
- | Screen Sharing | ✔ | Web Only |
38
+ | Escalation to Voice & Video | ✔ | | Only supported on Web |
39
+ | Co-browse | ✔ | 3rd party add-on | Only supported on Web |
40
+ | Screen Sharing | ✔ | 3rd party add-on | Only supported on Web |
41
41
  | Authenticated Chat | ✔ | ✔ |
42
42
  | Pre-chat Survey | ✔ | ✔ |
43
- | Post-chat Survey | ✔ | |
44
- | Queue Position | ✔ | ✔ |
45
- | Average Wait Time | ✔ | ✔ |
43
+ | Post-chat Survey | ✔ | |
46
44
  | Download Transcript | ✔ | ✔ |
47
45
  | Email Transcript | ✔ | ✔ |
48
46
  | Data Masking | ✔ | ✔ |
@@ -52,6 +50,8 @@ Omnichannel offers an live chat widget (LCW) by default. You can use the Chat SD
52
50
  | Persistent Chat | ✔ | ✔ |
53
51
  | Chat Reconnect | ✔ | ✔ |
54
52
  | Operating Hours | ✔ | ✔ |
53
+ | Queue Position | ✔ | ✔ | No SDK method. Handled as *system message* |
54
+ | Average Wait Time | ✔ | ✔ | No SDK method. Handled as *system message* |
55
55
 
56
56
  **\*** BYOI: Bring Your Own Implementation
57
57
 
@@ -65,7 +65,26 @@ Omnichannel offers an live chat widget (LCW) by default. You can use the Chat SD
65
65
 
66
66
  The following steps will be required to run Omnichannel Chat SDK on React Native:
67
67
 
68
- 1. Run `npm install node-libs-react-native --save-dev`
68
+ 1. Install `node-libs-react-native`
69
+ ```
70
+ npm install node-libs-react-native --save-dev
71
+ ```
72
+
73
+ 1. Install `react-native-randomBytes`
74
+ ```
75
+ npm install react-native-randombytes --save-dev
76
+ ```
77
+
78
+ 1. Install `react-native-get-random-values`
79
+ ```
80
+ npm install react-native-get-random-values --save-dev
81
+ ```
82
+
83
+ 1. Install `react-native-url-polyfill`
84
+ ```
85
+ npm install react-native-url-polyfill --save-dev
86
+ ```
87
+
69
88
  1. Update *metro.config.js* to use React Native compatible Node Core modules
70
89
  ```ts
71
90
  module.exports = {
@@ -80,14 +99,11 @@ The following steps will be required to run Omnichannel Chat SDK on React Native
80
99
  };
81
100
  ```
82
101
 
83
- 1. Import 'node-libs-react-native/globals' on top of your entry point file
102
+ 1. Add following *import* on top of your entry point file
84
103
  ```ts
85
104
  import 'node-libs-react-native/globals';
86
- ```
87
-
88
- 1. Install `react-native-randomBytes`
89
- ```
90
- npm install react-native-randombytes --save-dev
105
+ import 'react-native-get-random-values';
106
+ import 'react-native-url-polyfill';
91
107
  ```
92
108
 
93
109
  ## API Reference
@@ -116,7 +132,8 @@ The following steps will be required to run Omnichannel Chat SDK on React Native
116
132
  | OmnichannelChatSDK.uploadFileAttachment() | Send file attachment | |
117
133
  | OmnichannelChatSDK.downloadFileAttachment() | Download file attachment | |
118
134
  | OmnichannelChatSDK.createChatAdapter() | Get IC3Adapter | **Web only** |
119
- | OmnichannelChatSDK.getVoiceVideoCalling() | Get VoiceVideoCall SDK for Escalation to Voice & Video| **Web only** |
135
+ | OmnichannelChatSDK.getVoiceVideoCalling() | Get VoiceVideoCall SDK for Escalation to Voice & Video | **Web only** |
136
+ | OmnichannelChatSDK.getPostChatSurveyContext() | Get post chat survey link, survey locale, and whether an agent has joined the survey | |
120
137
 
121
138
  ## API examples
122
139
 
@@ -194,6 +211,21 @@ The following steps will be required to run Omnichannel Chat SDK on React Native
194
211
  const preChatSurvey = await getPreChatSurvey(parseToJSON); // Adaptive Cards payload data as string
195
212
  ```
196
213
 
214
+ ### Get PostChat Survey
215
+ ```ts
216
+ try {
217
+ const context = await chatSDK.getPostChatSurveyContext();
218
+ if (context.participantJoined) { // participantJoined will be true if an agent has joined the conversation, or a bot has joined the conversation and the bot survey flag has been turned on on the admin side.
219
+ // formsProLocale is the default language you have set on the CustomerVoice portal. You can override this url parameter with any locale that CustomerVoice supports.
220
+ // If "&lang=" is not set on the url, the locale will be English.
221
+ const linkToSend = context.surveyInviteLink + "&lang=" + context.formsProLocale;
222
+ // This link is accessible and will redirect to the survey page. Use it as you see fit.
223
+ }
224
+ } catch (ex) {
225
+ // If the post chat should not be shown by any reason (e.g. post chat is not enabled), promise will be rejected.
226
+ }
227
+ ```
228
+
197
229
  ### Start Chat
198
230
  ```ts
199
231
  const customContext = {
@@ -1,11 +1,11 @@
1
1
  import ACSClient from "./core/messaging/ACSClient";
2
+ import { ParticipantsRemovedEvent } from '@azure/communication-signaling';
2
3
  import ChatConfig from "./core/ChatConfig";
3
4
  import ChatReconnectContext from "./core/ChatReconnectContext";
4
5
  import ChatReconnectOptionalParams from "./core/ChatReconnectOptionalParams";
5
6
  import ChatSDKConfig from "./core/ChatSDKConfig";
6
7
  import ChatSDKMessage from "./core/messaging/ChatSDKMessage";
7
8
  import ChatTranscriptBody from "./core/ChatTranscriptBody";
8
- import { ParticipantsRemovedEvent } from '@azure/communication-signaling';
9
9
  import FileMetadata from "@microsoft/omnichannel-amsclient/lib/FileMetadata";
10
10
  import FramedClient from "@microsoft/omnichannel-amsclient/lib/FramedClient";
11
11
  import FramedlessClient from "@microsoft/omnichannel-amsclient/lib/FramedlessClient";
@@ -13,16 +13,17 @@ import IChatToken from "./external/IC3Adapter/IChatToken";
13
13
  import IFileInfo from "@microsoft/omnichannel-ic3core/lib/interfaces/IFileInfo";
14
14
  import IFileMetadata from "@microsoft/omnichannel-ic3core/lib/model/IFileMetadata";
15
15
  import IMessage from "@microsoft/omnichannel-ic3core/lib/model/IMessage";
16
- import OmnichannelConfig from "./core/OmnichannelConfig";
17
16
  import IRawMessage from "@microsoft/omnichannel-ic3core/lib/model/IRawMessage";
18
17
  import IRawThread from "@microsoft/omnichannel-ic3core/lib/interfaces/IRawThread";
19
18
  import LiveChatContext from "./core/LiveChatContext";
20
19
  import LiveWorkItemDetails from "./core/LiveWorkItemDetails";
21
- import OnNewMessageOptionalParams from "./core/messaging/OnNewMessageOptionalParams";
20
+ import OmnichannelConfig from "./core/OmnichannelConfig";
22
21
  import OmnichannelMessage from "./core/messaging/OmnichannelMessage";
22
+ import OnNewMessageOptionalParams from "./core/messaging/OnNewMessageOptionalParams";
23
23
  import StartChatOptionalParams from "./core/StartChatOptionalParams";
24
24
  declare class OmnichannelChatSDK {
25
25
  private debug;
26
+ runtimeId: string;
26
27
  OCSDKProvider: unknown;
27
28
  IC3SDKProvider: unknown;
28
29
  OCClient: any;
@@ -32,6 +33,7 @@ declare class OmnichannelChatSDK {
32
33
  omnichannelConfig: OmnichannelConfig;
33
34
  chatSDKConfig: ChatSDKConfig;
34
35
  isInitialized: boolean;
36
+ localeId: string;
35
37
  requestId: string;
36
38
  private chatToken;
37
39
  private liveChatConfig;
@@ -81,6 +83,7 @@ declare class OmnichannelChatSDK {
81
83
  getLiveChatTranscript(): Promise<any>;
82
84
  createChatAdapter(protocol?: string | null): Promise<unknown>;
83
85
  getVoiceVideoCalling(params?: any): Promise<any>;
86
+ getPostChatSurveyContext(): Promise<any>;
84
87
  private getIC3Client;
85
88
  private getChatConfig;
86
89
  private resolveIC3ClientUrl;
@@ -55,37 +55,40 @@ var __spreadArrays = (this && this.__spreadArrays) || function () {
55
55
  return r;
56
56
  };
57
57
  Object.defineProperty(exports, "__esModule", { value: true });
58
+ var loggers_1 = require("./utils/loggers");
58
59
  var ACSClient_1 = require("./core/messaging/ACSClient");
60
+ var ocsdk_1 = require("@microsoft/ocsdk");
61
+ var platform_1 = require("./utils/platform");
62
+ var SDKConfigValidators_1 = require("./validators/SDKConfigValidators");
59
63
  var ACSParticipantDisplayName_1 = require("./core/messaging/ACSParticipantDisplayName");
60
64
  var AMSFileManager_1 = require("./external/ACSAdapter/AMSFileManager");
61
65
  var CallingOptionsOptionSetNumber_1 = require("./core/CallingOptionsOptionSetNumber");
62
66
  var ChatAdapterProtocols_1 = require("./core/messaging/ChatAdapterProtocols");
63
67
  var ConversationMode_1 = require("./core/ConversationMode");
64
- var omnichannel_amsclient_1 = require("@microsoft/omnichannel-amsclient");
65
- var loggers_1 = require("./utils/loggers");
66
- var createOmnichannelMessage_1 = require("./utils/createOmnichannelMessage");
67
- var createTelemetry_1 = require("./utils/createTelemetry");
68
- var createVoiceVideoCalling_1 = require("./api/createVoiceVideoCalling");
69
- var MessageTags_1 = require("./core/messaging/MessageTags");
68
+ var createFormatEgressTagsMiddleware_1 = require("./external/ACSAdapter/createFormatEgressTagsMiddleware");
69
+ var createFormatIngressTagsMiddleware_1 = require("./external/ACSAdapter/createFormatIngressTagsMiddleware");
70
70
  var DeliveryMode_1 = require("@microsoft/omnichannel-ic3core/lib/model/DeliveryMode");
71
71
  var FileSharingProtocolType_1 = require("@microsoft/omnichannel-ic3core/lib/model/FileSharingProtocolType");
72
72
  var HostType_1 = require("@microsoft/omnichannel-ic3core/lib/interfaces/HostType");
73
- var utilities_1 = require("./utils/utilities");
74
- var libraries_1 = require("./utils/libraries");
75
- var LiveWorkItemState_1 = require("./core/LiveWorkItemState");
73
+ var omnichannel_ic3core_1 = require("@microsoft/omnichannel-ic3core");
76
74
  var LiveChatVersion_1 = require("./core/LiveChatVersion");
77
- var WebUtils_1 = require("./utils/WebUtils");
75
+ var LiveWorkItemState_1 = require("./core/LiveWorkItemState");
78
76
  var MessageContentType_1 = require("@microsoft/omnichannel-ic3core/lib/model/MessageContentType");
79
77
  var MessageType_1 = require("@microsoft/omnichannel-ic3core/lib/model/MessageType");
80
78
  var PersonType_1 = require("@microsoft/omnichannel-ic3core/lib/model/PersonType");
81
- var platform_1 = require("./utils/platform");
82
79
  var ProtocoleType_1 = require("@microsoft/omnichannel-ic3core/lib/interfaces/ProtocoleType");
83
80
  var ScenarioMarker_1 = require("./telemetry/ScenarioMarker");
84
- var ocsdk_1 = require("@microsoft/ocsdk");
85
- var omnichannel_ic3core_1 = require("@microsoft/omnichannel-ic3core");
86
81
  var TelemetryEvent_1 = require("./telemetry/TelemetryEvent");
82
+ var omnichannel_amsclient_1 = require("@microsoft/omnichannel-amsclient");
83
+ var createOmnichannelMessage_1 = require("./utils/createOmnichannelMessage");
84
+ var createTelemetry_1 = require("./utils/createTelemetry");
85
+ var createVoiceVideoCalling_1 = require("./api/createVoiceVideoCalling");
86
+ var MessageTags_1 = require("./core/messaging/MessageTags");
87
+ var locale_1 = require("./utils/locale");
88
+ var utilities_1 = require("./utils/utilities");
89
+ var libraries_1 = require("./utils/libraries");
90
+ var WebUtils_1 = require("./utils/WebUtils");
87
91
  var OmnichannelConfigValidator_1 = require("./validators/OmnichannelConfigValidator");
88
- var SDKConfigValidators_1 = require("./validators/SDKConfigValidators");
89
92
  var OmnichannelChatSDK = /** @class */ (function () {
90
93
  function OmnichannelChatSDK(omnichannelConfig, chatSDKConfig) {
91
94
  if (chatSDKConfig === void 0) { chatSDKConfig = SDKConfigValidators_1.defaultChatSDKConfig; }
@@ -106,11 +109,13 @@ var OmnichannelChatSDK = /** @class */ (function () {
106
109
  this.reconnectId = null;
107
110
  this.refreshTokenTimer = null;
108
111
  this.debug = false;
112
+ this.runtimeId = ocsdk_1.uuidv4();
109
113
  this.omnichannelConfig = omnichannelConfig;
110
114
  this.chatSDKConfig = __assign(__assign({}, SDKConfigValidators_1.defaultChatSDKConfig), chatSDKConfig // overrides
111
115
  );
112
116
  this.isInitialized = false;
113
117
  this.liveChatVersion = LiveChatVersion_1.default.V1;
118
+ this.localeId = locale_1.defaultLocaleId;
114
119
  this.requestId = ocsdk_1.uuidv4();
115
120
  this.chatToken = {};
116
121
  this.liveChatConfig = {};
@@ -128,6 +133,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
128
133
  this.ocSdkLogger.useTelemetry(this.telemetry);
129
134
  this.acsClientLogger.useTelemetry(this.telemetry);
130
135
  this.acsAdapterLogger.useTelemetry(this.telemetry);
136
+ this.scenarioMarker.setRuntimeId(this.runtimeId);
137
+ this.ic3ClientLogger.setRuntimeId(this.runtimeId);
138
+ this.ocSdkLogger.setRuntimeId(this.runtimeId);
139
+ this.acsClientLogger.setRuntimeId(this.runtimeId);
140
+ this.acsAdapterLogger.setRuntimeId(this.runtimeId);
131
141
  OmnichannelConfigValidator_1.default(omnichannelConfig);
132
142
  SDKConfigValidators_1.default(chatSDKConfig);
133
143
  ((_a = this.chatSDKConfig.telemetry) === null || _a === void 0 ? void 0 : _a.disable) && ((_b = this.telemetry) === null || _b === void 0 ? void 0 : _b.disable());
@@ -323,7 +333,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
323
333
  };
324
334
  throw Error(exceptionDetails.response);
325
335
  case 4:
326
- if (!(optionalParams.liveChatContext && !this.isPersistentChat && !this.isChatReconnect)) return [3 /*break*/, 6];
336
+ if (!(optionalParams.liveChatContext && !this.reconnectId)) return [3 /*break*/, 6];
327
337
  this.chatToken = optionalParams.liveChatContext.chatToken || {};
328
338
  this.requestId = optionalParams.liveChatContext.requestId || ocsdk_1.uuidv4();
329
339
  return [4 /*yield*/, this.getConversationDetails()];
@@ -368,6 +378,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
368
378
  sessionInitOptionalParams = {
369
379
  initContext: {}
370
380
  };
381
+ sessionInitOptionalParams.initContext.locale = locale_1.getLocaleStringFromId(this.localeId);
371
382
  if (this.isPersistentChat && !((_g = this.chatSDKConfig.persistentChat) === null || _g === void 0 ? void 0 : _g.disable)) {
372
383
  sessionInitOptionalParams.reconnectId = this.reconnectId;
373
384
  }
@@ -399,6 +410,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
399
410
  if (this.authenticatedUserToken) {
400
411
  sessionInitOptionalParams.authenticatedUserToken = this.authenticatedUserToken;
401
412
  }
413
+ if (!!optionalParams.liveChatContext) return [3 /*break*/, 12];
402
414
  _s.label = 9;
403
415
  case 9:
404
416
  _s.trys.push([9, 11, , 12]);
@@ -579,6 +591,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
579
591
  }
580
592
  if (this.isChatReconnect && !((_b = this.chatSDKConfig.chatReconnect) === null || _b === void 0 ? void 0 : _b.disable) && !this.isPersistentChat) {
581
593
  isChatReconnect = this.reconnectId !== null ? true : false;
594
+ this.requestId = isChatReconnect ? this.reconnectId : this.requestId; // Chat Reconnect session to close
582
595
  sessionCloseOptionalParams.isReconnectChat = isChatReconnect;
583
596
  }
584
597
  if (this.authenticatedUserToken) {
@@ -896,6 +909,13 @@ var OmnichannelChatSDK = /** @class */ (function () {
896
909
  sendMessageRequest = {
897
910
  content: message.content,
898
911
  };
912
+ sendMessageRequest.metadata = {
913
+ widgetId: this.omnichannelConfig.widgetId,
914
+ clientMessageId: Date.now().toString()
915
+ };
916
+ if (message.metadata) {
917
+ sendMessageRequest.metadata = __assign(__assign({}, sendMessageRequest.metadata), message.metadata);
918
+ }
899
919
  _e.label = 1;
900
920
  case 1:
901
921
  _e.trys.push([1, 3, , 4]);
@@ -1278,7 +1298,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
1278
1298
  };
1279
1299
  sendMessageRequest = {
1280
1300
  content: '',
1281
- metadata: __assign(__assign({}, fileIdsProperty), fileMetaProperty)
1301
+ metadata: __assign(__assign({ widgetId: this.omnichannelConfig.widgetId, clientMessageId: Date.now().toString() }, fileIdsProperty), fileMetaProperty)
1282
1302
  };
1283
1303
  messageToSend = {
1284
1304
  content: "",
@@ -1504,16 +1524,20 @@ var OmnichannelChatSDK = /** @class */ (function () {
1504
1524
  }
1505
1525
  if (protocol === ChatAdapterProtocols_1.default.ACS || this.liveChatVersion === LiveChatVersion_1.default.V2) {
1506
1526
  return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
1507
- var featuresOption, acsAdapterCDNUrl;
1527
+ var egressMiddlewares, ingressMiddlewares, featuresOption, acsAdapterCDNUrl;
1508
1528
  var _this = this;
1509
1529
  var _a;
1510
1530
  return __generator(this, function (_b) {
1511
1531
  switch (_b.label) {
1512
1532
  case 0:
1533
+ egressMiddlewares = [createFormatEgressTagsMiddleware_1.default()];
1534
+ ingressMiddlewares = [createFormatIngressTagsMiddleware_1.default()];
1513
1535
  featuresOption = {
1514
- enableAdaptiveCards: false,
1536
+ enableAdaptiveCards: true,
1515
1537
  enableThreadMemberUpdateNotification: true,
1516
- enableLeaveThreadOnWindowClosed: false
1538
+ enableLeaveThreadOnWindowClosed: false,
1539
+ egressMiddleware: egressMiddlewares,
1540
+ ingressMiddleware: ingressMiddlewares
1517
1541
  };
1518
1542
  acsAdapterCDNUrl = this.resolveChatAdapterUrl(protocol || ChatAdapterProtocols_1.default.ACS);
1519
1543
  (_a = this.telemetry) === null || _a === void 0 ? void 0 : _a.setCDNPackages({
@@ -1525,7 +1549,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
1525
1549
  try {
1526
1550
  var ChatAdapter = window.ChatAdapter; // eslint-disable-line @typescript-eslint/no-explicit-any
1527
1551
  var fileManager = new AMSFileManager_1.default(_this.AMSClient, _this.acsAdapterLogger);
1528
- var adapter = ChatAdapter.createACSAdapter(_this.chatToken.token, _this.chatToken.visitorId || 'teamsvisitor', _this.chatToken.chatId, _this.chatToken.acsEndpoint, fileManager, 1000, ACSParticipantDisplayName_1.default.Customer, undefined, featuresOption);
1552
+ var adapter = ChatAdapter.createACSAdapter(_this.chatToken.token, _this.chatToken.visitorId || 'teamsvisitor', _this.chatToken.chatId, _this.chatToken.acsEndpoint, fileManager, 1000, ACSParticipantDisplayName_1.default.Customer, undefined, undefined, // logger
1553
+ featuresOption);
1529
1554
  resolve(adapter);
1530
1555
  }
1531
1556
  catch (_a) {
@@ -1659,6 +1684,92 @@ var OmnichannelChatSDK = /** @class */ (function () {
1659
1684
  });
1660
1685
  });
1661
1686
  };
1687
+ OmnichannelChatSDK.prototype.getPostChatSurveyContext = function () {
1688
+ return __awaiter(this, void 0, void 0, function () {
1689
+ var conversationId, liveWSAndLiveChatEngJoin, msdyn_postconversationsurveyenable, msfp_sourcesurveyidentifier, postConversationSurveyOwnerId, liveWorkItemDetails, participantJoined, surveyInviteLinkRequest, optionalParams, surveyInviteLinkResponse, surveyInviteLink, formsProLocale, postChatContext, ex_1;
1690
+ return __generator(this, function (_a) {
1691
+ switch (_a.label) {
1692
+ case 0:
1693
+ this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetPostChatSurveyContext, {
1694
+ RequestId: this.requestId
1695
+ });
1696
+ _a.label = 1;
1697
+ case 1:
1698
+ _a.trys.push([1, 6, , 7]);
1699
+ liveWSAndLiveChatEngJoin = this.liveChatConfig.LiveWSAndLiveChatEngJoin;
1700
+ msdyn_postconversationsurveyenable = liveWSAndLiveChatEngJoin.msdyn_postconversationsurveyenable, msfp_sourcesurveyidentifier = liveWSAndLiveChatEngJoin.msfp_sourcesurveyidentifier, postConversationSurveyOwnerId = liveWSAndLiveChatEngJoin.postConversationSurveyOwnerId;
1701
+ if (!msdyn_postconversationsurveyenable) return [3 /*break*/, 4];
1702
+ return [4 /*yield*/, this.OCClient.getLWIDetails(this.requestId)];
1703
+ case 2:
1704
+ liveWorkItemDetails = _a.sent();
1705
+ participantJoined = (liveWorkItemDetails === null || liveWorkItemDetails === void 0 ? void 0 : liveWorkItemDetails.CanRenderPostChat) && (liveWorkItemDetails === null || liveWorkItemDetails === void 0 ? void 0 : liveWorkItemDetails.CanRenderPostChat) === "True";
1706
+ conversationId = liveWorkItemDetails === null || liveWorkItemDetails === void 0 ? void 0 : liveWorkItemDetails.ConversationId;
1707
+ surveyInviteLinkRequest = {
1708
+ "FormId": msfp_sourcesurveyidentifier,
1709
+ "ConversationId": conversationId,
1710
+ "OCLocaleCode": locale_1.getLocaleStringFromId(this.localeId) || locale_1.getLocaleStringFromId(locale_1.defaultLocaleId)
1711
+ };
1712
+ optionalParams = {
1713
+ "requestId": this.requestId
1714
+ };
1715
+ if (this.authenticatedUserToken) {
1716
+ optionalParams.authenticatedUserToken = this.authenticatedUserToken;
1717
+ }
1718
+ return [4 /*yield*/, this.OCClient.getSurveyInviteLink(postConversationSurveyOwnerId, surveyInviteLinkRequest)];
1719
+ case 3:
1720
+ surveyInviteLinkResponse = _a.sent();
1721
+ surveyInviteLink = void 0, formsProLocale = void 0;
1722
+ if (surveyInviteLinkResponse != null) {
1723
+ if (surveyInviteLinkResponse.inviteList != null && surveyInviteLinkResponse.inviteList.length == 1) {
1724
+ surveyInviteLink = surveyInviteLinkResponse.inviteList[0].invitationLink;
1725
+ }
1726
+ else {
1727
+ this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetPostChatSurveyContext, {
1728
+ ConversationId: conversationId,
1729
+ RequestId: this.requestId,
1730
+ ExceptionDetails: "Survey Invite link failed to send response."
1731
+ });
1732
+ return [2 /*return*/, Promise.reject("Survey Invite link failed to send response.")];
1733
+ }
1734
+ if (surveyInviteLinkResponse.formsProLocaleCode != null) {
1735
+ formsProLocale = surveyInviteLinkResponse.formsProLocaleCode;
1736
+ }
1737
+ postChatContext = {
1738
+ participantJoined: participantJoined,
1739
+ surveyInviteLink: surveyInviteLink,
1740
+ formsProLocale: formsProLocale
1741
+ };
1742
+ return [2 /*return*/, Promise.resolve(postChatContext)];
1743
+ }
1744
+ else {
1745
+ this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetPostChatSurveyContext, {
1746
+ ConversationId: conversationId,
1747
+ RequestId: this.requestId,
1748
+ ExceptionDetails: "surveyInviteLinkResponse is null."
1749
+ });
1750
+ return [2 /*return*/, Promise.reject("surveyInviteLinkResponse is null.")];
1751
+ }
1752
+ return [3 /*break*/, 5];
1753
+ case 4:
1754
+ this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetPostChatSurveyContext, {
1755
+ RequestId: this.requestId,
1756
+ ExceptionDetails: "Post Chat Survey is disabled. Please check the Omnichannel Administration Portal."
1757
+ });
1758
+ return [2 /*return*/, Promise.reject("Post Chat is disabled from admin side.")];
1759
+ case 5: return [3 /*break*/, 7];
1760
+ case 6:
1761
+ ex_1 = _a.sent();
1762
+ this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetPostChatSurveyContext, {
1763
+ ConversationId: conversationId,
1764
+ RequestId: this.requestId,
1765
+ ExceptionDetails: JSON.stringify(ex_1)
1766
+ });
1767
+ return [2 /*return*/, Promise.reject("Retrieving post chat context failed " + JSON.stringify(ex_1))];
1768
+ case 7: return [2 /*return*/];
1769
+ }
1770
+ });
1771
+ });
1772
+ };
1662
1773
  OmnichannelChatSDK.prototype.getIC3Client = function () {
1663
1774
  return __awaiter(this, void 0, void 0, function () {
1664
1775
  var IC3Client;
@@ -1744,7 +1855,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
1744
1855
  };
1745
1856
  OmnichannelChatSDK.prototype.getChatConfig = function () {
1746
1857
  return __awaiter(this, void 0, void 0, function () {
1747
- var liveChatConfig, dataMaskingConfig, authSettings, liveWSAndLiveChatEngJoin, liveChatVersion, setting, preChatSurvey, msdyn_prechatenabled, msdyn_callingoptions, msdyn_conversationmode, msdyn_enablechatreconnect, isPreChatEnabled, isChatReconnectEnabled, token, exceptionDetails, _a, exceptionDetails, exceptionDetails, error_18;
1858
+ var liveChatConfig, dataMaskingConfig, authSettings, liveWSAndLiveChatEngJoin, liveChatVersion, chatWidgetLanguage, msdyn_localeid, setting, preChatSurvey, msdyn_prechatenabled, msdyn_callingoptions, msdyn_conversationmode, msdyn_enablechatreconnect, isPreChatEnabled, isChatReconnectEnabled, token, exceptionDetails, _a, exceptionDetails, exceptionDetails, error_18;
1748
1859
  return __generator(this, function (_b) {
1749
1860
  switch (_b.label) {
1750
1861
  case 0:
@@ -1752,7 +1863,9 @@ var OmnichannelChatSDK = /** @class */ (function () {
1752
1863
  return [4 /*yield*/, this.OCClient.getChatConfig()];
1753
1864
  case 1:
1754
1865
  liveChatConfig = _b.sent();
1755
- dataMaskingConfig = liveChatConfig.DataMaskingInfo, authSettings = liveChatConfig.LiveChatConfigAuthSettings, liveWSAndLiveChatEngJoin = liveChatConfig.LiveWSAndLiveChatEngJoin, liveChatVersion = liveChatConfig.LiveChatVersion;
1866
+ dataMaskingConfig = liveChatConfig.DataMaskingInfo, authSettings = liveChatConfig.LiveChatConfigAuthSettings, liveWSAndLiveChatEngJoin = liveChatConfig.LiveWSAndLiveChatEngJoin, liveChatVersion = liveChatConfig.LiveChatVersion, chatWidgetLanguage = liveChatConfig.ChatWidgetLanguage;
1867
+ msdyn_localeid = chatWidgetLanguage.msdyn_localeid;
1868
+ this.localeId = msdyn_localeid || locale_1.defaultLocaleId;
1756
1869
  this.liveChatVersion = liveChatVersion || LiveChatVersion_1.default.V1;
1757
1870
  /* istanbul ignore next */
1758
1871
  this.debug && console.log("[OmnichannelChatSDK][getChatConfig][liveChatVersion] " + this.liveChatVersion);