@microsoft/omnichannel-chat-widget 0.1.0-main.170e416 → 0.1.0-main.18d1166

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 (131) hide show
  1. package/README.md +7 -34
  2. package/lib/cjs/assets/Icons.js +4 -2
  3. package/lib/cjs/common/Constants.js +9 -3
  4. package/lib/cjs/common/KeyCodes.js +3 -1
  5. package/lib/cjs/common/contextDataStore/DataStoreManager.js +3 -1
  6. package/lib/cjs/common/storage/default/defaultCacheManager.js +5 -3
  7. package/lib/cjs/common/storage/default/defaultClientDataStoreProvider.js +15 -6
  8. package/lib/cjs/common/telemetry/TelemetryConstants.js +34 -4
  9. package/lib/cjs/common/telemetry/TelemetryHelper.js +5 -2
  10. package/lib/cjs/common/telemetry/TelemetryManager.js +3 -1
  11. package/lib/cjs/common/utils.js +23 -2
  12. package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +12 -19
  13. package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +1 -1
  14. package/lib/cjs/components/headerstateful/HeaderStateful.js +7 -4
  15. package/lib/cjs/components/livechatwidget/common/ActivityStreamHandler.js +3 -1
  16. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +139 -0
  17. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +3 -1
  18. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +3 -1
  19. package/lib/cjs/components/livechatwidget/common/ChatAdapterShim.js +3 -1
  20. package/lib/cjs/components/livechatwidget/common/Deferred.js +3 -1
  21. package/lib/cjs/components/livechatwidget/common/agentEndConversationHelper.js +36 -0
  22. package/lib/cjs/components/livechatwidget/common/createAdapter.js +2 -0
  23. package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +66 -14
  24. package/lib/cjs/components/livechatwidget/common/endChat.js +41 -49
  25. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +11 -49
  26. package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +6 -9
  27. package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +254 -2
  28. package/lib/cjs/components/livechatwidget/common/startChat.js +76 -53
  29. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +82 -44
  30. package/lib/cjs/components/loadingpanestateful/LoadingPaneStateful.js +22 -2
  31. package/lib/cjs/components/loadingpanestateful/common/errorUIStyleProps/errorUILoadingPaneStyleProps.js +57 -0
  32. package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +3 -1
  33. package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +1 -1
  34. package/lib/cjs/components/prechatsurveypanestateful/common/defaultStyles/defaultGeneralPreChatSurveyPaneStyleProps.js +1 -1
  35. package/lib/cjs/components/webchatcontainerstateful/common/mockadapter.js +3 -1
  36. package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +3 -1
  37. package/lib/cjs/components/webchatcontainerstateful/common/utils/FileAttachmentIconManager.js +2 -0
  38. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +3 -1
  39. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/WebChatStoreLoader.js +3 -1
  40. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +1 -3
  41. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +2 -1
  42. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageBoxStyles.js +1 -1
  43. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultUserMessageBoxStyles.js +1 -1
  44. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +5 -6
  45. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +2 -14
  46. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +2 -11
  47. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +7 -3
  48. package/lib/cjs/contexts/common/ConversationEndEntity.js +12 -0
  49. package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +32 -28
  50. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +9 -3
  51. package/lib/cjs/contexts/createReducer.js +36 -2
  52. package/lib/cjs/hooks/useDebounce.js +28 -0
  53. package/lib/cjs/hooks/useWindowDimensions.js +30 -0
  54. package/lib/cjs/plugins/newMessageEventHandler.js +14 -0
  55. package/lib/esm/assets/Icons.js +2 -1
  56. package/lib/esm/common/Constants.js +9 -3
  57. package/lib/esm/common/KeyCodes.js +3 -1
  58. package/lib/esm/common/contextDataStore/DataStoreManager.js +3 -1
  59. package/lib/esm/common/storage/default/defaultCacheManager.js +5 -3
  60. package/lib/esm/common/storage/default/defaultClientDataStoreProvider.js +15 -6
  61. package/lib/esm/common/telemetry/TelemetryConstants.js +34 -4
  62. package/lib/esm/common/telemetry/TelemetryHelper.js +5 -2
  63. package/lib/esm/common/telemetry/TelemetryManager.js +3 -1
  64. package/lib/esm/common/utils.js +20 -0
  65. package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +12 -19
  66. package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +1 -1
  67. package/lib/esm/components/headerstateful/HeaderStateful.js +7 -4
  68. package/lib/esm/components/livechatwidget/common/ActivityStreamHandler.js +3 -1
  69. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +134 -0
  70. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +3 -1
  71. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +3 -1
  72. package/lib/esm/components/livechatwidget/common/ChatAdapterShim.js +3 -1
  73. package/lib/esm/components/livechatwidget/common/Deferred.js +3 -1
  74. package/lib/esm/components/livechatwidget/common/agentEndConversationHelper.js +30 -0
  75. package/lib/esm/components/livechatwidget/common/createAdapter.js +2 -0
  76. package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +66 -14
  77. package/lib/esm/components/livechatwidget/common/endChat.js +43 -51
  78. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +13 -51
  79. package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +7 -9
  80. package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +254 -3
  81. package/lib/esm/components/livechatwidget/common/startChat.js +76 -53
  82. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +83 -45
  83. package/lib/esm/components/loadingpanestateful/LoadingPaneStateful.js +22 -2
  84. package/lib/esm/components/loadingpanestateful/common/errorUIStyleProps/errorUILoadingPaneStyleProps.js +50 -0
  85. package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +3 -1
  86. package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +1 -1
  87. package/lib/esm/components/prechatsurveypanestateful/common/defaultStyles/defaultGeneralPreChatSurveyPaneStyleProps.js +1 -1
  88. package/lib/esm/components/webchatcontainerstateful/common/mockadapter.js +3 -1
  89. package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +3 -1
  90. package/lib/esm/components/webchatcontainerstateful/common/utils/FileAttachmentIconManager.js +2 -0
  91. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +3 -1
  92. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/WebChatStoreLoader.js +3 -1
  93. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +1 -3
  94. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +2 -1
  95. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageBoxStyles.js +1 -1
  96. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultUserMessageBoxStyles.js +1 -1
  97. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +5 -6
  98. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +2 -14
  99. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +2 -11
  100. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +5 -3
  101. package/lib/esm/contexts/common/ConversationEndEntity.js +5 -0
  102. package/lib/esm/contexts/common/LiveChatWidgetActionType.js +32 -28
  103. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +9 -3
  104. package/lib/esm/contexts/createReducer.js +36 -2
  105. package/lib/esm/hooks/useDebounce.js +22 -0
  106. package/lib/esm/hooks/useWindowDimensions.js +23 -0
  107. package/lib/esm/plugins/newMessageEventHandler.js +14 -0
  108. package/lib/types/assets/Icons.d.ts +1 -0
  109. package/lib/types/common/Constants.d.ts +4 -0
  110. package/lib/types/common/storage/default/defaultCacheManager.d.ts +1 -1
  111. package/lib/types/common/storage/default/defaultClientDataStoreProvider.d.ts +1 -1
  112. package/lib/types/common/telemetry/TelemetryConstants.d.ts +30 -6
  113. package/lib/types/common/telemetry/definitions/Contracts.d.ts +2 -0
  114. package/lib/types/common/telemetry/definitions/Payload.d.ts +1 -0
  115. package/lib/types/common/telemetry/interfaces/ITelemetryConfig.d.ts +4 -0
  116. package/lib/types/common/utils.d.ts +1 -0
  117. package/lib/types/components/confirmationpanestateful/interfaces/IConfirmationPaneStatefulParams.d.ts +0 -7
  118. package/lib/types/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.d.ts +9 -0
  119. package/lib/types/components/livechatwidget/common/agentEndConversationHelper.d.ts +6 -0
  120. package/lib/types/components/livechatwidget/common/initWebChatComposer.d.ts +1 -1
  121. package/lib/types/components/livechatwidget/common/setPostChatContextAndLoadSurvey.d.ts +6 -1
  122. package/lib/types/components/livechatwidget/common/startChat.d.ts +3 -3
  123. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetControlProps.d.ts +2 -0
  124. package/lib/types/components/loadingpanestateful/common/errorUIStyleProps/errorUILoadingPaneStyleProps.d.ts +2 -0
  125. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.d.ts +1 -1
  126. package/lib/types/contexts/common/ConversationEndEntity.d.ts +4 -0
  127. package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +6 -1
  128. package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +32 -28
  129. package/lib/types/hooks/useDebounce.d.ts +3 -0
  130. package/lib/types/hooks/useWindowDimensions.d.ts +4 -0
  131. package/package.json +3 -3
