@microsoft/omnichannel-chat-widget 1.8.2-main.e3c1d40 → 1.8.2-main.fc93d3d

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 (44) hide show
  1. package/README.md +2 -0
  2. package/lib/cjs/common/Constants.js +9 -1
  3. package/lib/cjs/components/draggable/DraggableChatWidget.js +16 -1
  4. package/lib/cjs/components/livechatwidget/common/endChat.js +18 -7
  5. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +29 -1
  6. package/lib/cjs/components/livechatwidget/common/liveChatConfigUtils.js +18 -1
  7. package/lib/cjs/components/livechatwidget/common/renderSurveyHelpers.js +31 -7
  8. package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +15 -2
  9. package/lib/cjs/components/livechatwidget/common/startChat.js +5 -3
  10. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +22 -11
  11. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware.js +4 -3
  12. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +12 -6
  13. package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +3 -1
  14. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +3 -1
  15. package/lib/cjs/contexts/createReducer.js +30 -0
  16. package/lib/cjs/controller/componentController.js +2 -2
  17. package/lib/cjs/firstresponselatency/util.js +52 -27
  18. package/lib/cjs/plugins/newMessageEventHandler.js +12 -6
  19. package/lib/esm/common/Constants.js +7 -0
  20. package/lib/esm/components/draggable/DraggableChatWidget.js +16 -1
  21. package/lib/esm/components/livechatwidget/common/endChat.js +18 -7
  22. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +29 -1
  23. package/lib/esm/components/livechatwidget/common/liveChatConfigUtils.js +16 -0
  24. package/lib/esm/components/livechatwidget/common/renderSurveyHelpers.js +33 -9
  25. package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +16 -3
  26. package/lib/esm/components/livechatwidget/common/startChat.js +5 -3
  27. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +22 -11
  28. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware.js +4 -4
  29. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +12 -6
  30. package/lib/esm/contexts/common/LiveChatWidgetActionType.js +3 -1
  31. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +3 -1
  32. package/lib/esm/contexts/createReducer.js +30 -0
  33. package/lib/esm/controller/componentController.js +2 -2
  34. package/lib/esm/firstresponselatency/util.js +49 -25
  35. package/lib/esm/plugins/newMessageEventHandler.js +12 -6
  36. package/lib/types/common/Constants.d.ts +6 -0
  37. package/lib/types/components/livechatwidget/common/liveChatConfigUtils.d.ts +1 -0
  38. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware.d.ts +1 -1
  39. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.d.ts +1 -1
  40. package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +2 -0
  41. package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +3 -1
  42. package/lib/types/firstresponselatency/util.d.ts +17 -0
  43. package/lib/types/plugins/newMessageEventHandler.d.ts +1 -1
  44. package/package.json +3 -3
