@microsoft/omnichannel-chat-widget 0.1.0-main.52da005 → 0.1.0-main.52fa2fc

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 (105) hide show
  1. package/README.md +7 -34
  2. package/lib/cjs/common/Constants.js +12 -3
  3. package/lib/cjs/common/storage/default/defaultCacheManager.js +2 -2
  4. package/lib/cjs/common/storage/default/defaultClientDataStoreProvider.js +15 -6
  5. package/lib/cjs/common/telemetry/TelemetryConstants.js +35 -4
  6. package/lib/cjs/common/telemetry/TelemetryHelper.js +2 -1
  7. package/lib/cjs/common/utils.js +23 -2
  8. package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +12 -19
  9. package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +1 -1
  10. package/lib/cjs/components/headerstateful/HeaderStateful.js +5 -2
  11. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +139 -0
  12. package/lib/cjs/components/livechatwidget/common/agentEndConversationHelper.js +36 -0
  13. package/lib/cjs/components/livechatwidget/common/createAdapter.js +2 -0
  14. package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +66 -14
  15. package/lib/cjs/components/livechatwidget/common/endChat.js +43 -63
  16. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +11 -49
  17. package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +11 -7
  18. package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +255 -2
  19. package/lib/cjs/components/livechatwidget/common/startChat.js +83 -64
  20. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +91 -45
  21. package/lib/cjs/components/loadingpanestateful/LoadingPaneStateful.js +8 -1
  22. package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +3 -1
  23. package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +1 -1
  24. package/lib/cjs/components/prechatsurveypanestateful/common/defaultStyles/defaultGeneralPreChatSurveyPaneStyleProps.js +1 -1
  25. package/lib/cjs/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +2 -0
  26. package/lib/cjs/components/webchatcontainerstateful/common/utils/FileAttachmentIconManager.js +2 -0
  27. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +1 -3
  28. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +2 -1
  29. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageBoxStyles.js +1 -1
  30. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultUserMessageBoxStyles.js +1 -1
  31. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +2 -14
  32. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +2 -11
  33. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +7 -3
  34. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.js +75 -11
  35. package/lib/cjs/contexts/common/ConversationEndEntity.js +12 -0
  36. package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +11 -7
  37. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +10 -4
  38. package/lib/cjs/contexts/createReducer.js +36 -2
  39. package/lib/cjs/hooks/useDebounce.js +28 -0
  40. package/lib/cjs/hooks/useWindowDimensions.js +30 -0
  41. package/lib/cjs/plugins/newMessageEventHandler.js +14 -0
  42. package/lib/esm/common/Constants.js +10 -2
  43. package/lib/esm/common/storage/default/defaultCacheManager.js +2 -2
  44. package/lib/esm/common/storage/default/defaultClientDataStoreProvider.js +15 -6
  45. package/lib/esm/common/telemetry/TelemetryConstants.js +35 -4
  46. package/lib/esm/common/telemetry/TelemetryHelper.js +2 -1
  47. package/lib/esm/common/utils.js +20 -0
  48. package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +12 -19
  49. package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +1 -1
  50. package/lib/esm/components/headerstateful/HeaderStateful.js +5 -2
  51. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +134 -0
  52. package/lib/esm/components/livechatwidget/common/agentEndConversationHelper.js +30 -0
  53. package/lib/esm/components/livechatwidget/common/createAdapter.js +2 -0
  54. package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +66 -14
  55. package/lib/esm/components/livechatwidget/common/endChat.js +45 -65
  56. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +13 -51
  57. package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +12 -7
  58. package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +255 -3
  59. package/lib/esm/components/livechatwidget/common/startChat.js +83 -64
  60. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +92 -46
  61. package/lib/esm/components/loadingpanestateful/LoadingPaneStateful.js +8 -1
  62. package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +3 -1
  63. package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +1 -1
  64. package/lib/esm/components/prechatsurveypanestateful/common/defaultStyles/defaultGeneralPreChatSurveyPaneStyleProps.js +1 -1
  65. package/lib/esm/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +2 -0
  66. package/lib/esm/components/webchatcontainerstateful/common/utils/FileAttachmentIconManager.js +2 -0
  67. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +1 -3
  68. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +2 -1
  69. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageBoxStyles.js +1 -1
  70. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultUserMessageBoxStyles.js +1 -1
  71. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +2 -14
  72. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +2 -11
  73. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +5 -3
  74. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.js +75 -11
  75. package/lib/esm/contexts/common/ConversationEndEntity.js +5 -0
  76. package/lib/esm/contexts/common/LiveChatWidgetActionType.js +11 -7
  77. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +10 -4
  78. package/lib/esm/contexts/createReducer.js +36 -2
  79. package/lib/esm/hooks/useDebounce.js +22 -0
  80. package/lib/esm/hooks/useWindowDimensions.js +23 -0
  81. package/lib/esm/plugins/newMessageEventHandler.js +14 -0
  82. package/lib/types/common/Constants.d.ts +9 -0
  83. package/lib/types/common/storage/default/defaultCacheManager.d.ts +1 -1
  84. package/lib/types/common/storage/default/defaultClientDataStoreProvider.d.ts +1 -1
  85. package/lib/types/common/telemetry/TelemetryConstants.d.ts +31 -6
  86. package/lib/types/common/telemetry/definitions/Contracts.d.ts +2 -0
  87. package/lib/types/common/telemetry/definitions/Payload.d.ts +1 -0
  88. package/lib/types/common/telemetry/interfaces/ITelemetryConfig.d.ts +4 -0
  89. package/lib/types/common/utils.d.ts +1 -0
  90. package/lib/types/components/confirmationpanestateful/interfaces/IConfirmationPaneStatefulParams.d.ts +0 -7
  91. package/lib/types/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.d.ts +9 -0
  92. package/lib/types/components/livechatwidget/common/agentEndConversationHelper.d.ts +6 -0
  93. package/lib/types/components/livechatwidget/common/initWebChatComposer.d.ts +1 -1
  94. package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +1 -1
  95. package/lib/types/components/livechatwidget/common/setPostChatContextAndLoadSurvey.d.ts +6 -1
  96. package/lib/types/components/livechatwidget/common/startChat.d.ts +3 -3
  97. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetControlProps.d.ts +2 -0
  98. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.d.ts +1 -1
  99. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.d.ts +1 -1
  100. package/lib/types/contexts/common/ConversationEndEntity.d.ts +4 -0
  101. package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +6 -1
  102. package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +11 -7
  103. package/lib/types/hooks/useDebounce.d.ts +3 -0
  104. package/lib/types/hooks/useWindowDimensions.d.ts +4 -0
  105. package/package.json +3 -3
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.handleAgentEndConversation = void 0;
7
+ var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
8
+ var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
9
+ var _ConversationEndEntity = require("../../../contexts/common/ConversationEndEntity");
10
+ var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidgetActionType");
11
+ var _setPostChatContextAndLoadSurvey = require("./setPostChatContextAndLoadSurvey");
12
+ const handleAgentEndConversation = (props, state, dispatch) => {
13
+ const isPostChatEnabled = (0, _setPostChatContextAndLoadSurvey.checkPostChatEnabled)(props, state);
14
+ if (isPostChatEnabled) {
15
+ if (!state.appStates.postChatWorkflowInProgress) {
16
+ dispatch({
17
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY,
18
+ payload: _ConversationEndEntity.ConversationEndEntity.Agent
19
+ });
20
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
21
+ Event: _TelemetryConstants.TelemetryEvent.ConversationEndedByAgent,
22
+ Description: "Conversation is ended from agent side"
23
+ });
24
+ }
25
+ } else {
26
+ dispatch({
27
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY,
28
+ payload: _ConversationEndEntity.ConversationEndEntity.Agent
29
+ });
30
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
31
+ Event: _TelemetryConstants.TelemetryEvent.ConversationEndedByAgent,
32
+ Description: "Conversation is ended from agent side"
33
+ });
34
+ }
35
+ };
36
+ exports.handleAgentEndConversation = handleAgentEndConversation;
@@ -10,6 +10,7 @@ var _NotificationScenarios = require("../../webchatcontainerstateful/webchatcont
10
10
  var _defaultMiddlewareLocalizedTexts = require("../../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts");
11
11
  var _ChatAdapterShim = require("./ChatAdapterShim");
12
12
  var _PauseActivitySubscriber = require("./ActivitySubscriber/PauseActivitySubscriber");
13
+ var _BotAuthActivitySubscriber = require("./ActivitySubscriber/BotAuthActivitySubscriber");
13
14
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
15
  const createAdapter = async chatSDK => {
15
16
  const chatAdapterOptionalParams = {
@@ -34,6 +35,7 @@ const createAdapter = async chatSDK => {
34
35
  if (chatSDK.isMockModeOn !== true) {
35
36
  adapter = new _ChatAdapterShim.ChatAdapterShim(adapter);
36
37
  adapter.addSubscriber(new _PauseActivitySubscriber.PauseActivitySubscriber());
38
+ adapter.addSubscriber(new _BotAuthActivitySubscriber.BotAuthActivitySubscriber());
37
39
  return adapter.chatAdapter;
38
40
  }
39
41
  return adapter;
@@ -13,9 +13,9 @@ var _activityMiddleware = require("../../../webchatcontainerstateful/webchatcont
13
13
  var _attachmentMiddleware = _interopRequireDefault(require("../../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware"));
14
14
  var _avatarMiddleware = require("../../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/avatarMiddleware");
15
15
  var _createMarkdown = require("../createMarkdown");
16
+ var _WebChatLogger = require("../../../webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger");
16
17
  var _groupActivitiesMiddleware = require("../../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/groupActivitiesMiddleware");
17
18
  var _typingIndicatorMiddleware = require("../../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware");
18
- var _WebChatLogger = require("../../../webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger");
19
19
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
20
  /* eslint-disable @typescript-eslint/no-empty-function, @typescript-eslint/no-explicit-any */
21
21
 
@@ -413,6 +413,7 @@ const dummyDefaultProps = {
413
413
  width: "90px",
414
414
  cursor: "pointer",
415
415
  overflow: "hidden",
416
+ padding: "0px",
416
417
  whiteSpace: "nowrap"
417
418
  },
418
419
  subtitleStyleProps: {
@@ -420,12 +421,14 @@ const dummyDefaultProps = {
420
421
  fontWeight: "200",
421
422
  color: "#666",
422
423
  overflow: "hidden",
424
+ padding: "0px",
423
425
  fontFamily: "'Segoe UI',Arial,sans-serif",
424
426
  display: "block",
425
427
  alignItems: "center",
426
428
  margin: "0px 14px 0px 14px",
427
429
  textOverflow: "ellipsis !important",
428
- width: "max-content",
430
+ width: "90px",
431
+ whiteSpace: "nowrap",
429
432
  cursor: "pointer"
430
433
  },
431
434
  classNames: {
@@ -475,7 +478,6 @@ const dummyDefaultProps = {
475
478
  cancelButtonText: "Cancel",
476
479
  cancelButtonAriaLabel: "Cancel. Return to Chat",
477
480
  brightnessValueOnDim: "0.2",
478
- disableDimLayer: false,
479
481
  onConfirm: () => {},
480
482
  // Detailed implementation omitted
481
483
  onCancel: () => {} // Detailed implementation omitted
@@ -483,20 +485,23 @@ const dummyDefaultProps = {
483
485
 
484
486
  styleProps: {
485
487
  generalStyleProps: {
488
+ display: "flex",
489
+ minHeight: "160px",
490
+ maxHeight: "300px",
491
+ boxSizing: "border-box",
486
492
  backgroundColor: "#FFFFFF",
487
493
  borderRadius: "2px",
488
494
  color: "black",
489
495
  fontFamily: "Segoe UI, Arial, sans-serif",
490
496
  fontSize: "14px",
491
- height: "160px",
492
497
  padding: "10px 20px",
493
- width: "262px",
494
498
  position: "absolute",
495
499
  justifyContent: "center",
496
500
  alignItems: "center",
497
- display: "flex",
498
501
  flexFlow: "column",
499
- zIndex: "9999"
502
+ zIndex: "9999",
503
+ left: "26px",
504
+ right: "26px"
500
505
  },
501
506
  titleStyleProps: {
502
507
  color: "#323130",
@@ -518,10 +523,14 @@ const dummyDefaultProps = {
518
523
  },
519
524
  buttonGroupStyleProps: {
520
525
  display: "flex",
526
+ width: "auto",
527
+ height: "auto",
528
+ boxSizing: "border-box",
521
529
  flexFlow: "row",
522
530
  justifyContent: "center",
523
531
  alignItems: "center",
524
- gap: "10px"
532
+ gap: "10px",
533
+ marginBottom: "10px"
525
534
  },
526
535
  confirmButtonStyleProps: {
527
536
  backgroundColor: "rgba(9,72,159,1)",
@@ -576,6 +585,7 @@ const dummyDefaultProps = {
576
585
  hideCallingContainer: false,
577
586
  hideChatButton: false,
578
587
  hideConfirmationPane: false,
588
+ hideErrorUIPane: false,
579
589
  hideFooter: false,
580
590
  hideHeader: false,
581
591
  hideLoadingPane: false,
@@ -626,7 +636,6 @@ const dummyDefaultProps = {
626
636
  cancelButtonText: "Cancel",
627
637
  cancelButtonAriaLabel: "Cancel",
628
638
  brightnessValueOnDim: "0.2",
629
- disableDimLayer: false,
630
639
  onSend: undefined,
631
640
  onCancel: undefined,
632
641
  checkInput: undefined
@@ -1024,7 +1033,8 @@ const dummyDefaultProps = {
1024
1033
  margin: "0px 0px 20px 0px",
1025
1034
  display: "flex",
1026
1035
  order: 1,
1027
- alignSelf: "auto"
1036
+ alignSelf: "auto",
1037
+ overflow: "visible"
1028
1038
  },
1029
1039
  iconImageProps: {
1030
1040
  src: "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDAiIGhlaWdodD0iNDAiIHZpZXdCb3g9IjAgMCA0MCA0MCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCjxnIGZpbHRlcj0idXJsKCNmaWx0ZXIwX2lpKSI+DQo8cGF0aCBkPSJNMTUuMTk3MSAxNi4yNzI1VjI1Ljg1MjRDMTUuMTk3MSAyNy4zODExIDE1Ljg0MDEgMjcuNTIwMSAxNi45ODMyIDI3LjUyMDFMMjYuNzA4NCAyNy41NjQ5TDMxLjAwMzkgMzIuMzEyM1YyNy41NjQ5SDMxLjg5N0MzMi4xNzQzIDI3LjU2MzcgMzIuNDQ4NyAyNy41MDc3IDMyLjcwNDUgMjcuNDAwMUMzMi45NjAzIDI3LjI5MjQgMzMuMTkyNSAyNy4xMzUzIDMzLjM4NzggMjYuOTM3NUMzMy41ODMxIDI2LjczOTggMzMuNzM3NyAyNi41MDU0IDMzLjg0MjcgMjYuMjQ3N0MzMy45NDc4IDI1Ljk5IDM0LjAwMTMgMjUuNzE0IDM0LjAwMDEgMjUuNDM1NVYxNi4zMDM4QzM0LjAwMTMgMTYuMDI1NCAzMy45NDc4IDE1Ljc0OTQgMzMuODQyNyAxNS40OTE3QzMzLjczNzcgMTUuMjM0IDMzLjU4MzEgMTQuOTk5NiAzMy4zODc4IDE0LjgwMThDMzMuMTkyNSAxNC42MDQxIDMyLjk2MDMgMTQuNDQ2OSAzMi43MDQ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9pbm5lclNoYWRvdyIvPg0KPGZlQ29sb3JNYXRyaXggaW49IlNvdXJjZUFscGhhIiB0eXBlPSJtYXRyaXgiIHZhbHVlcz0iMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMTI3IDAiIHJlc3VsdD0iaGFyZEFscGhhIi8+DQo8ZmVPZmZzZXQgZHg9Ii0xIiBkeT0iLTEiLz4NCjxmZUNvbXBvc2l0ZSBpbjI9ImhhcmRBbHBoYSIgb3BlcmF0b3I9ImFyaXRobWV0aWMiIGsyPSItMSIgazM9IjEiLz4NCjxmZUNvbG9yTWF0cml4IHR5cGU9Im1hdHJpeCIgdmFsdWVzPSIwIDAgMCAwIDEgMCAwIDAgMCAxIDAgMCAwIDAgMSAwIDAgMCAwLjE2IDAiLz4NCjxmZUJsZW5kIG1vZGU9Im5vcm1hbCIgaW4yPSJlZmZlY3QyX2lubmVyU2hhZG93IiByZXN1bHQ9ImVmZmVjdDNfaW5uZXJTaGFkb3ciLz4NCjwvZmlsdGVyPg0KPGxpbmVhckdyYWRpZW50IGlkPSJwYWludDBfbGluZWFyIiB4MT0iLTAuMzk1MDAxIiB5MT0iMjMuMTI4MiIgeDI9IjIwLjEwNTgiIHkyPSIzNy44NDc0IiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSI+DQo8c3RvcCBzdG9wLWNvbG9yPSIjRUZFRkVGIi8+DQo8c3RvcCBvZmZzZXQ9IjEiIHN0b3AtY29sb3I9IndoaXRlIi8+DQo8L2xpbmVhckdyYWRpZW50Pg0KPC9kZWZzPg0KPC9zdmc+DQo=",
@@ -1116,7 +1126,8 @@ const dummyDefaultProps = {
1116
1126
  dir: "auto",
1117
1127
  hideOOOHPane: false,
1118
1128
  hideTitle: false,
1119
- titleText: "Thanks for contacting us. You have reached us outside of our operating hours. An agent will respond when we open."
1129
+ titleText: "Thanks for contacting us. You have reached us outside of our operating hours. An agent will respond when we open. Please see link https://microsoft.com",
1130
+ openLinkInNewTab: true
1120
1131
  },
1121
1132
  styleProps: {
1122
1133
  generalStyleProps: {
@@ -1159,7 +1170,7 @@ const dummyDefaultProps = {
1159
1170
  subtitleText: "Please take a moment to give us feedback about your chat experience. We are loading the survey for you now."
1160
1171
  },
1161
1172
  styleProps: {
1162
- // ...[Existing chat button style props]
1173
+ // ...[Existing loading pane style props]
1163
1174
  generalStyleProps: {
1164
1175
  position: "initial",
1165
1176
  width: "100%",
@@ -1190,6 +1201,47 @@ const dummyDefaultProps = {
1190
1201
  },
1191
1202
  isCustomerVoiceSurveyCompact: undefined
1192
1203
  },
1204
+ preChatSurveyPaneProps: {
1205
+ controlProps: {
1206
+ id: "oc-lcw-prechatsurveypane-default",
1207
+ dir: "auto",
1208
+ hidePreChatSurveyPane: false,
1209
+ adaptiveCardHostConfig: "{\"fontFamily\":\"Segoe UI, Helvetica Neue, sans-serif\",\"containerStyles\":{\"default\":{\"foregroundColors\":{\"default\":{\"default\":\"#000000\"}},\"backgroundColor\":\"#FFFFFF\"}},\"actions\":{\"actionsOrientation\":\"Vertical\",\"actionAlignment\":\"stretch\"}}",
1210
+ payload: "{\"$schema\":\"http://adaptivecards.io/schemas/adaptive-card.json\",\"type\":\"AdaptiveCard\",\"version\":\"1.1\",\"body\":[{\"type\":\"TextBlock\",\"weight\":\"bolder\",\"text\":\"Please answer below questions.\"},{\"type\":\"Input.Text\",\"id\":\"1e5e4e7a-8f0b-ec11-b6e6-000d3a305d38\",\"label\":\"name pls?\",\"maxLength\":100,\"isRequired\":true,\"errorMessage\":\"Name is required\"},{\"type\":\"Input.Text\",\"id\":\"7f8f5d6d-995e-ec11-8f8f-000d3a31376e\",\"label\":\"multi\\nmulti\\nmulti\",\"style\":\"text\",\"isMultiline\":true,\"maxLength\":250},{\"type\":\"Input.ChoiceSet\",\"id\":\"e4bdf7cb-995e-ec11-8f8f-000d3a31376e\",\"label\":\"options\",\"isMultiSelect\":false,\"value\":\"1\",\"style\":\"compact\",\"choices\":[{\"title\":\"one\",\"value\":\"1\"},{\"title\":\"two\",\"value\":\"2\"},{\"title\":\"three\",\"value\":\"3\"}]},{\"type\":\"Input.Toggle\",\"id\":\"b26011d2-995e-ec11-8f8f-000d3a31376e\",\"title\":\"consent\",\"valueOn\":\"True\",\"valueOff\":\"False\",\"value\":\"false\"},{\"type\":\"TextBlock\",\"isSubtle\":true,\"text\":\"Fields marked with * are mandatory.\",\"wrap\":true}],\"actions\":[{\"type\":\"Action.Submit\",\"title\":\"Submit\",\"data\":{\"Type\":\"InputSubmit\"}}]}",
1211
+ onSubmit: function () {} // Detailed implementation omitted
1212
+ },
1213
+
1214
+ styleProps: {
1215
+ generalStyleProps: {
1216
+ borderStyle: "solid",
1217
+ borderRadius: "4px",
1218
+ borderWidth: "0px",
1219
+ backgroundColor: "#FFFFFF",
1220
+ borderColor: "#F1F1F1",
1221
+ overflowY: "auto",
1222
+ height: "inherit",
1223
+ width: "inherit"
1224
+ },
1225
+ customButtonStyleProps: {
1226
+ backgroundColor: "rgb(49, 95, 162)",
1227
+ color: "#FFFFFF",
1228
+ fontFamily: "Segoe UI, Arial, sans-serif",
1229
+ fontSize: "15px",
1230
+ height: "48px"
1231
+ },
1232
+ adaptiveCardContainerStyleProps: {
1233
+ border: "1px solid #ECECEC",
1234
+ borderRadius: "4px",
1235
+ margin: "3%"
1236
+ },
1237
+ customTextInputStyleProps: {
1238
+ height: "20px"
1239
+ },
1240
+ customMultilineTextInputStyleProps: {
1241
+ height: "52px"
1242
+ }
1243
+ }
1244
+ },
1193
1245
  proactiveChatPaneProps: {
1194
1246
  componentOverrides: {
1195
1247
  title: undefined,
@@ -1568,10 +1620,10 @@ const dummyDefaultProps = {
1568
1620
  padding: "0px 10px 0 10px"
1569
1621
  },
1570
1622
  userMessageBoxStyles: {
1571
- maxWidth: "75%"
1623
+ maxWidth: "90%"
1572
1624
  },
1573
1625
  systemMessageBoxStyles: {
1574
- maxWidth: "75%"
1626
+ maxWidth: "90%"
1575
1627
  },
1576
1628
  typingIndicatorStyleProps: {
1577
1629
  marginLeft: "10px",
@@ -11,21 +11,17 @@ var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidget
11
11
  var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
12
12
  var _WebChatStoreLoader = require("../../webchatcontainerstateful/webchatcontroller/WebChatStoreLoader");
13
13
  var _defaultWebChatContainerStatefulProps = require("../../webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps");
14
- var _PostChatSurveyMode = require("../../postchatsurveypanestateful/enums/PostChatSurveyMode");
15
- var _Constants = require("../../../common/Constants");
16
14
  var _utils = require("../../../common/utils");
17
15
  var _authHelper = require("./authHelper");
16
+ var _setPostChatContextAndLoadSurvey = require("./setPostChatContextAndLoadSurvey");
17
+ var _ConversationEndEntity = require("../../../contexts/common/ConversationEndEntity");
18
18
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
19
19
  const prepareEndChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state) => {
20
- var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _state$domainStates$l4, _conversationDetails;
21
- const isPostChatEnabled = (_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : (_state$domainStates$l2 = _state$domainStates$l.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.msdyn_postconversationsurveyenable;
22
- const postChatSurveyMode = (_state$domainStates$l3 = state.domainStates.liveChatConfig) === null || _state$domainStates$l3 === void 0 ? void 0 : (_state$domainStates$l4 = _state$domainStates$l3.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l4 === void 0 ? void 0 : _state$domainStates$l4.msdyn_postconversationsurveymode;
23
-
24
20
  //Unable to end chat if token has expired
25
21
  if (props.getAuthToken) {
26
22
  const authClientFunction = (0, _authHelper.getAuthClientFunction)(props.chatConfig);
27
23
  if (props.getAuthToken && authClientFunction) {
28
- // set auth token to chat sdk before start chat
24
+ // set auth token to chat sdk before end chat
29
25
  const authSuccess = await (0, _authHelper.handleAuthentication)(chatSDK, props.chatConfig, props.getAuthToken);
30
26
  if (!authSuccess) {
31
27
  _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
@@ -37,60 +33,28 @@ const prepareEndChat = async (props, chatSDK, setAdapter, setWebChatStyles, disp
37
33
  }
38
34
  }
39
35
  }
40
-
41
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
42
- let conversationDetails = undefined;
43
- try {
44
- conversationDetails = await chatSDK.getConversationDetails();
45
- } catch (erorr) {
46
- _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
47
- Event: _TelemetryConstants.TelemetryEvent.GetConversationDetailsException,
48
- ExceptionDetails: {
49
- exception: `Failed to get conversation details: ${erorr}`
50
- }
51
- });
52
- }
53
- if (isPostChatEnabled === "true" && ((_conversationDetails = conversationDetails) === null || _conversationDetails === void 0 ? void 0 : _conversationDetails.canRenderPostChat) === _Constants.Constants.truePascal) {
54
- const skipEndChatSDK = false;
55
- const skipCloseChat = true;
56
- const chatSession = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getCurrentLiveChatContext());
57
- await endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat, false);
58
- if (chatSession) {
59
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
60
- chatSDK.chatToken = chatSession.chatToken ?? {};
61
- chatSDK.requestId = chatSession.requestId;
36
+ const isPostChatEnabled = (0, _setPostChatContextAndLoadSurvey.checkPostChatEnabled)(props, state);
37
+ if (isPostChatEnabled) {
38
+ try {
39
+ await (0, _setPostChatContextAndLoadSurvey.initiatePostChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state);
40
+ } catch (error) {
41
+ // Ending chat because something went wrong
42
+ await endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, true);
62
43
  }
63
- if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Embed) {
44
+ } else {
45
+ if (state.appStates.conversationEndedBy === _ConversationEndEntity.ConversationEndEntity.Agent) {
64
46
  dispatch({
65
- type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
66
- payload: _ConversationState.ConversationState.PostchatLoading
67
- });
68
- await (0, _utils.addDelayInMs)(_Constants.Constants.PostChatLoadingDurationInMs);
69
- const loadPostChatEvent = {
70
- eventName: _TelemetryConstants.BroadcastEvent.LoadPostChatSurvey
71
- };
72
- _omnichannelChatComponents.BroadcastService.postMessage(loadPostChatEvent);
73
- } else if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Link) {
74
- var _props$webChatContain, _props$webChatContain2;
47
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CHAT_TOKEN,
48
+ payload: undefined
49
+ });
75
50
  dispatch({
76
- type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
77
- payload: _ConversationState.ConversationState.InActive
51
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
52
+ payload: undefined
78
53
  });
79
-
80
- // Disable SendBox
81
- if ((props === null || props === void 0 ? void 0 : (_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : (_props$webChatContain2 = _props$webChatContain.renderingMiddlewareProps) === null || _props$webChatContain2 === void 0 ? void 0 : _props$webChatContain2.hideSendboxOnConversationEnd) !== false) {
82
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
83
- setWebChatStyles(styles => {
84
- return {
85
- ...styles,
86
- hideSendBox: true
87
- };
88
- });
89
- }
54
+ } else {
55
+ await endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, true);
90
56
  }
91
- return;
92
57
  }
93
- await endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, true);
94
58
  };
95
59
 
96
60
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -112,7 +76,6 @@ const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, a
112
76
  postMessageToOtherTab = false;
113
77
  }
114
78
  }
115
-
116
79
  // Need to clear these states immediately when chat ended from OC.
117
80
  dispatch({
118
81
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CUSTOM_CONTEXT,
@@ -132,12 +95,12 @@ const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, a
132
95
  });
133
96
  if (!skipCloseChat) {
134
97
  try {
135
- var _props$webChatContain3;
98
+ var _props$webChatContain;
136
99
  adapter === null || adapter === void 0 ? void 0 : adapter.end();
137
100
  setAdapter(undefined);
138
101
  setWebChatStyles({
139
102
  ..._defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.webChatStyles,
140
- ...((_props$webChatContain3 = props.webChatContainerProps) === null || _props$webChatContain3 === void 0 ? void 0 : _props$webChatContain3.webChatStyles)
103
+ ...((_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : _props$webChatContain.webChatStyles)
141
104
  });
142
105
  _WebChatStoreLoader.WebChatStoreLoader.store = null;
143
106
  dispatch({
@@ -145,9 +108,21 @@ const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, a
145
108
  payload: _ConversationState.ConversationState.Closed
146
109
  });
147
110
  dispatch({
148
- type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY_AGENT,
111
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_POST_CHAT_WORKFLOW_IN_PROGRESS,
149
112
  payload: false
150
113
  });
114
+ dispatch({
115
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_SHOULD_USE_BOT_SURVEY,
116
+ payload: false
117
+ });
118
+ dispatch({
119
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY_AGENT_EVENT_RECEIVED,
120
+ payload: false
121
+ });
122
+ dispatch({
123
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY,
124
+ payload: undefined
125
+ });
151
126
  dispatch({
152
127
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_RECONNECT_ID,
153
128
  payload: undefined
@@ -156,10 +131,6 @@ const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, a
156
131
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_AUDIO_NOTIFICATION,
157
132
  payload: null
158
133
  });
159
- dispatch({
160
- type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_UNREAD_MESSAGE_COUNT,
161
- payload: 0
162
- });
163
134
  dispatch({
164
135
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_PROACTIVE_CHAT_PARAMS,
165
136
  payload: {
@@ -175,6 +146,10 @@ const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, a
175
146
  eventName: endChatEventName
176
147
  });
177
148
  }
149
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
150
+ Event: _TelemetryConstants.TelemetryEvent.CloseChatCall,
151
+ Description: "Chat was closed succesfully"
152
+ });
178
153
  } catch (error) {
179
154
  _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
180
155
  Event: _TelemetryConstants.TelemetryEvent.CloseChatMethodException,
@@ -182,6 +157,11 @@ const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, a
182
157
  exception: `Failed to endChat: ${error}`
183
158
  }
184
159
  });
160
+ } finally {
161
+ dispatch({
162
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_UNREAD_MESSAGE_COUNT,
163
+ payload: 0
164
+ });
185
165
  }
186
166
  }
187
167
  };
@@ -6,10 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.initWebChatComposer = void 0;
7
7
  var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
8
8
  var _botframeworkWebchat = require("botframework-webchat");
9
- var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
10
- var _ConversationState = require("../../../contexts/common/ConversationState");
11
9
  var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidgetActionType");
12
- var _PostChatSurveyMode = require("../../postchatsurveypanestateful/enums/PostChatSurveyMode");
13
10
  var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
14
11
  var _WebChatStoreLoader = require("../../webchatcontainerstateful/webchatcontroller/WebChatStoreLoader");
15
12
  var _attachmentProcessingMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentProcessingMiddleware"));
@@ -35,11 +32,10 @@ var _preProcessingMiddleware = _interopRequireDefault(require("../../webchatcont
35
32
  var _sanitizationMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware"));
36
33
  var _cardActionMiddleware = require("../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware");
37
34
  var _messageTimestampMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware"));
38
- var _Constants = require("../../../common/Constants");
39
35
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
40
36
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
41
- const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatStyles) => {
42
- var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _state$domainStates$l4, _state$domainStates$l8, _state$domainStates$l9, _props$webChatContain7, _props$webChatContain8, _state$domainStates$r, _state$domainStates$r2, _props$webChatContain9, _props$webChatContain10, _state$domainStates$r3, _state$domainStates$r4, _props$webChatContain11, _props$webChatContain12, _defaultWebChatContai, _props$webChatContain13, _props$webChatContain14, _props$webChatContain15, _props$webChatContain16, _state$domainStates$r5, _state$domainStates$r6, _props$webChatContain17, _props$webChatContain18, _defaultWebChatContai2, _props$webChatContain19, _props$webChatContain20, _defaultWebChatContai3, _props$webChatContain21, _props$webChatContain22;
37
+ const initWebChatComposer = (props, chatSDK, setAdapter, state, dispatch, adapter, setWebChatStyles) => {
38
+ var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _state$domainStates$l4, _state$domainStates$l5, _props$webChatContain7, _props$webChatContain8, _state$domainStates$r, _state$domainStates$r2, _props$webChatContain9, _props$webChatContain10, _state$domainStates$r3, _state$domainStates$r4, _props$webChatContain11, _props$webChatContain12, _defaultWebChatContai, _props$webChatContain13, _props$webChatContain14, _props$webChatContain15, _props$webChatContain16, _state$domainStates$r5, _state$domainStates$r6, _props$webChatContain17, _props$webChatContain18, _defaultWebChatContai2, _props$webChatContain19, _props$webChatContain20, _defaultWebChatContai3, _props$webChatContain21, _props$webChatContain22;
43
39
  const localizedTexts = {
44
40
  ..._defaultMiddlewareLocalizedTexts.defaultMiddlewareLocalizedTexts,
45
41
  ...((_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : _props$webChatContain.localizedTexts)
@@ -47,19 +43,12 @@ const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatStyles)
47
43
  const disableNewLineMarkdownSupport = ((_props$webChatContain2 = props.webChatContainerProps) === null || _props$webChatContain2 === void 0 ? void 0 : _props$webChatContain2.disableNewLineMarkdownSupport) ?? _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.disableNewLineMarkdownSupport;
48
44
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
49
45
  const markdown = (0, _createMarkdown.createMarkdown)(((_props$webChatContain3 = props.webChatContainerProps) === null || _props$webChatContain3 === void 0 ? void 0 : _props$webChatContain3.disableMarkdownMessageFormatting) ?? _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.disableMarkdownMessageFormatting, disableNewLineMarkdownSupport);
50
- const isPostChatEnabled = (_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : (_state$domainStates$l2 = _state$domainStates$l.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.msdyn_postconversationsurveyenable;
51
- const postChatSurveyMode = (_state$domainStates$l3 = state.domainStates.liveChatConfig) === null || _state$domainStates$l3 === void 0 ? void 0 : (_state$domainStates$l4 = _state$domainStates$l3.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l4 === void 0 ? void 0 : _state$domainStates$l4.msdyn_postconversationsurveymode;
52
-
53
46
  // Initialize Web Chat's redux store
54
47
  let webChatStore = _WebChatStoreLoader.WebChatStoreLoader.store;
55
48
  if (!webChatStore) {
56
- var _state$domainStates$l5, _state$domainStates$l6, _state$domainStates$l7, _props$webChatContain6;
49
+ var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _props$webChatContain6;
57
50
  const conversationEndCallback = async () => {
58
51
  var _props$webChatContain4, _props$webChatContain5;
59
- _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
60
- Event: _TelemetryConstants.TelemetryEvent.ConversationEndedThreadEventReceived,
61
- Description: "Conversation is ended by agent side or by timeout."
62
- });
63
52
  if ((props === null || props === void 0 ? void 0 : (_props$webChatContain4 = props.webChatContainerProps) === null || _props$webChatContain4 === void 0 ? void 0 : (_props$webChatContain5 = _props$webChatContain4.renderingMiddlewareProps) === null || _props$webChatContain5 === void 0 ? void 0 : _props$webChatContain5.hideSendboxOnConversationEnd) !== false) {
64
53
  setWebChatStyles(styles => {
65
54
  return {
@@ -68,46 +57,18 @@ const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatStyles)
68
57
  };
69
58
  });
70
59
  }
71
- if (isPostChatEnabled === "true") {
72
- if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Embed) {
73
- _WebChatStoreLoader.WebChatStoreLoader.store = null;
74
- dispatch({
75
- type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
76
- payload: _ConversationState.ConversationState.PostchatLoading
77
- });
78
- await (0, _utils.addDelayInMs)(_Constants.Constants.PostChatLoadingDurationInMs);
79
- const loadPostChatEvent = {
80
- eventName: _TelemetryConstants.BroadcastEvent.LoadPostChatSurvey
81
- };
82
- _omnichannelChatComponents.BroadcastService.postMessage(loadPostChatEvent);
83
- } else if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Link) {
84
- dispatch({
85
- type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
86
- payload: _ConversationState.ConversationState.InActive
87
- });
88
- }
89
- } else {
90
- dispatch({
91
- type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
92
- payload: _ConversationState.ConversationState.InActive
93
- });
94
- dispatch({
95
- type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY_AGENT,
96
- payload: true
97
- });
98
- }
99
60
  dispatch({
100
- type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CHAT_TOKEN,
101
- payload: undefined
61
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY_AGENT_EVENT_RECEIVED,
62
+ payload: true
102
63
  });
103
- dispatch({
104
- type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
105
- payload: undefined
64
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
65
+ Event: _TelemetryConstants.TelemetryEvent.ConversationEndedThreadEventReceived,
66
+ Description: "Conversation end by agent side or by timeout event received."
106
67
  });
107
68
  };
108
69
  webChatStore = (0, _botframeworkWebchat.createStore)({},
109
70
  //initial state
110
- _preProcessingMiddleware.default, _attachmentProcessingMiddleware.default, (0, _attachmentUploadValidatorMiddleware.default)((_state$domainStates$l5 = state.domainStates.liveChatConfig) === null || _state$domainStates$l5 === void 0 ? void 0 : _state$domainStates$l5.allowedFileExtensions, (_state$domainStates$l6 = state.domainStates.liveChatConfig) === null || _state$domainStates$l6 === void 0 ? void 0 : _state$domainStates$l6.maxUploadFileSize, localizedTexts), _channelDataMiddleware.default, (0, _conversationEndMiddleware.default)(conversationEndCallback), (0, _dataMaskingMiddleware.default)((_state$domainStates$l7 = state.domainStates.liveChatConfig) === null || _state$domainStates$l7 === void 0 ? void 0 : _state$domainStates$l7.DataMaskingInfo), _messageTimestampMiddleware.default, _gifUploadMiddleware.default, _htmlPlayerMiddleware.default, _htmlTextMiddleware.default, (0, _maxMessageSizeValidator.default)(localizedTexts), _sanitizationMiddleware.default,
71
+ _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.default, _gifUploadMiddleware.default, _htmlPlayerMiddleware.default, _htmlTextMiddleware.default, (0, _maxMessageSizeValidator.default)(localizedTexts), _sanitizationMiddleware.default,
111
72
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
112
73
  ...(((_props$webChatContain6 = props.webChatContainerProps) === null || _props$webChatContain6 === void 0 ? void 0 : _props$webChatContain6.storeMiddlewares) ?? []));
113
74
  _WebChatStoreLoader.WebChatStoreLoader.store = webChatStore;
@@ -117,7 +78,7 @@ const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatStyles)
117
78
  const webChatProps = {
118
79
  ..._defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.webChatProps,
119
80
  dir: state.domainStates.globalDir,
120
- locale: (0, _utils.changeLanguageCodeFormatForWebChat)((0, _omnichannelChatSdk.getLocaleStringFromId)((_state$domainStates$l8 = state.domainStates.liveChatConfig) === null || _state$domainStates$l8 === void 0 ? void 0 : (_state$domainStates$l9 = _state$domainStates$l8.ChatWidgetLanguage) === null || _state$domainStates$l9 === void 0 ? void 0 : _state$domainStates$l9.msdyn_localeid)),
81
+ locale: (0, _utils.changeLanguageCodeFormatForWebChat)((0, _omnichannelChatSdk.getLocaleStringFromId)((_state$domainStates$l4 = state.domainStates.liveChatConfig) === null || _state$domainStates$l4 === void 0 ? void 0 : (_state$domainStates$l5 = _state$domainStates$l4.ChatWidgetLanguage) === null || _state$domainStates$l5 === void 0 ? void 0 : _state$domainStates$l5.msdyn_localeid)),
121
82
  store: webChatStore,
122
83
  activityMiddleware: (_props$webChatContain7 = props.webChatContainerProps) !== null && _props$webChatContain7 !== void 0 && (_props$webChatContain8 = _props$webChatContain7.renderingMiddlewareProps) !== null && _props$webChatContain8 !== void 0 && _props$webChatContain8.disableActivityMiddleware ? undefined : (0, _activityMiddleware.createActivityMiddleware)((_state$domainStates$r = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r === void 0 ? void 0 : _state$domainStates$r.systemMessageStyleProps, (_state$domainStates$r2 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r2 === void 0 ? void 0 : _state$domainStates$r2.userMessageStyleProps),
123
84
  attachmentMiddleware: (_props$webChatContain9 = props.webChatContainerProps) !== null && _props$webChatContain9 !== void 0 && (_props$webChatContain10 = _props$webChatContain9.renderingMiddlewareProps) !== null && _props$webChatContain10 !== void 0 && _props$webChatContain10.disableAttachmentMiddleware ? undefined : (0, _attachmentMiddleware.default)(((_state$domainStates$r3 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r3 === void 0 ? void 0 : (_state$domainStates$r4 = _state$domainStates$r3.attachmentProps) === null || _state$domainStates$r4 === void 0 ? void 0 : _state$domainStates$r4.enableInlinePlaying) ?? _defaultAttachmentProps.defaultAttachmentProps.enableInlinePlaying),
@@ -128,6 +89,7 @@ const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatStyles)
128
89
  typingIndicatorMiddleware: (_props$webChatContain19 = props.webChatContainerProps) !== null && _props$webChatContain19 !== void 0 && (_props$webChatContain20 = _props$webChatContain19.renderingMiddlewareProps) !== null && _props$webChatContain20 !== void 0 && _props$webChatContain20.disableTypingIndicatorMiddleware ? undefined : (_defaultWebChatContai3 = _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai3 === void 0 ? void 0 : _defaultWebChatContai3.typingIndicatorMiddleware,
129
90
  onTelemetry: (0, _WebChatLogger.createWebChatTelemetry)(),
130
91
  cardActionMiddleware: (0, _cardActionMiddleware.createCardActionMiddleware)(((_props$webChatContain21 = props.webChatContainerProps) === null || _props$webChatContain21 === void 0 ? void 0 : _props$webChatContain21.botMagicCode) || undefined),
92
+ sendTypingIndicator: true,
131
93
  ...((_props$webChatContain22 = props.webChatContainerProps) === null || _props$webChatContain22 === void 0 ? void 0 : _props$webChatContain22.webChatProps)
132
94
  };
133
95
  return webChatProps;
@@ -6,12 +6,12 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.isReconnectEnabled = exports.handleChatReconnect = exports.getChatReconnectContext = void 0;
7
7
  require("regenerator-runtime/runtime");
8
8
  var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
9
+ var _authHelper = require("./authHelper");
10
+ var _utils = require("../../../common/utils");
9
11
  var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
10
12
  var _ConversationState = require("../../../contexts/common/ConversationState");
11
13
  var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidgetActionType");
12
14
  var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
13
- var _authHelper = require("./authHelper");
14
- var _utils = require("../../../common/utils");
15
15
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
16
  const handleChatReconnect = async (chatSDK, props, dispatch, setAdapter, initStartChat, state) => {
17
17
  var _props$chatConfig, _props$chatConfig$Liv;
@@ -60,14 +60,14 @@ const getChatReconnectContext = async (chatSDK, chatConfig, props, isAuthenticat
60
60
  const chatReconnectOptionalParams = {
61
61
  reconnectId: (_props$reconnectChatP4 = props.reconnectChatPaneProps) === null || _props$reconnectChatP4 === void 0 ? void 0 : _props$reconnectChatP4.reconnectId
62
62
  };
63
+ // Get auth token for getting chat reconnect context
63
64
  if (isAuthenticatedChat) {
64
- // Get auth token for for getting chat reconnect context
65
65
  await (0, _authHelper.handleAuthentication)(chatSDK, chatConfig, props.getAuthToken);
66
66
  }
67
67
  const reconnectChatContext = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getChatReconnectContext(chatReconnectOptionalParams));
68
68
  if (isAuthenticatedChat) {
69
69
  // remove auth token after reconnectId is fetched
70
- // this will be reset later at start chat
70
+ // AuthToken will be reset later at start chat
71
71
  (0, _authHelper.removeAuthTokenProvider)(chatSDK);
72
72
  }
73
73
  return reconnectChatContext;
@@ -101,7 +101,7 @@ const setReconnectIdAndStartChat = async (isAuthenticatedChat, chatSDK, props, d
101
101
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
102
102
  payload: _ConversationState.ConversationState.Loading
103
103
  });
104
- await initStartChat(chatSDK, props.chatConfig, props.getAuthToken, dispatch, setAdapter, optionalParams);
104
+ await initStartChat(chatSDK, dispatch, setAdapter, props, optionalParams);
105
105
  };
106
106
  const redirectPage = (redirectURL, redirectInSameWindow) => {
107
107
  const redirectPageRequest = {
@@ -116,8 +116,12 @@ const redirectPage = (redirectURL, redirectInSameWindow) => {
116
116
  }
117
117
  };
118
118
  const isReconnectEnabled = chatConfig => {
119
- var _chatConfig$LiveWSAnd;
120
- return chatConfig && ((_chatConfig$LiveWSAnd = chatConfig.LiveWSAndLiveChatEngJoin) === null || _chatConfig$LiveWSAnd === void 0 ? void 0 : _chatConfig$LiveWSAnd.msdyn_enablechatreconnect) && (chatConfig.LiveWSAndLiveChatEngJoin.msdyn_enablechatreconnect === "true" || chatConfig.LiveWSAndLiveChatEngJoin.msdyn_enablechatreconnect === true);
119
+ if (chatConfig) {
120
+ var _chatConfig$LiveWSAnd, _chatConfig$LiveWSAnd2;
121
+ const reconnectEnabled = ((_chatConfig$LiveWSAnd = chatConfig.LiveWSAndLiveChatEngJoin) === null || _chatConfig$LiveWSAnd === void 0 ? void 0 : (_chatConfig$LiveWSAnd2 = _chatConfig$LiveWSAnd.msdyn_enablechatreconnect) === null || _chatConfig$LiveWSAnd2 === void 0 ? void 0 : _chatConfig$LiveWSAnd2.toLowerCase()) === "true";
122
+ return reconnectEnabled;
123
+ }
124
+ return false;
121
125
  };
122
126
  exports.isReconnectEnabled = isReconnectEnabled;
123
127
  const hasReconnectId = reconnectAvailabilityResponse => {