@@ -1,13 +1,10 @@
1
- import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
1
+ import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
2
2
  import { createStore } from "botframework-webchat";
3
- import { BroadcastService } from "@microsoft/omnichannel-chat-components";
4
- import { ConversationState } from "../../../contexts/common/ConversationState";
5
3
  import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
6
- import { PostChatSurveyMode } from "../../postchatsurveypanestateful/enums/PostChatSurveyMode";
7
4
  import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
8
5
  import { WebChatStoreLoader } from "../../webchatcontainerstateful/webchatcontroller/WebChatStoreLoader";
9
6
  import attachmentProcessingMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentProcessingMiddleware";
10
- import { addDelayInMs, changeLanguageCodeFormatForWebChat } from "../../../common/utils";
7
+ import { changeLanguageCodeFormatForWebChat } from "../../../common/utils";
11
8
  import channelDataMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware";
12
9
  import { createActivityMiddleware } from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware";
13
10
  import createAttachmentMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware";
@@ -29,11 +26,10 @@ import preProcessingMiddleware from "../../webchatcontainerstateful/webchatcontr
29
26
  import sanitizationMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware";
30
27
  import { createCardActionMiddleware } from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware";
31
28
  import createMessageTimeStampMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware";
32
- import { Constants } from "../../../common/Constants";
33
29
 
34
30
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
35
- export const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatStyles) => {
36
- 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;
31
+ export const initWebChatComposer = (props, chatSDK, setAdapter, state, dispatch, adapter, setWebChatStyles) => {
32
+ 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;
37
33
  const localizedTexts = {
38
34
  ...defaultMiddlewareLocalizedTexts,
39
35
  ...((_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : _props$webChatContain.localizedTexts)
@@ -41,19 +37,12 @@ export const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatS
41
37
  const disableNewLineMarkdownSupport = ((_props$webChatContain2 = props.webChatContainerProps) === null || _props$webChatContain2 === void 0 ? void 0 : _props$webChatContain2.disableNewLineMarkdownSupport) ?? defaultWebChatContainerStatefulProps.disableNewLineMarkdownSupport;
42
38
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
43
39
  const markdown = createMarkdown(((_props$webChatContain3 = props.webChatContainerProps) === null || _props$webChatContain3 === void 0 ? void 0 : _props$webChatContain3.disableMarkdownMessageFormatting) ?? defaultWebChatContainerStatefulProps.disableMarkdownMessageFormatting, disableNewLineMarkdownSupport);
44
- 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;
45
- 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;
46
-
47
40
  // Initialize Web Chat's redux store
48
41
  let webChatStore = WebChatStoreLoader.store;
49
42
  if (!webChatStore) {
50
- var _state$domainStates$l5, _state$domainStates$l6, _state$domainStates$l7, _props$webChatContain6;
43
+ var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _props$webChatContain6;
51
44
  const conversationEndCallback = async () => {
52
45
  var _props$webChatContain4, _props$webChatContain5;
53
- TelemetryHelper.logActionEvent(LogLevel.INFO, {
54
- Event: TelemetryEvent.ConversationEndedThreadEventReceived,
55
- Description: "Conversation is ended by agent side or by timeout."
56
- });
57
46
  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) {
58
47
  setWebChatStyles(styles => {
59
48
  return {
@@ -62,46 +51,18 @@ export const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatS
62
51
  };
63
52
  });
64
53
  }
65
- if (isPostChatEnabled === "true") {
66
- if (postChatSurveyMode === PostChatSurveyMode.Embed) {
67
- WebChatStoreLoader.store = null;
68
- dispatch({
69
- type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
70
- payload: ConversationState.PostchatLoading
71
- });
72
- await addDelayInMs(Constants.PostChatLoadingDurationInMs);
73
- const loadPostChatEvent = {
74
- eventName: BroadcastEvent.LoadPostChatSurvey
75
- };
76
- BroadcastService.postMessage(loadPostChatEvent);
77
- } else if (postChatSurveyMode === PostChatSurveyMode.Link) {
78
- dispatch({
79
- type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
80
- payload: ConversationState.InActive
81
- });
82
- }
83
- } else {
84
- dispatch({
85
- type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
86
- payload: ConversationState.InActive
87
- });
88
- dispatch({
89
- type: LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY_AGENT,
90
- payload: true
91
- });
92
- }
93
54
  dispatch({
94
- type: LiveChatWidgetActionType.SET_CHAT_TOKEN,
95
- payload: undefined
55
+ type: LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY_AGENT_EVENT_RECEIVED,
56
+ payload: true
96
57
  });
97
- dispatch({
98
- type: LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
99
- payload: undefined
58
+ TelemetryHelper.logActionEvent(LogLevel.INFO, {
59
+ Event: TelemetryEvent.ConversationEndedThreadEventReceived,
60
+ Description: "Conversation end by agent side or by timeout event received."
100
61
  });
101
62
  };
102
63
  webChatStore = createStore({},
103
64
  //initial state
104
- preProcessingMiddleware, attachmentProcessingMiddleware, createAttachmentUploadValidatorMiddleware((_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, createConversationEndMiddleware(conversationEndCallback), createDataMaskingMiddleware((_state$domainStates$l7 = state.domainStates.liveChatConfig) === null || _state$domainStates$l7 === void 0 ? void 0 : _state$domainStates$l7.DataMaskingInfo), createMessageTimeStampMiddleware, gifUploadMiddleware, htmlPlayerMiddleware, htmlTextMiddleware, createMaxMessageSizeValidator(localizedTexts), sanitizationMiddleware,
65
+ preProcessingMiddleware, attachmentProcessingMiddleware, createAttachmentUploadValidatorMiddleware((_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, createConversationEndMiddleware(conversationEndCallback), createDataMaskingMiddleware((_state$domainStates$l3 = state.domainStates.liveChatConfig) === null || _state$domainStates$l3 === void 0 ? void 0 : _state$domainStates$l3.DataMaskingInfo), createMessageTimeStampMiddleware, gifUploadMiddleware, htmlPlayerMiddleware, htmlTextMiddleware, createMaxMessageSizeValidator(localizedTexts), sanitizationMiddleware,
105
66
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
106
67
  ...(((_props$webChatContain6 = props.webChatContainerProps) === null || _props$webChatContain6 === void 0 ? void 0 : _props$webChatContain6.storeMiddlewares) ?? []));
107
68
  WebChatStoreLoader.store = webChatStore;
@@ -111,7 +72,7 @@ export const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatS
111
72
  const webChatProps = {
112
73
  ...defaultWebChatContainerStatefulProps.webChatProps,
113
74
  dir: state.domainStates.globalDir,
114
- locale: changeLanguageCodeFormatForWebChat(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)),
75
+ locale: changeLanguageCodeFormatForWebChat(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)),
115
76
  store: webChatStore,
116
77
  activityMiddleware: (_props$webChatContain7 = props.webChatContainerProps) !== null && _props$webChatContain7 !== void 0 && (_props$webChatContain8 = _props$webChatContain7.renderingMiddlewareProps) !== null && _props$webChatContain8 !== void 0 && _props$webChatContain8.disableActivityMiddleware ? undefined : 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),
117
78
  attachmentMiddleware: (_props$webChatContain9 = props.webChatContainerProps) !== null && _props$webChatContain9 !== void 0 && (_props$webChatContain10 = _props$webChatContain9.renderingMiddlewareProps) !== null && _props$webChatContain10 !== void 0 && _props$webChatContain10.disableAttachmentMiddleware ? undefined : createAttachmentMiddleware(((_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.enableInlinePlaying),
@@ -122,6 +83,7 @@ export const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatS
122
83
  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.webChatProps) === null || _defaultWebChatContai3 === void 0 ? void 0 : _defaultWebChatContai3.typingIndicatorMiddleware,
123
84
  onTelemetry: createWebChatTelemetry(),
124
85
  cardActionMiddleware: createCardActionMiddleware(((_props$webChatContain21 = props.webChatContainerProps) === null || _props$webChatContain21 === void 0 ? void 0 : _props$webChatContain21.botMagicCode) || undefined),
86
+ sendTypingIndicator: true,
125
87
  ...((_props$webChatContain22 = props.webChatContainerProps) === null || _props$webChatContain22 === void 0 ? void 0 : _props$webChatContain22.webChatProps)
126
88
  };
127
89
  return webChatProps;
@@ -1,11 +1,12 @@
1
1
  import "regenerator-runtime/runtime";
2
2
  import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
3
+ import { handleAuthentication, removeAuthTokenProvider } from "./authHelper";
4
+ import { isNullOrEmptyString, isNullOrUndefined } from "../../../common/utils";
3
5
  import { BroadcastService } from "@microsoft/omnichannel-chat-components";
4
6
  import { ConversationState } from "../../../contexts/common/ConversationState";
5
7
  import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
6
8
  import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
7
- import { handleAuthentication, removeAuthTokenProvider } from "./authHelper";
8
- import { isNullOrEmptyString, isNullOrUndefined } from "../../../common/utils";
9
+
9
10
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
11
  const handleChatReconnect = async (chatSDK, props, dispatch, setAdapter, initStartChat, state) => {
11
12
  var _props$chatConfig, _props$chatConfig$Liv;
@@ -53,14 +54,14 @@ const getChatReconnectContext = async (chatSDK, chatConfig, props, isAuthenticat
53
54
  const chatReconnectOptionalParams = {
54
55
  reconnectId: (_props$reconnectChatP4 = props.reconnectChatPaneProps) === null || _props$reconnectChatP4 === void 0 ? void 0 : _props$reconnectChatP4.reconnectId
55
56
  };
57
+ // Get auth token for getting chat reconnect context
56
58
  if (isAuthenticatedChat) {
57
- // Get auth token for for getting chat reconnect context
58
59
  await handleAuthentication(chatSDK, chatConfig, props.getAuthToken);
59
60
  }
60
61
  const reconnectChatContext = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getChatReconnectContext(chatReconnectOptionalParams));
61
62
  if (isAuthenticatedChat) {
62
63
  // remove auth token after reconnectId is fetched
63
- // this will be reset later at start chat
64
+ // AuthToken will be reset later at start chat
64
65
  removeAuthTokenProvider(chatSDK);
65
66
  }
66
67
  return reconnectChatContext;
@@ -76,10 +77,7 @@ const getChatReconnectContext = async (chatSDK, chatConfig, props, isAuthenticat
76
77
 
77
78
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
78
79
  const setReconnectIdAndStartChat = async (isAuthenticatedChat, chatSDK, props, dispatch, setAdapter, reconnectId, initStartChat) => {
79
- if (isAuthenticatedChat) {
80
- // Get auth token for for getting chat reconnect context
81
- await handleAuthentication(chatSDK, props.chatConfig, props.getAuthToken);
82
- } else {
80
+ if (!isAuthenticatedChat) {
83
81
  const startUnauthenticatedReconnectChat = {
84
82
  eventName: BroadcastEvent.StartUnauthenticatedReconnectChat
85
83
  };
@@ -96,7 +94,7 @@ const setReconnectIdAndStartChat = async (isAuthenticatedChat, chatSDK, props, d
96
94
  type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
97
95
  payload: ConversationState.Loading
98
96
  });
99
- await initStartChat(chatSDK, props.chatConfig, props.getAuthToken, dispatch, setAdapter, optionalParams);
97
+ await initStartChat(chatSDK, dispatch, setAdapter, props, optionalParams);
100
98
  };
101
99
  const redirectPage = (redirectURL, redirectInSameWindow) => {
102
100
  const redirectPageRequest = {
@@ -1,11 +1,18 @@
1
- import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
1
+ import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
2
2
  import { BroadcastService } from "@microsoft/omnichannel-chat-components";
3
3
  import { ConversationState } from "../../../contexts/common/ConversationState";
4
4
  import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
5
5
  import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
6
+ import { Constants } from "../../../common/Constants";
7
+ import { endChat } from "./endChat";
8
+ import { PostChatSurveyMode } from "../../postchatsurveypanestateful/enums/PostChatSurveyMode";
9
+ import { addDelayInMs } from "../../../common/utils";
10
+ import { NotificationHandler } from "../../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler";
11
+ import { NotificationScenarios } from "../../webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios";
12
+ import { ConversationEndEntity } from "../../../contexts/common/ConversationEndEntity";
6
13
 
7
14
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
8
- export const setPostChatContextAndLoadSurvey = async (chatSDK, dispatch, persistedChat) => {
15
+ const setPostChatContextAndLoadSurvey = async (chatSDK, dispatch, persistedChat) => {
9
16
  try {
10
17
  if (!persistedChat) {
11
18
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -35,4 +42,248 @@ export const setPostChatContextAndLoadSurvey = async (chatSDK, dispatch, persist
35
42
  payload: ConversationState.Postchat
36
43
  });
37
44
  });
38
- };
45
+ };
46
+
47
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
48
+ const checkPostChatEnabled = (props, state) => {
49
+ var _props$chatConfig, _props$chatConfig$Liv, _state$domainStates$l, _state$domainStates$l2;
50
+ const isPostChatEnabled = ((_props$chatConfig = props.chatConfig) === null || _props$chatConfig === void 0 ? void 0 : (_props$chatConfig$Liv = _props$chatConfig.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig$Liv === void 0 ? void 0 : _props$chatConfig$Liv.msdyn_postconversationsurveyenable) ?? ((_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
+ return isPostChatEnabled === Constants.true;
52
+ };
53
+
54
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
55
+ const initiatePostChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state) => {
56
+ // Check if Postchat already in progress and handle case where chat is ended by customer
57
+ if (state.appStates.postChatWorkflowInProgress && state.appStates.conversationEndedBy === ConversationEndEntity.Customer) {
58
+ await endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, true);
59
+ return;
60
+ }
61
+
62
+ // Conversation Details call required by customer as well as agent
63
+ const conversationDetails = await getConversationDetailsCall(chatSDK);
64
+ // Start Postchat workflow
65
+ dispatch({
66
+ type: LiveChatWidgetActionType.SET_POST_CHAT_WORKFLOW_IN_PROGRESS,
67
+ payload: true
68
+ });
69
+
70
+ // Below logic checks if agent or bot or noone joins conversation and handles them separately
71
+ if ((conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.participantType) === Constants.userParticipantTypeTag) {
72
+ if (state.appStates.conversationEndedBy === ConversationEndEntity.Customer) {
73
+ // Set use bot settings to false
74
+ await postChatInitiatedByCustomer(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state, conversationDetails, false);
75
+ } else if (state.appStates.conversationEndedBy === ConversationEndEntity.Agent) {
76
+ await postChatInitiatedByAgent(props, setWebChatStyles, dispatch, state);
77
+ } else {
78
+ const error = `Conversation was Ended after agent joined but App State was not set correctly: conversationEndedBy = ${state.appStates.conversationEndedBy}`;
79
+ TelemetryHelper.logActionEvent(LogLevel.ERROR, {
80
+ Event: TelemetryEvent.AppStatesException,
81
+ ExceptionDetails: {
82
+ exception: error
83
+ }
84
+ });
85
+ throw new Error(error);
86
+ }
87
+ } else if ((conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.participantType) === Constants.botParticipantTypeTag) {
88
+ // Set Use bot survey to true
89
+ dispatch({
90
+ type: LiveChatWidgetActionType.SET_SHOULD_USE_BOT_SURVEY,
91
+ payload: true
92
+ });
93
+ if (state.appStates.conversationEndedBy === ConversationEndEntity.Customer) {
94
+ // Set use bot settings to true
95
+ await postChatInitiatedByCustomer(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state, conversationDetails, true);
96
+ } else if (state.appStates.conversationEndedBy === ConversationEndEntity.Agent) {
97
+ await postChatInitiatedByBot(props, setWebChatStyles, dispatch, state);
98
+ } else {
99
+ const error = `Conversation was Ended after bot joined but App State was not set correctly: conversationEndedBy = ${state.appStates.conversationEndedBy}`;
100
+ TelemetryHelper.logActionEvent(LogLevel.ERROR, {
101
+ Event: TelemetryEvent.AppStatesException,
102
+ ExceptionDetails: {
103
+ exception: error
104
+ }
105
+ });
106
+ throw new Error(error);
107
+ }
108
+ } else {
109
+ if (state.appStates.conversationEndedBy === ConversationEndEntity.Customer) {
110
+ // No one has joined chat will be handled by postChat customer
111
+ await postChatInitiatedByCustomer(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state, conversationDetails, false);
112
+ } else {
113
+ const error = `ConversationDetails and App state was not set correctly: conversationDetails = ${JSON.stringify(conversationDetails)} , conversationEndedBy = ${state.appStates.conversationEndedBy}`;
114
+ TelemetryHelper.logActionEvent(LogLevel.ERROR, {
115
+ Event: TelemetryEvent.AppStatesException,
116
+ ExceptionDetails: {
117
+ exception: error
118
+ }
119
+ });
120
+ throw new Error(error);
121
+ }
122
+ }
123
+ };
124
+
125
+ // Function for link mode postchat workflow which is essentially same for both customer and agent
126
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
127
+ const linkModePostChatWorkflow = (props, dispatch, setWebChatStyles) => {
128
+ var _props$webChatContain, _props$webChatContain2;
129
+ TelemetryHelper.logActionEvent(LogLevel.INFO, {
130
+ Event: TelemetryEvent.LinkModePostChatWorkflowStarted
131
+ });
132
+ dispatch({
133
+ type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
134
+ payload: ConversationState.InActive
135
+ });
136
+
137
+ // Disable SendBox
138
+ 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) {
139
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
140
+ setWebChatStyles(styles => {
141
+ return {
142
+ ...styles,
143
+ hideSendBox: true
144
+ };
145
+ });
146
+ }
147
+ };
148
+
149
+ // Function for embed mode postchat workflow which is essentially same for both customer and agent
150
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
151
+ const embedModePostChatWorkflow = async (dispatch, state) => {
152
+ TelemetryHelper.logActionEvent(LogLevel.INFO, {
153
+ Event: TelemetryEvent.EmbedModePostChatWorkflowStarted
154
+ });
155
+ if (state.domainStates.postChatContext) {
156
+ dispatch({
157
+ type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
158
+ payload: ConversationState.PostchatLoading
159
+ });
160
+ await addDelayInMs(Constants.PostChatLoadingDurationInMs);
161
+ const loadPostChatEvent = {
162
+ eventName: BroadcastEvent.LoadPostChatSurvey
163
+ };
164
+ BroadcastService.postMessage(loadPostChatEvent);
165
+ } else {
166
+ const error = `Conversation was Ended but App State was not set correctly: postChatContext = ${state.domainStates.postChatContext}`;
167
+ TelemetryHelper.logActionEvent(LogLevel.ERROR, {
168
+ Event: TelemetryEvent.AppStatesException,
169
+ ExceptionDetails: {
170
+ exception: error
171
+ }
172
+ });
173
+ throw new Error(error);
174
+ }
175
+ };
176
+
177
+ // Function will handle only postchat cases initiated by customer
178
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
179
+ const postChatInitiatedByCustomer = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state, conversationDetails, shouldUseBotSetting) => {
180
+ let postChatSurveyMode = "";
181
+ if (shouldUseBotSetting) {
182
+ var _props$chatConfig2, _props$chatConfig2$Li, _state$domainStates$l3, _state$domainStates$l4;
183
+ postChatSurveyMode = ((_props$chatConfig2 = props.chatConfig) === null || _props$chatConfig2 === void 0 ? void 0 : (_props$chatConfig2$Li = _props$chatConfig2.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig2$Li === void 0 ? void 0 : _props$chatConfig2$Li.msdyn_postconversationsurveybotsurveymode) ?? ((_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_postconversationsurveybotsurveymode);
184
+ } else {
185
+ var _props$chatConfig3, _props$chatConfig3$Li, _state$domainStates$l5, _state$domainStates$l6;
186
+ postChatSurveyMode = ((_props$chatConfig3 = props.chatConfig) === null || _props$chatConfig3 === void 0 ? void 0 : (_props$chatConfig3$Li = _props$chatConfig3.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig3$Li === void 0 ? void 0 : _props$chatConfig3$Li.msdyn_postconversationsurveymode) ?? ((_state$domainStates$l5 = state.domainStates.liveChatConfig) === null || _state$domainStates$l5 === void 0 ? void 0 : (_state$domainStates$l6 = _state$domainStates$l5.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l6 === void 0 ? void 0 : _state$domainStates$l6.msdyn_postconversationsurveymode);
187
+ }
188
+ // Check if agent or bot has joined conversation
189
+ if ((conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.canRenderPostChat) === Constants.truePascal) {
190
+ TelemetryHelper.logActionEvent(LogLevel.INFO, {
191
+ Event: TelemetryEvent.PostChatWorkflowFromCustomer,
192
+ Description: shouldUseBotSetting ? "PostChat Workflow was started by customer using bot settings" : "PostChat Workflow was started by customer using agent settings"
193
+ });
194
+ const chatSession = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getCurrentLiveChatContext());
195
+ if (chatSession) {
196
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
197
+ chatSDK.chatToken = chatSession.chatToken ?? {};
198
+ chatSDK.requestId = chatSession.requestId;
199
+ }
200
+ // End chat call to end chatsdk but not close chat, only if chat ended by customer
201
+ await endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, true, false);
202
+ if (postChatSurveyMode === PostChatSurveyMode.Embed) {
203
+ await embedModePostChatWorkflow(dispatch, state);
204
+ } else if (postChatSurveyMode === PostChatSurveyMode.Link) {
205
+ linkModePostChatWorkflow(props, dispatch, setWebChatStyles);
206
+ } else {
207
+ const error = `Conversation was Ended but App State was not set correctly: msdyn_postconversationsurveymode = ${postChatSurveyMode}`;
208
+ TelemetryHelper.logActionEvent(LogLevel.ERROR, {
209
+ Event: TelemetryEvent.AppStatesException,
210
+ ExceptionDetails: {
211
+ exception: error
212
+ }
213
+ });
214
+ throw new Error(error);
215
+ }
216
+ } else {
217
+ // Agent did not join chat so end chat normally
218
+ await endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, true);
219
+ }
220
+ };
221
+
222
+ // Function will handle only postchat cases initiated by agent
223
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
224
+ const postChatInitiatedByAgent = async (props, setWebChatStyles, dispatch, state) => {
225
+ var _props$chatConfig4, _props$chatConfig4$Li, _state$domainStates$l7, _state$domainStates$l8;
226
+ const postChatSurveyMode = ((_props$chatConfig4 = props.chatConfig) === null || _props$chatConfig4 === void 0 ? void 0 : (_props$chatConfig4$Li = _props$chatConfig4.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig4$Li === void 0 ? void 0 : _props$chatConfig4$Li.msdyn_postconversationsurveymode) ?? ((_state$domainStates$l7 = state.domainStates.liveChatConfig) === null || _state$domainStates$l7 === void 0 ? void 0 : (_state$domainStates$l8 = _state$domainStates$l7.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l8 === void 0 ? void 0 : _state$domainStates$l8.msdyn_postconversationsurveymode);
227
+ TelemetryHelper.logActionEvent(LogLevel.INFO, {
228
+ Event: TelemetryEvent.PostChatWorkflowFromAgent,
229
+ Description: "PostChat Workflow was started by agent"
230
+ });
231
+ if (postChatSurveyMode === PostChatSurveyMode.Embed) {
232
+ await embedModePostChatWorkflow(dispatch, state);
233
+ } else if (postChatSurveyMode === PostChatSurveyMode.Link) {
234
+ linkModePostChatWorkflow(props, dispatch, setWebChatStyles);
235
+ } else {
236
+ const error = `Conversation was Ended but App State was not set correctly: msdyn_postconversationsurveymode = ${postChatSurveyMode}`;
237
+ TelemetryHelper.logActionEvent(LogLevel.ERROR, {
238
+ Event: TelemetryEvent.AppStatesException,
239
+ ExceptionDetails: {
240
+ exception: error
241
+ }
242
+ });
243
+ throw new Error(error);
244
+ }
245
+ };
246
+
247
+ // Function will handle only postchat cases initiated by bot
248
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
249
+ const postChatInitiatedByBot = async (props, setWebChatStyles, dispatch, state) => {
250
+ var _props$chatConfig5, _props$chatConfig5$Li, _state$domainStates$l9, _state$domainStates$l10;
251
+ const postChatSurveyMode = ((_props$chatConfig5 = props.chatConfig) === null || _props$chatConfig5 === void 0 ? void 0 : (_props$chatConfig5$Li = _props$chatConfig5.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig5$Li === void 0 ? void 0 : _props$chatConfig5$Li.msdyn_postconversationsurveybotsurveymode) ?? ((_state$domainStates$l9 = state.domainStates.liveChatConfig) === null || _state$domainStates$l9 === void 0 ? void 0 : (_state$domainStates$l10 = _state$domainStates$l9.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l10 === void 0 ? void 0 : _state$domainStates$l10.msdyn_postconversationsurveybotsurveymode);
252
+ TelemetryHelper.logActionEvent(LogLevel.INFO, {
253
+ Event: TelemetryEvent.PostChatWorkflowFromBot,
254
+ Description: "PostChat Workflow was started by bot"
255
+ });
256
+ if (postChatSurveyMode === PostChatSurveyMode.Embed) {
257
+ await embedModePostChatWorkflow(dispatch, state);
258
+ } else if (postChatSurveyMode === PostChatSurveyMode.Link) {
259
+ linkModePostChatWorkflow(props, dispatch, setWebChatStyles);
260
+ } else {
261
+ const error = `Conversation was Ended but App State was not set correctly: msdyn_postconversationsurveybotsurveymode = ${postChatSurveyMode}`;
262
+ TelemetryHelper.logActionEvent(LogLevel.ERROR, {
263
+ Event: TelemetryEvent.AppStatesException,
264
+ ExceptionDetails: {
265
+ exception: error
266
+ }
267
+ });
268
+ throw new Error(error);
269
+ }
270
+ };
271
+
272
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
273
+ const getConversationDetailsCall = async chatSDK => {
274
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
275
+ let conversationDetails = undefined;
276
+ try {
277
+ conversationDetails = await chatSDK.getConversationDetails();
278
+ } catch (error) {
279
+ TelemetryHelper.logSDKEvent(LogLevel.ERROR, {
280
+ Event: TelemetryEvent.GetConversationDetailsCallFailed,
281
+ ExceptionDetails: {
282
+ exception: `Get Conversation Details Call Failed : ${error}`
283
+ }
284
+ });
285
+ NotificationHandler.notifyError(NotificationScenarios.Connection, "Get Conversation Details Call Failed: " + error);
286
+ }
287
+ return conversationDetails;
288
+ };
289
+ export { setPostChatContextAndLoadSurvey, checkPostChatEnabled, initiatePostChat };