package/README.md CHANGED
@@ -101,6 +101,8 @@ A javascript sample widget can be found in this repo [here](https://github.com/m
101
101
 
102
102
  A typescript sample widget can be found [here](https://github.com/microsoft/omnichannel-chat-widget/tree/main/chat-widget/samples/typescript-sample). To build it, do ```yarn install``` then ```yarn build``` then ```yarn start``` from typescript sample project root. See [Create LiveChatWidget with Webpack5 and TypeScript](https://github.com/microsoft/omnichannel-chat-widget/blob/main/docs/BuildingUsingWebpack5.md) for additional typescript sample project resources.
103
103
 
104
+ ```react-scripts``` has deprecated to build the sample project, please refer to vite building instructions: [BuildingUsingVite.md](https://github.com/microsoft/omnichannel-chat-widget/blob/main/docs/BuildingUsingVite.md)
105
+
104
106
  ## Components
105
107
 
106
108
  For a detailed guide on how to customize each component with sample usages, please see our new [Developer Guide](https://github.com/microsoft/omnichannel-chat-widget/blob/main/docs/customizations/getstarted.md).
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.WidgetLoadTelemetryMessage = exports.WidgetLoadCustomErrorString = exports.WebChatMiddlewareConstants = exports.TranscriptConstants = exports.StorageType = exports.StartChatErrorPaneConstants = exports.Regex = exports.PrepareEndChatDescriptionConstants = exports.PostChatSurveyTelemetryMessage = exports.ParticipantType = exports.NotificationPaneConstants = exports.MimeTypes = exports.LocaleConstants = exports.LiveWorkItemState = exports.HtmlIdNames = exports.HtmlElementSelectors = exports.HtmlClassNames = exports.HtmlAttributeNames = exports.EnvironmentVersion = exports.ElementType = exports.E2VVOptions = exports.ConversationMode = exports.ConversationEndEntity = exports.Constants = exports.ConfirmationState = exports.AriaTelemetryConstants = exports.AppInsightsTelemetryMessage = exports.AMSConstants = void 0;
6
+ exports.WidgetLoadTelemetryMessage = exports.WidgetLoadCustomErrorString = exports.WebChatMiddlewareConstants = exports.TranscriptConstants = exports.SurveyProvider = exports.StorageType = exports.StartChatErrorPaneConstants = exports.Regex = exports.PrepareEndChatDescriptionConstants = exports.PostChatSurveyTelemetryMessage = exports.ParticipantType = exports.NotificationPaneConstants = exports.MimeTypes = exports.LocaleConstants = exports.LiveWorkItemState = exports.HtmlIdNames = exports.HtmlElementSelectors = exports.HtmlClassNames = exports.HtmlAttributeNames = exports.EnvironmentVersion = exports.ElementType = exports.E2VVOptions = exports.ConversationMode = exports.ConversationEndEntity = exports.Constants = exports.ConfirmationState = exports.AriaTelemetryConstants = exports.AppInsightsTelemetryMessage = exports.AMSConstants = void 0;
7
7
  var _class;
8
8
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
9
9
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
@@ -23,6 +23,9 @@ _defineProperty(Constants, "channelMessageTag", "channel");
23
23
  _defineProperty(Constants, "historyMessageTag", "history");
24
24
  _defineProperty(Constants, "agentEndConversationMessageTag", "agentendconversation");
25
25
  _defineProperty(Constants, "supervisorForceCloseMessageTag", "supervisorforceclosedconversation");
26
+ _defineProperty(Constants, "endConversationalSurveyMessageTag", "endconversationalsurvey");
27
+ _defineProperty(Constants, "startConversationalSurveyMessageTag", "startconversationalsurvey");
28
+ _defineProperty(Constants, "c2ConversationalSurveyMessageTag", "c2conversationalsurvey");
26
29
  _defineProperty(Constants, "receivedMessageClassName", "ms_lcw_webchat_received_message");
27
30
  _defineProperty(Constants, "sentMessageClassName", "ms_lcw_webchat_sent_message");
28
31
  _defineProperty(Constants, "webchatChannelId", "webchat");
@@ -240,6 +243,11 @@ exports.ConversationMode = ConversationMode;
240
243
  ConversationMode["Regular"] = "192350000";
241
244
  ConversationMode["Persistent"] = "192350001";
242
245
  })(ConversationMode || (exports.ConversationMode = ConversationMode = {}));
246
+ let SurveyProvider;
247
+ exports.SurveyProvider = SurveyProvider;
248
+ (function (SurveyProvider) {
249
+ SurveyProvider["MicrosoftCopilotStudio"] = "600990001";
250
+ })(SurveyProvider || (exports.SurveyProvider = SurveyProvider = {}));
243
251
  let LiveWorkItemState;
244
252
  exports.LiveWorkItemState = LiveWorkItemState;
245
253
  (function (LiveWorkItemState) {
@@ -34,8 +34,11 @@ const DraggableChatWidget = props => {
34
34
  };
35
35
  const calculateOffsetsWithinViewport = (0, _react.useCallback)((id, offset, delta) => {
36
36
  const draggableElement = document.getElementById(id);
37
+ if ((0, _utils.isNullOrUndefined)(draggableElement)) {
38
+ return;
39
+ }
37
40
  const positionRelativeToViewport = draggableElement.getBoundingClientRect();
38
- if ((0, _utils.isNullOrUndefined)(draggableElement) || (0, _utils.isNullOrUndefined)(positionRelativeToViewport) || (0, _utils.isNullOrUndefined)(offset.offsetLeft) || (0, _utils.isNullOrUndefined)(offset.offsetTop)) {
41
+ if ((0, _utils.isNullOrUndefined)(positionRelativeToViewport) || (0, _utils.isNullOrUndefined)(offset.offsetLeft) || (0, _utils.isNullOrUndefined)(offset.offsetTop)) {
39
42
  return;
40
43
  }
41
44
  let offsetLeft = offset.offsetLeft;
@@ -77,6 +80,9 @@ const DraggableChatWidget = props => {
77
80
  }
78
81
  const cacheInitialPosition = () => {
79
82
  const draggableElement = document.getElementById(props.elementId);
83
+ if ((0, _utils.isNullOrUndefined)(draggableElement)) {
84
+ return;
85
+ }
80
86
  const offsetLeft = draggableElement.offsetLeft;
81
87
  const offsetTop = draggableElement.offsetTop;
82
88
  setInitialPosition({
@@ -86,6 +92,9 @@ const DraggableChatWidget = props => {
86
92
  };
87
93
  const calculateOffsets = () => {
88
94
  const draggableElement = document.getElementById(props.elementId);
95
+ if ((0, _utils.isNullOrUndefined)(draggableElement)) {
96
+ return;
97
+ }
89
98
  const offsetLeft = draggableElement.offsetLeft;
90
99
  const offsetTop = draggableElement.offsetTop;
91
100
 
@@ -120,6 +129,9 @@ const DraggableChatWidget = props => {
120
129
  resetPosition(initialPosition);
121
130
  } else if (state.appStates.isMinimized) {
122
131
  const draggableElement = document.getElementById(props.elementId);
132
+ if ((0, _utils.isNullOrUndefined)(draggableElement)) {
133
+ return;
134
+ }
123
135
  const offsetLeft = draggableElement.offsetLeft;
124
136
  const offsetTop = draggableElement.offsetTop;
125
137
  if (!cachedPosition) {
@@ -144,6 +156,9 @@ const DraggableChatWidget = props => {
144
156
 
145
157
  // Update position via DOM manipulation to prevent <Stack/> continuously rendering on style change causing high CPU spike
146
158
  const draggableElement = document.getElementById(props.elementId);
159
+ if ((0, _utils.isNullOrUndefined)(draggableElement)) {
160
+ return;
161
+ }
147
162
  repositionElement(draggableElement, offsetLeft, offsetTop);
148
163
  setPosition({
149
164
  offsetLeft,
@@ -21,7 +21,7 @@ var _omnichannelChatSdk = require("@microsoft/omnichannel-chat-sdk");
21
21
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
22
22
  const prepareEndChat = async (props, facadeChatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter) => {
23
23
  try {
24
- var _conversationDetails$, _state$domainStates, _state$appStates3;
24
+ var _conversationDetails$, _state$domainStates, _state$appStates5;
25
25
  const {
26
26
  chatConfig
27
27
  } = props;
@@ -32,7 +32,7 @@ const prepareEndChat = async (props, facadeChatSDK, state, dispatch, setAdapter,
32
32
 
33
33
  // Use Case: When post chat is not configured
34
34
  if ((conversationDetails === null || conversationDetails === void 0 ? void 0 : (_conversationDetails$ = conversationDetails.canRenderPostChat) === null || _conversationDetails$ === void 0 ? void 0 : _conversationDetails$.toLowerCase()) === _Constants.Constants.false) {
35
- var _state$appStates;
35
+ var _state$appStates, _state$appStates2, _state$appStates3;
36
36
  // If ended by customer, just close chat
37
37
  if ((state === null || state === void 0 ? void 0 : (_state$appStates = state.appStates) === null || _state$appStates === void 0 ? void 0 : _state$appStates.conversationEndedBy) === _Constants.ConversationEndEntity.Customer) {
38
38
  _TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
@@ -43,6 +43,13 @@ const prepareEndChat = async (props, facadeChatSDK, state, dispatch, setAdapter,
43
43
  }
44
44
 
45
45
  // Use Case: If ended by Agent, stay chat in InActive state
46
+ let isConversationalSurveyEnabled = state.appStates.isConversationalSurveyEnabled;
47
+ if (isConversationalSurveyEnabled && ((state === null || state === void 0 ? void 0 : (_state$appStates2 = state.appStates) === null || _state$appStates2 === void 0 ? void 0 : _state$appStates2.conversationEndedBy) === _Constants.ConversationEndEntity.Agent || (state === null || state === void 0 ? void 0 : (_state$appStates3 = state.appStates) === null || _state$appStates3 === void 0 ? void 0 : _state$appStates3.conversationEndedBy) === _Constants.ConversationEndEntity.Bot)) {
48
+ dispatch({
49
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
50
+ payload: _ConversationState.ConversationState.InActive
51
+ });
52
+ }
46
53
  return;
47
54
  }
48
55
 
@@ -58,7 +65,7 @@ const prepareEndChat = async (props, facadeChatSDK, state, dispatch, setAdapter,
58
65
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
59
66
  const postchatContext = (await (0, _renderSurveyHelpers.getPostChatContext)(facadeChatSDK, state, dispatch)) ?? (state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : _state$domainStates.postChatContext);
60
67
  if (postchatContext === undefined) {
61
- var _state$appStates2;
68
+ var _state$appStates4;
62
69
  _omnichannelChatComponents.BroadcastService.postMessage({
63
70
  eventName: _TelemetryConstants.BroadcastEvent.OnWidgetError,
64
71
  payload: {
@@ -67,7 +74,7 @@ const prepareEndChat = async (props, facadeChatSDK, state, dispatch, setAdapter,
67
74
  });
68
75
 
69
76
  // For Customer intiated conversations, just close chat widget
70
- if ((state === null || state === void 0 ? void 0 : (_state$appStates2 = state.appStates) === null || _state$appStates2 === void 0 ? void 0 : _state$appStates2.conversationEndedBy) === _Constants.ConversationEndEntity.Customer) {
77
+ if ((state === null || state === void 0 ? void 0 : (_state$appStates4 = state.appStates) === null || _state$appStates4 === void 0 ? void 0 : _state$appStates4.conversationEndedBy) === _Constants.ConversationEndEntity.Customer) {
71
78
  _TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
72
79
  Event: _TelemetryConstants.TelemetryEvent.PrepareEndChat,
73
80
  Description: _Constants.PrepareEndChatDescriptionConstants.ConversationEndedByCustomerWithInvalidPostChat
@@ -85,11 +92,11 @@ const prepareEndChat = async (props, facadeChatSDK, state, dispatch, setAdapter,
85
92
  }
86
93
 
87
94
  // Log PrepareEndChat if conversation ended by customer (bot and agent cases are handled in LiveChatWidgetStateful.tsx)
88
- if (state !== null && state !== void 0 && (_state$appStates3 = state.appStates) !== null && _state$appStates3 !== void 0 && _state$appStates3.conversationEndedBy) {
89
- var _state$appStates4;
95
+ if (state !== null && state !== void 0 && (_state$appStates5 = state.appStates) !== null && _state$appStates5 !== void 0 && _state$appStates5.conversationEndedBy) {
96
+ var _state$appStates6;
90
97
  _TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
91
98
  Event: _TelemetryConstants.TelemetryEvent.PrepareEndChat,
92
- Description: `${_Constants.PrepareEndChatDescriptionConstants.ConversationEndedByCustomerWithInvalidPostChat} ${state === null || state === void 0 ? void 0 : (_state$appStates4 = state.appStates) === null || _state$appStates4 === void 0 ? void 0 : _state$appStates4.conversationEndedBy}.`
99
+ Description: `${_Constants.PrepareEndChatDescriptionConstants.ConversationEndedByCustomerWithInvalidPostChat} ${state === null || state === void 0 ? void 0 : (_state$appStates6 = state.appStates) === null || _state$appStates6 === void 0 ? void 0 : _state$appStates6.conversationEndedBy}.`
93
100
  });
94
101
  }
95
102
  const persistentEnabled = (0, _reconnectChatHelper.isPersistentEnabled)(chatConfig);
@@ -265,6 +272,10 @@ const closeChatStateCleanUp = dispatch => {
265
272
  payload: undefined
266
273
  });
267
274
  // dispatch({ type: LiveChatWidgetActionType.SET_CONVERSATION_STATE, payload: ConversationState.Closed });
275
+ dispatch({
276
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATIONAL_SURVEY_DISPLAY,
277
+ payload: false
278
+ });
268
279
  dispatch({
269
280
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_RECONNECT_ID,
270
281
  payload: undefined
@@ -37,6 +37,8 @@ var _htmlPlayerMiddleware = _interopRequireDefault(require("../../webchatcontain
37
37
  var _htmlTextMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware"));
38
38
  var _preProcessingMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/preProcessingMiddleware"));
39
39
  var _sanitizationMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware"));
40
+ var _ConversationState = require("../../../contexts/common/ConversationState");
41
+ var _createReducer = require("../../../contexts/createReducer");
40
42
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
41
43
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
42
44
  const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endChat) => {
@@ -58,6 +60,20 @@ const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endChat) =>
58
60
  let webChatStore = _WebChatStoreLoader.WebChatStoreLoader.store;
59
61
  if (!webChatStore) {
60
62
  var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _props$webChatContain7;
63
+ const addConversationalSurveyTagsCallback = action => {
64
+ var _inMemoryState$appSta;
65
+ const inMemoryState = (0, _createReducer.executeReducer)(state, {
66
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
67
+ payload: null
68
+ });
69
+ const isConversationalSurvey = (_inMemoryState$appSta = inMemoryState.appStates) === null || _inMemoryState$appSta === void 0 ? void 0 : _inMemoryState$appSta.isConversationalSurvey;
70
+ if (isConversationalSurvey) {
71
+ if (!action.payload.activity.channelData.tags.includes(_Constants.Constants.c2ConversationalSurveyMessageTag)) {
72
+ action.payload.activity.channelData.tags.push(_Constants.Constants.c2ConversationalSurveyMessageTag);
73
+ }
74
+ }
75
+ return action;
76
+ };
61
77
  const conversationEndCallback = async () => {
62
78
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
63
79
  const conversationDetails = await (0, _utils.getConversationDetailsCall)(facadeChatSDK);
@@ -87,9 +103,21 @@ const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endChat) =>
87
103
  });
88
104
  }
89
105
  };
106
+ const startConversationalSurveyCallback = async () => {
107
+ dispatch({
108
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATIONAL_SURVEY_DISPLAY,
109
+ payload: true
110
+ });
111
+ };
112
+ const endConversationalSurveyCallback = async () => {
113
+ dispatch({
114
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
115
+ payload: _ConversationState.ConversationState.InActive
116
+ });
117
+ };
90
118
  webChatStore = (0, _botframeworkWebchat.createStore)({},
91
119
  //initial state
92
- _preProcessingMiddleware.default, _attachmentProcessingMiddleware.default, (0, _attachmentUploadValidatorMiddleware.default)((_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : _state$domainStates$l.allowedFileExtensions, (_state$domainStates$l2 = state.domainStates.liveChatConfig) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.maxUploadFileSize, localizedTexts), _channelDataMiddleware.default, (0, _conversationEndMiddleware.default)(conversationEndCallback), (0, _dataMaskingMiddleware.default)((_state$domainStates$l3 = state.domainStates.liveChatConfig) === null || _state$domainStates$l3 === void 0 ? void 0 : _state$domainStates$l3.DataMaskingInfo), _messageTimestampMiddleware.createMessageTimeStampMiddleware, _messageSequenceIdOverrideMiddleware.createMessageSequenceIdOverrideMiddleware, _gifUploadMiddleware.default, _htmlPlayerMiddleware.default, (0, _htmlTextMiddleware.default)(honorsTargetInHTMLLinks), (0, _maxMessageSizeValidator.default)(localizedTexts), _sanitizationMiddleware.default,
120
+ _preProcessingMiddleware.default, _attachmentProcessingMiddleware.default, (0, _attachmentUploadValidatorMiddleware.default)((_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : _state$domainStates$l.allowedFileExtensions, (_state$domainStates$l2 = state.domainStates.liveChatConfig) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.maxUploadFileSize, localizedTexts), (0, _channelDataMiddleware.default)(addConversationalSurveyTagsCallback), (0, _conversationEndMiddleware.default)(conversationEndCallback, startConversationalSurveyCallback, endConversationalSurveyCallback), (0, _dataMaskingMiddleware.default)((_state$domainStates$l3 = state.domainStates.liveChatConfig) === null || _state$domainStates$l3 === void 0 ? void 0 : _state$domainStates$l3.DataMaskingInfo), _messageTimestampMiddleware.createMessageTimeStampMiddleware, _messageSequenceIdOverrideMiddleware.createMessageSequenceIdOverrideMiddleware, _gifUploadMiddleware.default, _htmlPlayerMiddleware.default, (0, _htmlTextMiddleware.default)(honorsTargetInHTMLLinks), (0, _maxMessageSizeValidator.default)(localizedTexts), _sanitizationMiddleware.default,
93
121
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
94
122
  ...(((_props$webChatContain7 = props.webChatContainerProps) === null || _props$webChatContain7 === void 0 ? void 0 : _props$webChatContain7.storeMiddlewares) ?? []));
95
123
  _WebChatStoreLoader.WebChatStoreLoader.store = webChatStore;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.isPostChatSurveyEnabled = exports.isPersistentChatEnabled = void 0;
6
+ exports.isPostChatSurveyEnabled = exports.isPersistentChatEnabled = exports.getPostChatSurveyConfig = void 0;
7
7
  var _Constants = require("../../../common/Constants");
8
8
  var _utils = require("../../../common/utils");
9
9
  const isPostChatSurveyEnabled = async facadeChatSDK => {
@@ -13,6 +13,23 @@ const isPostChatSurveyEnabled = async facadeChatSDK => {
13
13
  return postChatEnabled === "true";
14
14
  };
15
15
  exports.isPostChatSurveyEnabled = isPostChatSurveyEnabled;
16
+ const getPostChatSurveyConfig = async facadeChatSDK => {
17
+ var _chatConfig$LiveWSAnd2, _chatConfig$LiveWSAnd3, _chatConfig$LiveWSAnd4, _chatConfig$LiveWSAnd5, _chatConfig$LiveWSAnd6, _chatConfig$LiveWSAnd7, _chatConfig$LiveWSAnd8, _chatConfig$LiveWSAnd9, _chatConfig$LiveWSAnd10;
18
+ const chatConfig = await facadeChatSDK.getLiveChatConfig();
19
+ const postChatEnabled = (_chatConfig$LiveWSAnd2 = chatConfig.LiveWSAndLiveChatEngJoin) === null || _chatConfig$LiveWSAnd2 === void 0 ? void 0 : _chatConfig$LiveWSAnd2.msdyn_postconversationsurveyenable.toString().toLowerCase();
20
+ const agentSurveyMode = (_chatConfig$LiveWSAnd3 = chatConfig.LiveWSAndLiveChatEngJoin) === null || _chatConfig$LiveWSAnd3 === void 0 ? void 0 : (_chatConfig$LiveWSAnd4 = _chatConfig$LiveWSAnd3.msdyn_postconversationsurveymode) === null || _chatConfig$LiveWSAnd4 === void 0 ? void 0 : _chatConfig$LiveWSAnd4.toString();
21
+ const botSurveyMode = (_chatConfig$LiveWSAnd5 = chatConfig.LiveWSAndLiveChatEngJoin) === null || _chatConfig$LiveWSAnd5 === void 0 ? void 0 : (_chatConfig$LiveWSAnd6 = _chatConfig$LiveWSAnd5.msdyn_postconversationsurveybotsurveymode) === null || _chatConfig$LiveWSAnd6 === void 0 ? void 0 : _chatConfig$LiveWSAnd6.toString();
22
+ const surveyProvider = (_chatConfig$LiveWSAnd7 = chatConfig.LiveWSAndLiveChatEngJoin) === null || _chatConfig$LiveWSAnd7 === void 0 ? void 0 : (_chatConfig$LiveWSAnd8 = _chatConfig$LiveWSAnd7.msdyn_surveyprovider) === null || _chatConfig$LiveWSAnd8 === void 0 ? void 0 : _chatConfig$LiveWSAnd8.toString();
23
+ const isConversationalSurveyEnabled = (_chatConfig$LiveWSAnd9 = chatConfig.LiveWSAndLiveChatEngJoin) === null || _chatConfig$LiveWSAnd9 === void 0 ? void 0 : (_chatConfig$LiveWSAnd10 = _chatConfig$LiveWSAnd9.msdyn_isConversationalPostChatSurveyEnabled) === null || _chatConfig$LiveWSAnd10 === void 0 ? void 0 : _chatConfig$LiveWSAnd10.toString().toLowerCase();
24
+ return {
25
+ postChatEnabled: postChatEnabled === "true",
26
+ agentSurveyMode: agentSurveyMode,
27
+ botSurveyMode: botSurveyMode,
28
+ surveyProvider: surveyProvider,
29
+ isConversationalSurveyEnabled: isConversationalSurveyEnabled === "true"
30
+ };
31
+ };
32
+ exports.getPostChatSurveyConfig = getPostChatSurveyConfig;
16
33
  const isPersistentChatEnabled = conversationMode => {
17
34
  if ((0, _utils.isNullOrUndefined)(conversationMode)) {
18
35
  return false;
@@ -51,23 +51,34 @@ const setSurveyMode = async (props, participantType, state, dispatch) => {
51
51
  };
52
52
 
53
53
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
54
- const renderSurvey = async (postChatContext, dispatch) => {
54
+ const renderSurvey = async (postChatContext, state, dispatch) => {
55
55
  if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Link) {
56
56
  setWidgetStateToInactive(dispatch);
57
57
  return;
58
58
  }
59
59
  if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Embed) {
60
- await embedModePostChatWorkflow(postChatContext, dispatch);
60
+ await embedModePostChatWorkflow(postChatContext, state, dispatch);
61
61
  }
62
62
  };
63
63
 
64
64
  // Function for embed mode postchat workflow which is essentially same for both customer and agent
65
65
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
66
- const embedModePostChatWorkflow = async (postChatContext, dispatch) => {
66
+ const embedModePostChatWorkflow = async (postChatContext, state, dispatch) => {
67
67
  _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
68
68
  Event: _TelemetryConstants.TelemetryEvent.EmbedModePostChatWorkflowStarted
69
69
  });
70
70
  if (postChatContext) {
71
+ if (postChatContext.isConversationalSurveyEnabled && postChatContext.surveyProvider === _Constants.SurveyProvider.MicrosoftCopilotStudio) {
72
+ dispatch({
73
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
74
+ payload: _ConversationState.ConversationState.Postchat
75
+ });
76
+ dispatch({
77
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATIONAL_SURVEY_DISPLAY,
78
+ payload: true
79
+ });
80
+ return;
81
+ }
71
82
  dispatch({
72
83
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
73
84
  payload: _ConversationState.ConversationState.PostchatLoading
@@ -94,7 +105,7 @@ const initiatePostChat = async (props, conversationDetailsParam, state, dispatch
94
105
  conversationDetails = conversationDetailsParam;
95
106
  const participantType = ((_conversationDetails = conversationDetails) === null || _conversationDetails === void 0 ? void 0 : _conversationDetails.participantType) ?? postchatContext.participantType;
96
107
  await setSurveyMode(props, participantType, state, dispatch);
97
- await renderSurvey(postchatContext, dispatch);
108
+ await renderSurvey(postchatContext, state, dispatch);
98
109
  };
99
110
 
100
111
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -109,7 +120,14 @@ const isPostChatEnabled = (props, state) => {
109
120
  exports.checkPostChatEnabled = isPostChatEnabled;
110
121
  const getPostChatContext = async (facadeChatSDK, state, dispatch) => {
111
122
  try {
112
- const postChatEnabled = await (0, _liveChatConfigUtils.isPostChatSurveyEnabled)(facadeChatSDK);
123
+ const postChatConfig = await (0, _liveChatConfigUtils.getPostChatSurveyConfig)(facadeChatSDK);
124
+ const postChatEnabled = postChatConfig.postChatEnabled;
125
+ if (postChatConfig.isConversationalSurveyEnabled) {
126
+ dispatch({
127
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATIONAL_SURVEY_ENABLED,
128
+ payload: true
129
+ });
130
+ }
113
131
  if (postChatEnabled) {
114
132
  var _state$domainStates2;
115
133
  if ((state === null || state === void 0 ? void 0 : (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : _state$domainStates2.postChatContext) === undefined) {
@@ -119,11 +137,17 @@ const getPostChatContext = async (facadeChatSDK, state, dispatch) => {
119
137
  Event: _TelemetryConstants.TelemetryEvent.PostChatContextCallSucceed,
120
138
  Description: _Constants.PostChatSurveyTelemetryMessage.PostChatContextCallSucceed
121
139
  });
140
+
141
+ // Merge postChatConfig with postChatSurveyContext
142
+ const mergedContext = {
143
+ ...context,
144
+ ...postChatConfig
145
+ };
122
146
  dispatch({
123
147
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_POST_CHAT_CONTEXT,
124
- payload: context
148
+ payload: mergedContext
125
149
  });
126
- return context;
150
+ return mergedContext;
127
151
  }
128
152
  }
129
153
  } catch (error) {
@@ -14,7 +14,14 @@ var _liveChatConfigUtils = require("./liveChatConfigUtils");
14
14
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
15
  const setPostChatContextAndLoadSurvey = async (facadeChatSDK, dispatch, persistedChat) => {
16
16
  try {
17
- const postChatEnabled = await (0, _liveChatConfigUtils.isPostChatSurveyEnabled)(facadeChatSDK);
17
+ const postChatConfig = await (0, _liveChatConfigUtils.getPostChatSurveyConfig)(facadeChatSDK);
18
+ if (postChatConfig.isConversationalSurveyEnabled) {
19
+ dispatch({
20
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATIONAL_SURVEY_ENABLED,
21
+ payload: true
22
+ });
23
+ }
24
+ const postChatEnabled = postChatConfig.postChatEnabled;
18
25
  if (postChatEnabled) {
19
26
  if (!persistedChat) {
20
27
  _TelemetryHelper.TelemetryHelper.logSDKEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
@@ -27,9 +34,15 @@ const setPostChatContextAndLoadSurvey = async (facadeChatSDK, dispatch, persiste
27
34
  Event: _TelemetryConstants.TelemetryEvent.PostChatContextCallSucceed,
28
35
  Description: _Constants.PostChatSurveyTelemetryMessage.PostChatContextCallSucceed
29
36
  });
37
+
38
+ // Merge postChatConfig with postChatSurveyContext
39
+ const mergedContext = {
40
+ ...context,
41
+ ...postChatConfig
42
+ };
30
43
  dispatch({
31
44
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_POST_CHAT_CONTEXT,
32
- payload: context
45
+ payload: mergedContext
33
46
  });
34
47
  }
35
48
  }
@@ -204,8 +204,11 @@ const initStartChat = async (facadeChatSDK, dispatch, setAdapter, state, props,
204
204
  portalContactId: (_window$Microsoft = window.Microsoft) === null || _window$Microsoft === void 0 ? void 0 : (_window$Microsoft$Dyn = _window$Microsoft.Dynamic365) === null || _window$Microsoft$Dyn === void 0 ? void 0 : (_window$Microsoft$Dyn2 = _window$Microsoft$Dyn.Portal) === null || _window$Microsoft$Dyn2 === void 0 ? void 0 : (_window$Microsoft$Dyn3 = _window$Microsoft$Dyn2.User) === null || _window$Microsoft$Dyn3 === void 0 ? void 0 : _window$Microsoft$Dyn3.contactId
205
205
  };
206
206
  const startChatOptionalParams = Object.assign({}, params, optionalParams, defaultOptionalParams);
207
+ // startTime is used to determine if a message is history or new, better to be set before creating the adapter to get bandwidth
208
+ const startTime = new Date().getTime();
207
209
  await facadeChatSDK.startChat(startChatOptionalParams);
208
210
  isStartChatSuccessful = true;
211
+ await createAdapterAndSubscribe(facadeChatSDK, dispatch, setAdapter, startTime, props);
209
212
  } catch (error) {
210
213
  (0, _utils.checkContactIdError)(error);
211
214
  _TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
@@ -223,7 +226,6 @@ const initStartChat = async (facadeChatSDK, dispatch, setAdapter, state, props,
223
226
  isStartChatSuccessful = false;
224
227
  throw error;
225
228
  }
226
- await createAdapterAndSubscribe(facadeChatSDK, dispatch, setAdapter, props);
227
229
 
228
230
  // Set app state to Active
229
231
  if (isStartChatSuccessful) {
@@ -274,7 +276,7 @@ const initStartChat = async (facadeChatSDK, dispatch, setAdapter, state, props,
274
276
 
275
277
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
276
278
  exports.initStartChat = initStartChat;
277
- const createAdapterAndSubscribe = async (facadeChatSDK, dispatch, setAdapter, props) => {
279
+ const createAdapterAndSubscribe = async (facadeChatSDK, dispatch, setAdapter, startTime, props) => {
278
280
  // New adapter creation
279
281
  const newAdapter = await (0, _createAdapter.createAdapter)(facadeChatSDK, props);
280
282
  setAdapter(newAdapter);
@@ -285,7 +287,7 @@ const createAdapterAndSubscribe = async (facadeChatSDK, dispatch, setAdapter, pr
285
287
  });
286
288
  if (chatToken !== null && chatToken !== void 0 && chatToken.chatId && chatToken !== null && chatToken !== void 0 && chatToken.visitorId) {
287
289
  var _newAdapter$activity$;
288
- newAdapter === null || newAdapter === void 0 ? void 0 : (_newAdapter$activity$ = newAdapter.activity$) === null || _newAdapter$activity$ === void 0 ? void 0 : _newAdapter$activity$.subscribe((0, _newMessageEventHandler.createOnNewAdapterActivityHandler)(chatToken.chatId, chatToken.visitorId));
290
+ newAdapter === null || newAdapter === void 0 ? void 0 : (_newAdapter$activity$ = newAdapter.activity$) === null || _newAdapter$activity$ === void 0 ? void 0 : _newAdapter$activity$.subscribe((0, _newMessageEventHandler.createOnNewAdapterActivityHandler)(chatToken.chatId, chatToken.visitorId, startTime));
289
291
  }
290
292
  };
291
293
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -619,12 +619,15 @@ const LiveChatWidgetStateful = props => {
619
619
  payload: null
620
620
  });
621
621
  if ("participantsRemoved" in event && (inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta5 = inMemoryState.appStates) === null || _inMemoryState$appSta5 === void 0 ? void 0 : _inMemoryState$appSta5.conversationState) === _ConversationState.ConversationState.Active) {
622
- setWebChatStyles(styles => {
623
- return {
624
- ...styles,
625
- hideSendBox: true
626
- };
627
- });
622
+ var _inMemoryState$appSta6;
623
+ if ((inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta6 = inMemoryState.appStates) === null || _inMemoryState$appSta6 === void 0 ? void 0 : _inMemoryState$appSta6.isConversationalSurveyEnabled) === false) {
624
+ setWebChatStyles(styles => {
625
+ return {
626
+ ...styles,
627
+ hideSendBox: true
628
+ };
629
+ });
630
+ }
628
631
  _TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
629
632
  Event: _TelemetryConstants.TelemetryEvent.ParticipantsRemovedEvent,
630
633
  Description: "Participants removed event received."
@@ -720,7 +723,15 @@ const LiveChatWidgetStateful = props => {
720
723
  (0, _endChat.endChat)(props, facadeChatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true);
721
724
  return;
722
725
  }
723
- if ((state === null || state === void 0 ? void 0 : (_state$appStates12 = state.appStates) === null || _state$appStates12 === void 0 ? void 0 : _state$appStates12.conversationEndedBy) === _Constants.ConversationEndEntity.Agent || (state === null || state === void 0 ? void 0 : (_state$appStates13 = state.appStates) === null || _state$appStates13 === void 0 ? void 0 : _state$appStates13.conversationEndedBy) === _Constants.ConversationEndEntity.Bot) {
726
+ const inMemoryState = (0, _createReducer.executeReducer)(state, {
727
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
728
+ payload: null
729
+ });
730
+ let isConversationalSurveyEnabled = state.appStates.isConversationalSurveyEnabled;
731
+
732
+ // In conversational survey, we need to check post chat survey logics before we set ConversationState to InActive
733
+ // Hence setting ConversationState to InActive will be done later in the post chat flows
734
+ if (!isConversationalSurveyEnabled && ((state === null || state === void 0 ? void 0 : (_state$appStates12 = state.appStates) === null || _state$appStates12 === void 0 ? void 0 : _state$appStates12.conversationEndedBy) === _Constants.ConversationEndEntity.Agent || (state === null || state === void 0 ? void 0 : (_state$appStates13 = state.appStates) === null || _state$appStates13 === void 0 ? void 0 : _state$appStates13.conversationEndedBy) === _Constants.ConversationEndEntity.Bot)) {
724
735
  dispatch({
725
736
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
726
737
  payload: _ConversationState.ConversationState.InActive
@@ -761,13 +772,13 @@ const LiveChatWidgetStateful = props => {
761
772
 
762
773
  // Handle Chat disconnect cases
763
774
  (0, _react2.useEffect)(() => {
764
- var _inMemoryState$appSta6;
775
+ var _inMemoryState$appSta7;
765
776
  const inMemoryState = (0, _createReducer.executeReducer)(state, {
766
777
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
767
778
  payload: null
768
779
  });
769
780
  (0, _chatDisconnectHelper.handleChatDisconnect)(props, inMemoryState, setWebChatStyles);
770
- const chatDisconnectState = inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta6 = inMemoryState.appStates) === null || _inMemoryState$appSta6 === void 0 ? void 0 : _inMemoryState$appSta6.chatDisconnectEventReceived;
781
+ const chatDisconnectState = inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta7 = inMemoryState.appStates) === null || _inMemoryState$appSta7 === void 0 ? void 0 : _inMemoryState$appSta7.chatDisconnectEventReceived;
771
782
  if (chatDisconnectState && adapter) {
772
783
  try {
773
784
  adapter.end();
@@ -895,8 +906,8 @@ const LiveChatWidgetStateful = props => {
895
906
  margin-left: .25em;
896
907
  }
897
908
  ${(sendBoxTextArea === null || sendBoxTextArea === void 0 ? void 0 : sendBoxTextArea.minHeight) && `
898
- textarea.webchat__send-box-text-box__html-text-area {
899
- min-height: ${sendBoxTextArea === null || sendBoxTextArea === void 0 ? void 0 : sendBoxTextArea.minHeight};
909
+ .webchat__auto-resize-textarea.webchat__send-box-text-box__text-area {
910
+ min-height: ${sendBoxTextArea === null || sendBoxTextArea === void 0 ? void 0 : sendBoxTextArea.minHeight} !important;
900
911
  }`}
901
912
  `), /*#__PURE__*/_react2.default.createElement(_DraggableChatWidget.default, chatWidgetDraggableConfig, /*#__PURE__*/_react2.default.createElement(Composer, _extends({}, webChatProps, {
902
913
  userID: userID,
@@ -14,13 +14,13 @@ var _WebChatActionType = require("../../enums/WebChatActionType");
14
14
  ******/
15
15
 
16
16
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
17
- const channelDataMiddleware = _ref => {
17
+ const channelDataMiddleware = addConversationalSurveyTagsCallback => _ref => {
18
18
  let {
19
19
  dispatch
20
20
  } = _ref;
21
21
  return next => action => {
22
- var _action$payload, _action$payload$activ;
23
- if ((action === null || action === void 0 ? void 0 : action.type) === _WebChatActionType.WebChatActionType.DIRECT_LINE_POST_ACTIVITY_PENDING && action !== null && action !== void 0 && (_action$payload = action.payload) !== null && _action$payload !== void 0 && (_action$payload$activ = _action$payload.activity) !== null && _action$payload$activ !== void 0 && _action$payload$activ.channelData) {
22
+ var _action, _action2, _action2$payload, _action2$payload$acti;
23
+ if (((_action = action) === null || _action === void 0 ? void 0 : _action.type) === _WebChatActionType.WebChatActionType.DIRECT_LINE_POST_ACTIVITY_PENDING && (_action2 = action) !== null && _action2 !== void 0 && (_action2$payload = _action2.payload) !== null && _action2$payload !== void 0 && (_action2$payload$acti = _action2$payload.activity) !== null && _action2$payload$acti !== void 0 && _action2$payload$acti.channelData) {
24
24
  const channelIdTag = `${_Constants.Constants.channelIdKey}${_Constants.Constants.ChannelId}`;
25
25
  const customerMessageTag = `${_Constants.Constants.CustomerTag}`;
26
26
  if (action.payload.activity.channelData.tags) {
@@ -34,6 +34,7 @@ const channelDataMiddleware = _ref => {
34
34
  action.payload.activity.channelData.tags = [channelIdTag];
35
35
  action.payload.activity.channelData.tags.push(customerMessageTag);
36
36
  }
37
+ action = addConversationalSurveyTagsCallback(action);
37
38
  action.payload.activity.channelData.metadata = {
38
39
  deliveryMode: _omnichannelChatSdk.DeliveryMode.Bridged
39
40
  };
@@ -16,27 +16,33 @@ var _WebChatActionType = require("../../enums/WebChatActionType");
16
16
  ******/
17
17
 
18
18
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
19
- const createConversationEndMiddleware = conversationEndCallback => _ref => {
19
+ const createConversationEndMiddleware = (conversationEndCallback, startConversationalSurveyCallback, endConversationalSurveyCallback) => _ref => {
20
20
  let {
21
21
  dispatch
22
22
  } = _ref;
23
23
  return next => action => {
24
24
  var _action$payload;
25
25
  if ((action === null || action === void 0 ? void 0 : action.type) == _WebChatActionType.WebChatActionType.DIRECT_LINE_INCOMING_ACTIVITY && (_action$payload = action.payload) !== null && _action$payload !== void 0 && _action$payload.activity) {
26
- var _activity$from2, _activity$channelData7, _activity$channelData8;
26
+ var _activity$from2, _activity$channelData17, _activity$channelData18;
27
27
  const activity = action.payload.activity;
28
28
  if (activity.channelId === "ACS_CHANNEL") {
29
29
  var _activity$from;
30
30
  if (((_activity$from = activity.from) === null || _activity$from === void 0 ? void 0 : _activity$from.role) === _DirectLineSenderRole.DirectLineSenderRole.Bot) {
31
- var _activity$channelData, _activity$channelData2, _activity$channelData3, _activity$channelData4, _activity$channelData5, _activity$channelData6;
31
+ var _activity$channelData, _activity$channelData2, _activity$channelData3, _activity$channelData4, _activity$channelData5, _activity$channelData6, _activity$channelData7, _activity$channelData8, _activity$channelData9, _activity$channelData10, _activity$channelData11, _activity$channelData12, _activity$channelData13, _activity$channelData14, _activity$channelData15, _activity$channelData16;
32
32
  if ((_activity$channelData = activity.channelData) !== null && _activity$channelData !== void 0 && (_activity$channelData2 = _activity$channelData.tags) !== null && _activity$channelData2 !== void 0 && _activity$channelData2.includes(_Constants.Constants.systemMessageTag) && ((_activity$channelData3 = activity.channelData) !== null && _activity$channelData3 !== void 0 && (_activity$channelData4 = _activity$channelData3.tags) !== null && _activity$channelData4 !== void 0 && _activity$channelData4.includes(_Constants.Constants.agentEndConversationMessageTag) || (_activity$channelData5 = activity.channelData) !== null && _activity$channelData5 !== void 0 && (_activity$channelData6 = _activity$channelData5.tags) !== null && _activity$channelData6 !== void 0 && _activity$channelData6.includes(_Constants.Constants.supervisorForceCloseMessageTag))) {
33
33
  conversationEndCallback();
34
34
  }
35
+ if ((_activity$channelData7 = activity.channelData) !== null && _activity$channelData7 !== void 0 && (_activity$channelData8 = _activity$channelData7.tags) !== null && _activity$channelData8 !== void 0 && _activity$channelData8.includes(_Constants.Constants.systemMessageTag) && ((_activity$channelData9 = activity.channelData) !== null && _activity$channelData9 !== void 0 && (_activity$channelData10 = _activity$channelData9.tags) !== null && _activity$channelData10 !== void 0 && _activity$channelData10.includes(_Constants.Constants.startConversationalSurveyMessageTag) || (_activity$channelData11 = activity.channelData) !== null && _activity$channelData11 !== void 0 && (_activity$channelData12 = _activity$channelData11.tags) !== null && _activity$channelData12 !== void 0 && _activity$channelData12.includes(_Constants.Constants.startConversationalSurveyMessageTag))) {
36
+ startConversationalSurveyCallback();
37
+ }
38
+ if ((_activity$channelData13 = activity.channelData) !== null && _activity$channelData13 !== void 0 && (_activity$channelData14 = _activity$channelData13.tags) !== null && _activity$channelData14 !== void 0 && _activity$channelData14.includes(_Constants.Constants.systemMessageTag) && (_activity$channelData15 = activity.channelData) !== null && _activity$channelData15 !== void 0 && (_activity$channelData16 = _activity$channelData15.tags) !== null && _activity$channelData16 !== void 0 && _activity$channelData16.includes(_Constants.Constants.endConversationalSurveyMessageTag)) {
39
+ endConversationalSurveyCallback();
40
+ }
35
41
  }
36
- } else if (((_activity$from2 = activity.from) === null || _activity$from2 === void 0 ? void 0 : _activity$from2.role) === _DirectLineSenderRole.DirectLineSenderRole.Channel && ((_activity$channelData7 = activity.channelData) === null || _activity$channelData7 === void 0 ? void 0 : _activity$channelData7.type) === _MessageType.MessageTypes.Thread && (_activity$channelData8 = activity.channelData) !== null && _activity$channelData8 !== void 0 && _activity$channelData8.properties) {
37
- var _activity$channelData9, _activity$channelData10, _activity$channelData11, _activity$channelData12;
42
+ } else if (((_activity$from2 = activity.from) === null || _activity$from2 === void 0 ? void 0 : _activity$from2.role) === _DirectLineSenderRole.DirectLineSenderRole.Channel && ((_activity$channelData17 = activity.channelData) === null || _activity$channelData17 === void 0 ? void 0 : _activity$channelData17.type) === _MessageType.MessageTypes.Thread && (_activity$channelData18 = activity.channelData) !== null && _activity$channelData18 !== void 0 && _activity$channelData18.properties) {
43
+ var _activity$channelData19, _activity$channelData20, _activity$channelData21, _activity$channelData22;
38
44
  // IC3
39
- if (((_activity$channelData9 = activity.channelData) === null || _activity$channelData9 === void 0 ? void 0 : (_activity$channelData10 = _activity$channelData9.properties) === null || _activity$channelData10 === void 0 ? void 0 : _activity$channelData10.isdeleted) === _Constants.Constants.truePascal || !((_activity$channelData11 = activity.channelData) !== null && _activity$channelData11 !== void 0 && (_activity$channelData12 = _activity$channelData11.properties) !== null && _activity$channelData12 !== void 0 && _activity$channelData12.containsExternalEntitiesListeningAll)) {
45
+ if (((_activity$channelData19 = activity.channelData) === null || _activity$channelData19 === void 0 ? void 0 : (_activity$channelData20 = _activity$channelData19.properties) === null || _activity$channelData20 === void 0 ? void 0 : _activity$channelData20.isdeleted) === _Constants.Constants.truePascal || !((_activity$channelData21 = activity.channelData) !== null && _activity$channelData21 !== void 0 && (_activity$channelData22 = _activity$channelData21.properties) !== null && _activity$channelData22 !== void 0 && _activity$channelData22.containsExternalEntitiesListeningAll)) {
40
46
  conversationEndCallback();
41
47
  }
42
48
  }
@@ -52,5 +52,7 @@ exports.LiveChatWidgetActionType = LiveChatWidgetActionType;
52
52
  LiveChatWidgetActionType[LiveChatWidgetActionType["SET_SURVEY_MODE"] = 42] = "SET_SURVEY_MODE";
53
53
  LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CONFIRMATION_STATE"] = 43] = "SET_CONFIRMATION_STATE";
54
54
  LiveChatWidgetActionType[LiveChatWidgetActionType["SET_POST_CHAT_PARTICIPANT_TYPE"] = 44] = "SET_POST_CHAT_PARTICIPANT_TYPE";
55
- LiveChatWidgetActionType[LiveChatWidgetActionType["GET_IN_MEMORY_STATE"] = 45] = "GET_IN_MEMORY_STATE";
55
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CONVERSATIONAL_SURVEY_ENABLED"] = 45] = "SET_CONVERSATIONAL_SURVEY_ENABLED";
56
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CONVERSATIONAL_SURVEY_DISPLAY"] = 46] = "SET_CONVERSATIONAL_SURVEY_DISPLAY";
57
+ LiveChatWidgetActionType[LiveChatWidgetActionType["GET_IN_MEMORY_STATE"] = 47] = "GET_IN_MEMORY_STATE";
56
58
  })(LiveChatWidgetActionType || (exports.LiveChatWidgetActionType = LiveChatWidgetActionType = {}));
@@ -83,7 +83,9 @@ const getLiveChatWidgetContextInitialState = props => {
83
83
  conversationEndedBy: _Constants.ConversationEndEntity.NotSet,
84
84
  chatDisconnectEventReceived: false,
85
85
  selectedSurveyMode: null,
86
- postChatParticipantType: undefined
86
+ postChatParticipantType: undefined,
87
+ isConversationalSurvey: false,
88
+ isConversationalSurveyEnabled: false
87
89
  },
88
90
  uiStates: {
89
91
  showConfirmationPane: false,
@@ -656,6 +656,36 @@ const reducer = (state, action) => {
656
656
  postChatParticipantType: action.payload
657
657
  }
658
658
  };
659
+ case _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATIONAL_SURVEY_ENABLED:
660
+ inMemory = {
661
+ ...inMemory,
662
+ appStates: {
663
+ ...inMemory.appStates,
664
+ isConversationalSurveyEnabled: action.payload
665
+ }
666
+ };
667
+ return {
668
+ ...state,
669
+ appStates: {
670
+ ...state.appStates,
671
+ isConversationalSurveyEnabled: action.payload
672
+ }
673
+ };
674
+ case _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATIONAL_SURVEY_DISPLAY:
675
+ inMemory = {
676
+ ...inMemory,
677
+ appStates: {
678
+ ...inMemory.appStates,
679
+ isConversationalSurvey: action.payload
680
+ }
681
+ };
682
+ return {
683
+ ...state,
684
+ appStates: {
685
+ ...state.appStates,
686
+ isConversationalSurvey: action.payload
687
+ }
688
+ };
659
689
  case _LiveChatWidgetActionType.LiveChatWidgetActionType.GET_IN_MEMORY_STATE:
660
690
  return inMemory;
661
691
  default: