@microsoft/omnichannel-chat-widget 1.8.2-main.fc93d3d → 1.8.3-main.38c88a7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -1
- package/lib/cjs/common/Constants.js +8 -2
- package/lib/cjs/common/telemetry/TelemetryConstants.js +2 -0
- package/lib/cjs/common/utils.js +27 -2
- package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +4 -4
- package/lib/cjs/components/livechatwidget/common/createInternetConnectionChangeHandler.js +22 -9
- package/lib/cjs/components/livechatwidget/common/createMarkdown.js +54 -1
- package/lib/cjs/components/livechatwidget/common/customEventHandler.js +53 -0
- package/lib/cjs/components/livechatwidget/common/endChat.js +1 -0
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +5 -1
- package/lib/cjs/components/livechatwidget/common/renderSurveyHelpers.js +23 -0
- package/lib/cjs/components/livechatwidget/common/startChat.js +1 -1
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +5 -1
- package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +1 -1
- package/lib/cjs/components/webchatcontainerstateful/common/DesignerChatAdapter.js +3 -1
- package/lib/cjs/components/webchatcontainerstateful/common/utils/chatAdapterUtils.js +27 -2
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/callActionMiddleware.js +42 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/customEventMiddleware.js +41 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.js +45 -0
- package/lib/cjs/contexts/common/CustomEventType.js +1 -0
- package/lib/cjs/firstresponselatency/FirstMessageTrackerFromBot.js +101 -36
- package/lib/cjs/firstresponselatency/FirstResponseLatencyTracker.js +39 -21
- package/lib/cjs/firstresponselatency/util.js +12 -8
- package/lib/cjs/plugins/createChatTranscript.js +13 -0
- package/lib/esm/common/Constants.js +8 -2
- package/lib/esm/common/telemetry/TelemetryConstants.js +2 -0
- package/lib/esm/common/utils.js +21 -0
- package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +4 -4
- package/lib/esm/components/livechatwidget/common/createInternetConnectionChangeHandler.js +22 -9
- package/lib/esm/components/livechatwidget/common/createMarkdown.js +54 -1
- package/lib/esm/components/livechatwidget/common/customEventHandler.js +45 -0
- package/lib/esm/components/livechatwidget/common/endChat.js +1 -0
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +5 -1
- package/lib/esm/components/livechatwidget/common/renderSurveyHelpers.js +23 -0
- package/lib/esm/components/livechatwidget/common/startChat.js +1 -1
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +5 -1
- package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +1 -1
- package/lib/esm/components/webchatcontainerstateful/common/DesignerChatAdapter.js +4 -2
- package/lib/esm/components/webchatcontainerstateful/common/utils/chatAdapterUtils.js +23 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/callActionMiddleware.js +36 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/customEventMiddleware.js +33 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.js +38 -0
- package/lib/esm/contexts/common/CustomEventType.js +1 -0
- package/lib/esm/firstresponselatency/FirstMessageTrackerFromBot.js +101 -36
- package/lib/esm/firstresponselatency/FirstResponseLatencyTracker.js +39 -21
- package/lib/esm/firstresponselatency/util.js +12 -8
- package/lib/esm/plugins/createChatTranscript.js +13 -0
- package/lib/types/common/Constants.d.ts +8 -2
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +2 -0
- package/lib/types/common/utils.d.ts +8 -0
- package/lib/types/components/livechatwidget/common/customEventHandler.d.ts +4 -0
- package/lib/types/components/webchatcontainerstateful/common/utils/chatAdapterUtils.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/callActionMiddleware.d.ts +8 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/customEventMiddleware.d.ts +22 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.d.ts +5 -0
- package/lib/types/contexts/common/CustomEventType.d.ts +6 -0
- package/lib/types/firstresponselatency/FirstResponseLatencyTracker.d.ts +2 -2
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -223,6 +223,51 @@ const customizedFooterProp: IFooterProps = {
|
|
|
223
223
|
|
|
224
224
|
> :pushpin: Note that [WebChat hooks](https://github.com/microsoft/BotFramework-WebChat/blob/main/docs/HOOKS.md) can also be used in any custom components.
|
|
225
225
|
|
|
226
|
+
#### Bidirectional Custom Events
|
|
227
|
+
- Sending events from a hosting web page to bots/agents
|
|
228
|
+
- Register a function to post event
|
|
229
|
+
```js
|
|
230
|
+
//define sendCustomEvent function
|
|
231
|
+
const sendCustomEvent = (payload) => {
|
|
232
|
+
const customEvent = {
|
|
233
|
+
eventName: "sendCustomEvent",
|
|
234
|
+
payload
|
|
235
|
+
};
|
|
236
|
+
BroadcastService.postMessage(customEvent);
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
//attach the sendCustomEvent function to window object
|
|
240
|
+
window["sendCustomEvent"] = sendCustomEvent;
|
|
241
|
+
|
|
242
|
+
//invoke the sendCustomEvent function with some customized payload
|
|
243
|
+
window.sendCustomEvent({
|
|
244
|
+
customEventName: "TestEvent",
|
|
245
|
+
customEventValue: {
|
|
246
|
+
boolVar: true,
|
|
247
|
+
displayableVar: {
|
|
248
|
+
isDisplayable: true,
|
|
249
|
+
value: "From C2: "+ new Date().toISOString()
|
|
250
|
+
},
|
|
251
|
+
numberVar: -10.5,
|
|
252
|
+
stringVar: "Hello from C2 str: " + new Date().toISOString()
|
|
253
|
+
}
|
|
254
|
+
})
|
|
255
|
+
```
|
|
256
|
+
- Receiving events from bots/agents
|
|
257
|
+
```js
|
|
258
|
+
//define setOnCustomEvent function
|
|
259
|
+
const setOnCustomEvent = (callback) => {
|
|
260
|
+
BroadcastService.getMessageByEventName("onCustomEvent").subscribe((event) => {
|
|
261
|
+
if (event && typeof callback === "function") {
|
|
262
|
+
callback(event);
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
//set callback function
|
|
268
|
+
setOnCustomEvent((event) => console.log(event));
|
|
269
|
+
```
|
|
270
|
+
|
|
226
271
|
## See Also
|
|
227
272
|
|
|
228
273
|
[Customizations Dev Guide](https://github.com/microsoft/omnichannel-chat-widget/blob/main/docs/customizations/getstarted.md)\
|
|
@@ -232,4 +277,4 @@ const customizedFooterProp: IFooterProps = {
|
|
|
232
277
|
[How to Add Visual Regression Tests](https://github.com/microsoft/omnichannel-chat-widget/blob/main/docs/VisualRegressionTestingGuide.md)\
|
|
233
278
|
[Security](https://github.com/microsoft/omnichannel-chat-widget/blob/main/SECURITY.md)\
|
|
234
279
|
[Third Party Cookie Support](https://github.com/microsoft/omnichannel-chat-widget/blob/main/docs/Tpc.md)\
|
|
235
|
-
[Storybook](https://microsoft.github.io/omnichannel-chat-widget/docs/storybook/)
|
|
280
|
+
[Storybook](https://microsoft.github.io/omnichannel-chat-widget/docs/storybook/)
|
|
@@ -32,6 +32,7 @@ _defineProperty(Constants, "webchatChannelId", "webchat");
|
|
|
32
32
|
_defineProperty(Constants, "markdown", "markdown");
|
|
33
33
|
_defineProperty(Constants, "actionType", "actionType");
|
|
34
34
|
_defineProperty(Constants, "markDownSystemMessageClass", "webchat__basic-transcript__activity-markdown-body");
|
|
35
|
+
_defineProperty(Constants, "MARKDOWN_LIST_INDENTATION", " ");
|
|
35
36
|
_defineProperty(Constants, "String", "string");
|
|
36
37
|
_defineProperty(Constants, "ChatMessagesJson", "chatMessagesJson");
|
|
37
38
|
_defineProperty(Constants, "truePascal", "True");
|
|
@@ -115,8 +116,7 @@ _defineProperty(Constants, "TargetRelationshipAttributes", "noopener noreferrer"
|
|
|
115
116
|
// Markdown icons
|
|
116
117
|
_defineProperty(Constants, "OpenLinkIconCssClass", "webchat__render-markdown__external-link-icon");
|
|
117
118
|
// internet connection test
|
|
118
|
-
_defineProperty(Constants, "
|
|
119
|
-
_defineProperty(Constants, "internetConnectionTestUrlText", "Omnichannel Connect Test");
|
|
119
|
+
_defineProperty(Constants, "internetConnectionTestPath", "/livechatwidget/version.txt");
|
|
120
120
|
_defineProperty(Constants, "ChatWidgetStateChangedPrefix", "ChatWidgetStateChanged");
|
|
121
121
|
_defineProperty(Constants, "PostChatLoadingDurationInMs", 2000);
|
|
122
122
|
_defineProperty(Constants, "BrowserUnloadConfirmationMessage", "Do you want to leave chat?");
|
|
@@ -132,6 +132,12 @@ _defineProperty(Constants, "InitContextParamsResponse", "initContextParamsRespon
|
|
|
132
132
|
_defineProperty(Constants, "OCOriginalMessageId", "OriginalMessageId");
|
|
133
133
|
_defineProperty(Constants, "WebchatSequenceIdAttribute", "webchat:sequence-id");
|
|
134
134
|
_defineProperty(Constants, "MessageSequenceIdOverride", "MessageSequenceIdOverride");
|
|
135
|
+
_defineProperty(Constants, "sendCustomEvent", "sendCustomEvent");
|
|
136
|
+
_defineProperty(Constants, "onCustomEvent", "onCustomEvent");
|
|
137
|
+
_defineProperty(Constants, "customEventName", "customEventName");
|
|
138
|
+
_defineProperty(Constants, "customEventValue", "customEventValue");
|
|
139
|
+
_defineProperty(Constants, "Hidden", "Hidden");
|
|
140
|
+
_defineProperty(Constants, "EndConversationDueToOverflow", "endconversationduetooverflow");
|
|
135
141
|
const Regex = (_class = /*#__PURE__*/_createClass(function Regex() {
|
|
136
142
|
_classCallCheck(this, Regex);
|
|
137
143
|
}), _defineProperty(_class, "EmailRegex", "^(?:[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\")@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?)*|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\])$"), _class);
|
|
@@ -190,6 +190,7 @@ exports.TelemetryEvent = TelemetryEvent;
|
|
|
190
190
|
TelemetryEvent["BotAuthActivityUndefinedSignInId"] = "BotAuthActivityUndefinedSignInId";
|
|
191
191
|
TelemetryEvent["ThirdPartyCookiesBlocked"] = "ThirdPartyCookiesBlocked";
|
|
192
192
|
TelemetryEvent["ParticipantsRemovedEvent"] = "ParticipantsRemovedEvent";
|
|
193
|
+
TelemetryEvent["QueueOverflowEvent"] = "QueueOverflowEvent";
|
|
193
194
|
TelemetryEvent["ProcessingHTMLTextMiddlewareFailed"] = "ProcessingHTMLTextMiddlewareFailed";
|
|
194
195
|
TelemetryEvent["ProcessingSanitizationMiddlewareFailed"] = "ProcessingSanitizationMiddlewareFailed";
|
|
195
196
|
TelemetryEvent["FormatTagsMiddlewareJSONStringifyFailed"] = "FormatTagsMiddlewareJSONStringifyFailed";
|
|
@@ -228,6 +229,7 @@ exports.TelemetryEvent = TelemetryEvent;
|
|
|
228
229
|
TelemetryEvent["SystemMessageReceived"] = "SystemMessageReceived";
|
|
229
230
|
TelemetryEvent["RehydrateMessageReceived"] = "RehydrateMessageReceived";
|
|
230
231
|
TelemetryEvent["CustomContextReceived"] = "CustomContextReceived";
|
|
232
|
+
TelemetryEvent["CustomEventAction"] = "CustomEventAction";
|
|
231
233
|
TelemetryEvent["NetworkDisconnected"] = "NetworkDisconnected";
|
|
232
234
|
TelemetryEvent["NetworkReconnected"] = "NetworkReconnected";
|
|
233
235
|
TelemetryEvent["LinkModePostChatWorkflowStarted"] = "LinkModePostChatWorkflowStarted";
|
package/lib/cjs/common/utils.js
CHANGED
|
@@ -3,9 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.getConversationDetailsCall = exports.getBroadcastChannelName = exports.formatTemplateString = exports.findParentFocusableElementsWithoutChildContainer = exports.findAllFocusableElement = exports.extractPreChatSurveyResponseValues = exports.escapeHtml = exports.debounceLeading = exports.createTimer = exports.createFileAndDownload = exports.checkContactIdError = exports.changeLanguageCodeFormatForWebChat = exports.addDelayInMs = void 0;
|
|
6
|
+
exports.getCustomEventValue = exports.getConversationDetailsCall = exports.getBroadcastChannelName = exports.formatTemplateString = exports.findParentFocusableElementsWithoutChildContainer = exports.findAllFocusableElement = exports.extractPreChatSurveyResponseValues = exports.escapeHtml = exports.debounceLeading = exports.createTimer = exports.createFileAndDownload = exports.checkContactIdError = exports.changeLanguageCodeFormatForWebChat = exports.addDelayInMs = void 0;
|
|
7
7
|
exports.getDeviceType = getDeviceType;
|
|
8
|
-
exports.
|
|
8
|
+
exports.getWidgetEndChatEventName = exports.getWidgetCacheIdfromProps = exports.getWidgetCacheId = exports.getTimestampHourMinute = exports.getStateFromCache = exports.getLocaleDirection = exports.getIconText = exports.getDomain = void 0;
|
|
9
|
+
exports.isEndConversationDueToOverflowActivity = isEndConversationDueToOverflowActivity;
|
|
10
|
+
exports.setTabIndices = exports.setOcUserAgent = exports.setFocusOnSendBox = exports.setFocusOnElement = exports.preventFocusToMoveOutOfElement = exports.parseLowerCaseString = exports.parseAdaptiveCardPayload = exports.newGuid = exports.isValidCustomEvent = exports.isUndefinedOrEmpty = exports.isThisSessionPopout = exports.isNullOrUndefined = exports.isNullOrEmptyString = void 0;
|
|
9
11
|
var _Constants = require("./Constants");
|
|
10
12
|
var _TelemetryConstants = require("./telemetry/TelemetryConstants");
|
|
11
13
|
var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
|
|
@@ -494,4 +496,27 @@ function getDeviceType() {
|
|
|
494
496
|
} else {
|
|
495
497
|
return "standard";
|
|
496
498
|
}
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
//Bots expect a payload containing:
|
|
502
|
+
//1. customEventName: this should be string describe the event name
|
|
503
|
+
//2. customEventValue: given the value is from customer with unknown type, it is required to stringify the payload later
|
|
504
|
+
const isValidCustomEvent = payload => {
|
|
505
|
+
if (_Constants.Constants.customEventName in payload && payload.customEventName && typeof payload.customEventName === _Constants.Constants.String && _Constants.Constants.customEventValue in payload && payload.customEventValue) return true;
|
|
506
|
+
return false;
|
|
507
|
+
};
|
|
508
|
+
exports.isValidCustomEvent = isValidCustomEvent;
|
|
509
|
+
const getCustomEventValue = customEventPayload => {
|
|
510
|
+
let returnVal = "";
|
|
511
|
+
try {
|
|
512
|
+
returnVal = typeof customEventPayload.customEventValue === _Constants.Constants.String ? customEventPayload.customEventValue : JSON.stringify(customEventPayload.customEventValue);
|
|
513
|
+
} catch (error) {
|
|
514
|
+
console.error(error);
|
|
515
|
+
}
|
|
516
|
+
return returnVal;
|
|
517
|
+
};
|
|
518
|
+
exports.getCustomEventValue = getCustomEventValue;
|
|
519
|
+
function isEndConversationDueToOverflowActivity(activity) {
|
|
520
|
+
var _activity$channelData, _activity$channelData2;
|
|
521
|
+
return (activity === null || activity === void 0 ? void 0 : (_activity$channelData = activity.channelData) === null || _activity$channelData === void 0 ? void 0 : _activity$channelData.tags) && Array.isArray(activity === null || activity === void 0 ? void 0 : (_activity$channelData2 = activity.channelData) === null || _activity$channelData2 === void 0 ? void 0 : _activity$channelData2.tags) && activity.channelData.tags.includes(_Constants.Constants.EndConversationDueToOverflow);
|
|
497
522
|
}
|
|
@@ -74,7 +74,6 @@ const ChatButtonStateful = props => {
|
|
|
74
74
|
};
|
|
75
75
|
const outOfOfficeStyleProps = Object.assign({}, _defaultOutOfOfficeChatButtonStyleProps.defaultOutOfOfficeChatButtonStyleProps, outOfOfficeButtonProps === null || outOfOfficeButtonProps === void 0 ? void 0 : outOfOfficeButtonProps.styleProps);
|
|
76
76
|
const controlProps = {
|
|
77
|
-
...(buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.controlProps),
|
|
78
77
|
id: "oc-lcw-chat-button",
|
|
79
78
|
dir: state.domainStates.globalDir,
|
|
80
79
|
titleText: "Let's Chat!",
|
|
@@ -83,7 +82,8 @@ const ChatButtonStateful = props => {
|
|
|
83
82
|
unreadMessageCount: state.appStates.unreadMessageCount ? state.appStates.unreadMessageCount > _Constants.Constants.maximumUnreadMessageCount ? (_props$buttonProps = props.buttonProps) === null || _props$buttonProps === void 0 ? void 0 : (_props$buttonProps$co = _props$buttonProps.controlProps) === null || _props$buttonProps$co === void 0 ? void 0 : _props$buttonProps$co.largeUnreadMessageString : state.appStates.unreadMessageCount.toString() : "0",
|
|
84
83
|
unreadMessageString: (_props$buttonProps2 = props.buttonProps) === null || _props$buttonProps2 === void 0 ? void 0 : (_props$buttonProps2$c = _props$buttonProps2.controlProps) === null || _props$buttonProps2$c === void 0 ? void 0 : _props$buttonProps2$c.unreadMessageString,
|
|
85
84
|
// Regular chat button onClick - this will always take precedence
|
|
86
|
-
onClick: () => ref.current()
|
|
85
|
+
onClick: () => ref.current(),
|
|
86
|
+
...(buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.controlProps)
|
|
87
87
|
};
|
|
88
88
|
const outOfOfficeControlProps = {
|
|
89
89
|
// Only take specific properties from outOfOfficeButtonProps, never onClick
|
|
@@ -92,7 +92,6 @@ const ChatButtonStateful = props => {
|
|
|
92
92
|
titleText: (outOfOfficeButtonProps === null || outOfOfficeButtonProps === void 0 ? void 0 : (_outOfOfficeButtonPro = outOfOfficeButtonProps.controlProps) === null || _outOfOfficeButtonPro === void 0 ? void 0 : _outOfOfficeButtonPro.titleText) || "We're Offline",
|
|
93
93
|
subtitleText: (outOfOfficeButtonProps === null || outOfOfficeButtonProps === void 0 ? void 0 : (_outOfOfficeButtonPro2 = outOfOfficeButtonProps.controlProps) === null || _outOfOfficeButtonPro2 === void 0 ? void 0 : _outOfOfficeButtonPro2.subtitleText) || "No agents available",
|
|
94
94
|
unreadMessageString: (_props$buttonProps3 = props.buttonProps) === null || _props$buttonProps3 === void 0 ? void 0 : (_props$buttonProps3$c = _props$buttonProps3.controlProps) === null || _props$buttonProps3$c === void 0 ? void 0 : _props$buttonProps3$c.unreadMessageString,
|
|
95
|
-
...(outOfOfficeButtonProps === null || outOfOfficeButtonProps === void 0 ? void 0 : outOfOfficeButtonProps.controlProps),
|
|
96
95
|
// Out-of-office specific onClick - this will ALWAYS take precedence
|
|
97
96
|
onClick: () => {
|
|
98
97
|
if (state.appStates.isMinimized) {
|
|
@@ -105,7 +104,8 @@ const ChatButtonStateful = props => {
|
|
|
105
104
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
106
105
|
payload: _ConversationState.ConversationState.OutOfOffice
|
|
107
106
|
});
|
|
108
|
-
}
|
|
107
|
+
},
|
|
108
|
+
...(outOfOfficeButtonProps === null || outOfOfficeButtonProps === void 0 ? void 0 : outOfOfficeButtonProps.controlProps)
|
|
109
109
|
};
|
|
110
110
|
(0, _react.useEffect)(() => {
|
|
111
111
|
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
@@ -13,34 +13,47 @@ var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
|
|
|
13
13
|
var _defaultMiddlewareLocalizedTexts = require("../../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts");
|
|
14
14
|
var _createReducer = require("../../../contexts/createReducer");
|
|
15
15
|
var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidgetActionType");
|
|
16
|
-
const
|
|
16
|
+
const getRegionBasedInternetTestUrl = widgetSnippet => {
|
|
17
|
+
var _widgetSnippet$match;
|
|
18
|
+
if (!widgetSnippet) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
const widgetSnippetSourceRegex = new RegExp("src=\"(https:\\/\\/[\\w-.]+)[\\w-.\\/]+\"");
|
|
22
|
+
const baseCdnUrl = (_widgetSnippet$match = widgetSnippet.match(widgetSnippetSourceRegex)) === null || _widgetSnippet$match === void 0 ? void 0 : _widgetSnippet$match[1];
|
|
23
|
+
return baseCdnUrl ? `${baseCdnUrl}${_Constants.Constants.internetConnectionTestPath}` : null;
|
|
24
|
+
};
|
|
25
|
+
const isInternetConnected = async testUrl => {
|
|
17
26
|
try {
|
|
18
|
-
const response = await fetch(
|
|
19
|
-
|
|
20
|
-
|
|
27
|
+
const response = await fetch(testUrl, {
|
|
28
|
+
method: "GET",
|
|
29
|
+
cache: "no-cache"
|
|
30
|
+
});
|
|
31
|
+
return response.ok;
|
|
21
32
|
} catch {
|
|
22
33
|
return false;
|
|
23
34
|
}
|
|
24
35
|
};
|
|
25
36
|
const createInternetConnectionChangeHandler = async state => {
|
|
26
37
|
const handler = async () => {
|
|
27
|
-
|
|
38
|
+
var _inMemoryState$domain, _inMemoryState$domain2;
|
|
28
39
|
const inMemoryState = (0, _createReducer.executeReducer)(state, {
|
|
29
40
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
|
|
30
41
|
payload: null
|
|
31
42
|
});
|
|
43
|
+
const testUrl = getRegionBasedInternetTestUrl((_inMemoryState$domain = inMemoryState.domainStates.liveChatConfig) === null || _inMemoryState$domain === void 0 ? void 0 : (_inMemoryState$domain2 = _inMemoryState$domain.LiveWSAndLiveChatEngJoin) === null || _inMemoryState$domain2 === void 0 ? void 0 : _inMemoryState$domain2.msdyn_widgetsnippet);
|
|
44
|
+
const connected = testUrl ? await isInternetConnected(testUrl) : false;
|
|
32
45
|
if (!connected) {
|
|
33
|
-
var _inMemoryState$
|
|
46
|
+
var _inMemoryState$domain3, _inMemoryState$domain4;
|
|
34
47
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.WARN, {
|
|
35
48
|
Event: _TelemetryConstants.TelemetryEvent.NetworkDisconnected
|
|
36
49
|
});
|
|
37
|
-
_NotificationHandler.NotificationHandler.notifyError(_NotificationScenarios.NotificationScenarios.InternetConnection, (inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$
|
|
50
|
+
_NotificationHandler.NotificationHandler.notifyError(_NotificationScenarios.NotificationScenarios.InternetConnection, (inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$domain3 = inMemoryState.domainStates) === null || _inMemoryState$domain3 === void 0 ? void 0 : (_inMemoryState$domain4 = _inMemoryState$domain3.middlewareLocalizedTexts) === null || _inMemoryState$domain4 === void 0 ? void 0 : _inMemoryState$domain4.MIDDLEWARE_BANNER_NO_INTERNET_CONNECTION) ?? _defaultMiddlewareLocalizedTexts.defaultMiddlewareLocalizedTexts.MIDDLEWARE_BANNER_NO_INTERNET_CONNECTION);
|
|
38
51
|
} else {
|
|
39
|
-
var _inMemoryState$
|
|
52
|
+
var _inMemoryState$domain5, _inMemoryState$domain6;
|
|
40
53
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.WARN, {
|
|
41
54
|
Event: _TelemetryConstants.TelemetryEvent.NetworkReconnected
|
|
42
55
|
});
|
|
43
|
-
_NotificationHandler.NotificationHandler.notifySuccess(_NotificationScenarios.NotificationScenarios.InternetConnection, (inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$
|
|
56
|
+
_NotificationHandler.NotificationHandler.notifySuccess(_NotificationScenarios.NotificationScenarios.InternetConnection, (inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$domain5 = inMemoryState.domainStates) === null || _inMemoryState$domain5 === void 0 ? void 0 : (_inMemoryState$domain6 = _inMemoryState$domain5.middlewareLocalizedTexts) === null || _inMemoryState$domain6 === void 0 ? void 0 : _inMemoryState$domain6.MIDDLEWARE_BANNER_INTERNET_BACK_ONLINE) ?? _defaultMiddlewareLocalizedTexts.defaultMiddlewareLocalizedTexts.MIDDLEWARE_BANNER_INTERNET_BACK_ONLINE);
|
|
44
57
|
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
45
58
|
eventName: _TelemetryConstants.BroadcastEvent.NetworkReconnected
|
|
46
59
|
});
|
|
@@ -34,12 +34,65 @@ const createMarkdown = (disableMarkdownMessageFormatting, disableNewLineMarkdown
|
|
|
34
34
|
// Rule to process html blocks and paragraphs
|
|
35
35
|
"html_inline",
|
|
36
36
|
// Rule to process html tags
|
|
37
|
-
"newline"
|
|
37
|
+
"newline",
|
|
38
|
+
// Rule to proceess '\n'
|
|
39
|
+
"list" // Enable list parsing rule
|
|
38
40
|
]);
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
markdown.disable(["strikethrough"]);
|
|
42
44
|
|
|
45
|
+
// Custom plugin to fix numbered list continuity
|
|
46
|
+
markdown.use(function (md) {
|
|
47
|
+
const originalRender = md.render.bind(md);
|
|
48
|
+
const originalRenderInline = md.renderInline.bind(md);
|
|
49
|
+
function preprocessText(text) {
|
|
50
|
+
// Handle numbered lists that come with double line breaks (knowledge article format)
|
|
51
|
+
// This ensures proper continuous numbering instead of separate lists
|
|
52
|
+
|
|
53
|
+
let result = text;
|
|
54
|
+
|
|
55
|
+
// Only process if the text contains the double line break pattern
|
|
56
|
+
// But exclude simple numbered lists (where content after \n\n starts with another number)
|
|
57
|
+
if (!/\d+\.\s+.*?\n\n(?!\d+\.\s)[\s\S]*?(?:\n\n\d+\.|\s*$)/.test(text)) {
|
|
58
|
+
return result;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Convert "1. Item\n\nContent\n\n2. Item" to proper markdown list format
|
|
62
|
+
// Use improved pattern with negative lookahead to exclude cases where content starts with numbered list
|
|
63
|
+
const listPattern = /(\d+\.\s+[^\n]+)(\n\n(?!\d+\.\s)[\s\S]*?)(?=\n\n\d+\.|\s*$)/g;
|
|
64
|
+
if (listPattern.test(result)) {
|
|
65
|
+
// Reset regex state for actual replacement
|
|
66
|
+
listPattern.lastIndex = 0;
|
|
67
|
+
result = result.replace(listPattern, (match, listItem, content) => {
|
|
68
|
+
if (!content) {
|
|
69
|
+
return match;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Format content with proper indentation
|
|
73
|
+
const cleanContent = content.substring(2); // Remove leading \n\n
|
|
74
|
+
const lines = cleanContent.split("\n");
|
|
75
|
+
const indentedContent = lines.map(line => line.trim() ? `${_Constants.Constants.MARKDOWN_LIST_INDENTATION}${line}` : "").join("\n");
|
|
76
|
+
const lineBreak = disableNewLineMarkdownSupport ? "\n" : "\n\n";
|
|
77
|
+
return `${listItem}${lineBreak}${indentedContent}`;
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
return result;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
84
|
+
md.render = function (text, env) {
|
|
85
|
+
const processedText = preprocessText(text);
|
|
86
|
+
return originalRender(processedText, env);
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
90
|
+
md.renderInline = function (text, env) {
|
|
91
|
+
const processedText = preprocessText(text);
|
|
92
|
+
return originalRenderInline(processedText, env);
|
|
93
|
+
};
|
|
94
|
+
});
|
|
95
|
+
|
|
43
96
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
44
97
|
markdown.use(_markdownItForInline.default, "url_new_win", "link_open", function (tokens, idx, env) {
|
|
45
98
|
const targetAttrIndex = tokens[idx].attrIndex(_Constants.Constants.Target);
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.subscribeToSendCustomEvent = exports.customEventCallback = void 0;
|
|
7
|
+
var _Constants = require("../../../common/Constants");
|
|
8
|
+
var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
|
|
9
|
+
var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
|
|
10
|
+
var _utils = require("../../../common/utils");
|
|
11
|
+
const customEventCallback = facadeChatSDK => event => {
|
|
12
|
+
if (!(_Constants.Constants.payload in event)) return;
|
|
13
|
+
if ((0, _utils.isValidCustomEvent)(event.payload)) {
|
|
14
|
+
const customEventPayload = event.payload;
|
|
15
|
+
try {
|
|
16
|
+
const customEventValueStr = (0, _utils.getCustomEventValue)(customEventPayload);
|
|
17
|
+
const customEventName = customEventPayload.customEventName;
|
|
18
|
+
const messageMeta = {
|
|
19
|
+
customEvent: _Constants.Constants.true,
|
|
20
|
+
customEventName: customEventName,
|
|
21
|
+
customEventValue: customEventValueStr
|
|
22
|
+
};
|
|
23
|
+
const messagePayload = {
|
|
24
|
+
content: "",
|
|
25
|
+
tags: [_Constants.Constants.Hidden],
|
|
26
|
+
metadata: messageMeta,
|
|
27
|
+
timestamp: new Date()
|
|
28
|
+
};
|
|
29
|
+
facadeChatSDK.sendMessage(messagePayload);
|
|
30
|
+
_TelemetryHelper.TelemetryHelper.logActionEventToAllTelemetry(_TelemetryConstants.LogLevel.DEBUG, {
|
|
31
|
+
Event: _TelemetryConstants.TelemetryEvent.CustomEventAction,
|
|
32
|
+
Description: "Sent customEvent.",
|
|
33
|
+
CustomProperties: {
|
|
34
|
+
customEventName,
|
|
35
|
+
lengthCustomEventValue: customEventValueStr.length
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
} catch (error) {
|
|
39
|
+
_TelemetryHelper.TelemetryHelper.logActionEventToAllTelemetry(_TelemetryConstants.LogLevel.ERROR, {
|
|
40
|
+
Event: _TelemetryConstants.TelemetryEvent.CustomEventAction,
|
|
41
|
+
Description: "Failed to process CustomEvent.",
|
|
42
|
+
ExceptionDetails: {
|
|
43
|
+
error
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
exports.customEventCallback = customEventCallback;
|
|
50
|
+
const subscribeToSendCustomEvent = (broadcastService, facadeChatSDK, customEventCallback) => {
|
|
51
|
+
broadcastService.getMessageByEventName(_Constants.Constants.sendCustomEvent).subscribe(customEventCallback(facadeChatSDK));
|
|
52
|
+
};
|
|
53
|
+
exports.subscribeToSendCustomEvent = subscribeToSendCustomEvent;
|
|
@@ -40,6 +40,7 @@ const prepareEndChat = async (props, facadeChatSDK, state, dispatch, setAdapter,
|
|
|
40
40
|
Description: _Constants.PrepareEndChatDescriptionConstants.ConversationEndedByCustomerWithoutPostChat
|
|
41
41
|
});
|
|
42
42
|
await endChat(props, facadeChatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true);
|
|
43
|
+
return;
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
// Use Case: If ended by Agent, stay chat in InActive state
|
|
@@ -37,8 +37,12 @@ var _htmlPlayerMiddleware = _interopRequireDefault(require("../../webchatcontain
|
|
|
37
37
|
var _htmlTextMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware"));
|
|
38
38
|
var _preProcessingMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/preProcessingMiddleware"));
|
|
39
39
|
var _sanitizationMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware"));
|
|
40
|
+
var _callActionMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/callActionMiddleware"));
|
|
41
|
+
var _customEventMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/customEventMiddleware"));
|
|
40
42
|
var _ConversationState = require("../../../contexts/common/ConversationState");
|
|
41
43
|
var _createReducer = require("../../../contexts/createReducer");
|
|
44
|
+
var _queueOverflowHandlerMiddleware = require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware");
|
|
45
|
+
var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
|
|
42
46
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
43
47
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
44
48
|
const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endChat) => {
|
|
@@ -117,7 +121,7 @@ const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endChat) =>
|
|
|
117
121
|
};
|
|
118
122
|
webChatStore = (0, _botframeworkWebchat.createStore)({},
|
|
119
123
|
//initial state
|
|
120
|
-
_preProcessingMiddleware.default, _attachmentProcessingMiddleware.default, (0, _attachmentUploadValidatorMiddleware.default)((_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : _state$domainStates$l.allowedFileExtensions, (_state$domainStates$l2 = state.domainStates.liveChatConfig) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.maxUploadFileSize, localizedTexts), (0, _channelDataMiddleware.default)(addConversationalSurveyTagsCallback), (0, _conversationEndMiddleware.default)(conversationEndCallback, startConversationalSurveyCallback, endConversationalSurveyCallback), (0, _dataMaskingMiddleware.default)((_state$domainStates$l3 = state.domainStates.liveChatConfig) === null || _state$domainStates$l3 === void 0 ? void 0 : _state$domainStates$l3.DataMaskingInfo), _messageTimestampMiddleware.createMessageTimeStampMiddleware, _messageSequenceIdOverrideMiddleware.createMessageSequenceIdOverrideMiddleware, _gifUploadMiddleware.default, _htmlPlayerMiddleware.default, (0, _htmlTextMiddleware.default)(honorsTargetInHTMLLinks), (0, _maxMessageSizeValidator.default)(localizedTexts), _sanitizationMiddleware.default,
|
|
124
|
+
_preProcessingMiddleware.default, _attachmentProcessingMiddleware.default, (0, _attachmentUploadValidatorMiddleware.default)((_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : _state$domainStates$l.allowedFileExtensions, (_state$domainStates$l2 = state.domainStates.liveChatConfig) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.maxUploadFileSize, localizedTexts), (0, _customEventMiddleware.default)(_omnichannelChatComponents.BroadcastService), (0, _queueOverflowHandlerMiddleware.createQueueOverflowMiddleware)(state, dispatch), (0, _channelDataMiddleware.default)(addConversationalSurveyTagsCallback), (0, _conversationEndMiddleware.default)(conversationEndCallback, startConversationalSurveyCallback, endConversationalSurveyCallback), (0, _dataMaskingMiddleware.default)((_state$domainStates$l3 = state.domainStates.liveChatConfig) === null || _state$domainStates$l3 === void 0 ? void 0 : _state$domainStates$l3.DataMaskingInfo), _messageTimestampMiddleware.createMessageTimeStampMiddleware, _messageSequenceIdOverrideMiddleware.createMessageSequenceIdOverrideMiddleware, _gifUploadMiddleware.default, _htmlPlayerMiddleware.default, (0, _htmlTextMiddleware.default)(honorsTargetInHTMLLinks), (0, _maxMessageSizeValidator.default)(localizedTexts), _sanitizationMiddleware.default, (0, _callActionMiddleware.default)(),
|
|
121
125
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
122
126
|
...(((_props$webChatContain7 = props.webChatContainerProps) === null || _props$webChatContain7 === void 0 ? void 0 : _props$webChatContain7.storeMiddlewares) ?? []));
|
|
123
127
|
_WebChatStoreLoader.WebChatStoreLoader.store = webChatStore;
|
|
@@ -12,6 +12,7 @@ var _PostChatSurveyMode = require("../../postchatsurveypanestateful/enums/PostCh
|
|
|
12
12
|
var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
|
|
13
13
|
var _utils = require("../../../common/utils");
|
|
14
14
|
var _liveChatConfigUtils = require("./liveChatConfigUtils");
|
|
15
|
+
var _createReducer = require("../../../contexts/createReducer");
|
|
15
16
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
17
|
let conversationDetails = undefined;
|
|
17
18
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -64,6 +65,13 @@ const renderSurvey = async (postChatContext, state, dispatch) => {
|
|
|
64
65
|
// Function for embed mode postchat workflow which is essentially same for both customer and agent
|
|
65
66
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
66
67
|
const embedModePostChatWorkflow = async (postChatContext, state, dispatch) => {
|
|
68
|
+
const inMemoryState = (0, _createReducer.executeReducer)(state, {
|
|
69
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
|
|
70
|
+
payload: null
|
|
71
|
+
});
|
|
72
|
+
if (inMemoryState.appStates.conversationState === _ConversationState.ConversationState.Closed) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
67
75
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
68
76
|
Event: _TelemetryConstants.TelemetryEvent.EmbedModePostChatWorkflowStarted
|
|
69
77
|
});
|
|
@@ -84,6 +92,13 @@ const embedModePostChatWorkflow = async (postChatContext, state, dispatch) => {
|
|
|
84
92
|
payload: _ConversationState.ConversationState.PostchatLoading
|
|
85
93
|
});
|
|
86
94
|
await (0, _utils.addDelayInMs)(_Constants.Constants.PostChatLoadingDurationInMs);
|
|
95
|
+
const inMemoryState = (0, _createReducer.executeReducer)(state, {
|
|
96
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
|
|
97
|
+
payload: null
|
|
98
|
+
});
|
|
99
|
+
if (inMemoryState.appStates.conversationState === _ConversationState.ConversationState.Closed) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
87
102
|
dispatch({
|
|
88
103
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
89
104
|
payload: _ConversationState.ConversationState.Postchat
|
|
@@ -102,6 +117,14 @@ const embedModePostChatWorkflow = async (postChatContext, state, dispatch) => {
|
|
|
102
117
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
103
118
|
const initiatePostChat = async (props, conversationDetailsParam, state, dispatch, postchatContext) => {
|
|
104
119
|
var _conversationDetails;
|
|
120
|
+
const inMemoryState = (0, _createReducer.executeReducer)(state, {
|
|
121
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
|
|
122
|
+
payload: null
|
|
123
|
+
});
|
|
124
|
+
if (inMemoryState.appStates.conversationState === _ConversationState.ConversationState.Closed) {
|
|
125
|
+
// If the conversation is closed, we need to reset the state
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
105
128
|
conversationDetails = conversationDetailsParam;
|
|
106
129
|
const participantType = ((_conversationDetails = conversationDetails) === null || _conversationDetails === void 0 ? void 0 : _conversationDetails.participantType) ?? postchatContext.participantType;
|
|
107
130
|
await setSurveyMode(props, participantType, state, dispatch);
|
|
@@ -154,7 +154,6 @@ const setPreChatAndInitiateChat = async (facadeChatSDK, dispatch, setAdapter, is
|
|
|
154
154
|
const optionalParams = {
|
|
155
155
|
isProactiveChat
|
|
156
156
|
};
|
|
157
|
-
(0, _FirstMessageTrackerFromBot.createTrackingForFirstMessage)();
|
|
158
157
|
await initStartChat(facadeChatSDK, dispatch, setAdapter, state, props, optionalParams);
|
|
159
158
|
};
|
|
160
159
|
|
|
@@ -206,6 +205,7 @@ const initStartChat = async (facadeChatSDK, dispatch, setAdapter, state, props,
|
|
|
206
205
|
const startChatOptionalParams = Object.assign({}, params, optionalParams, defaultOptionalParams);
|
|
207
206
|
// startTime is used to determine if a message is history or new, better to be set before creating the adapter to get bandwidth
|
|
208
207
|
const startTime = new Date().getTime();
|
|
208
|
+
(0, _FirstMessageTrackerFromBot.createTrackingForFirstMessage)();
|
|
209
209
|
await facadeChatSDK.startChat(startChatOptionalParams);
|
|
210
210
|
isStartChatSuccessful = true;
|
|
211
211
|
await createAdapterAndSubscribe(facadeChatSDK, dispatch, setAdapter, startTime, props);
|
|
@@ -57,6 +57,7 @@ var _startProactiveChat = require("../common/startProactiveChat");
|
|
|
57
57
|
var _useChatAdapterStore = _interopRequireDefault(require("../../../hooks/useChatAdapterStore"));
|
|
58
58
|
var _useChatContextStore = _interopRequireDefault(require("../../../hooks/useChatContextStore"));
|
|
59
59
|
var _useFacadeChatSDKStore = _interopRequireDefault(require("../../../hooks/useFacadeChatSDKStore"));
|
|
60
|
+
var _customEventHandler = require("../common/customEventHandler");
|
|
60
61
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
61
62
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
62
63
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -421,7 +422,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
421
422
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.StartChat).subscribe(msg => {
|
|
422
423
|
var _msg$payload5, _msg$payload6, _msg$payload7, _msg$payload9, _inMemoryState$appSta2, _inMemoryState$appSta3, _inMemoryState$appSta4;
|
|
423
424
|
// If chat is out of operating hours chat widget sets the conversation state to OutOfOffice.
|
|
424
|
-
if (state.appStates.outsideOperatingHours
|
|
425
|
+
if (state.appStates.outsideOperatingHours && state.appStates.conversationState !== _ConversationState.ConversationState.Active) {
|
|
425
426
|
dispatch({
|
|
426
427
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_MINIMIZED,
|
|
427
428
|
payload: false
|
|
@@ -588,6 +589,9 @@ const LiveChatWidgetStateful = props => {
|
|
|
588
589
|
}
|
|
589
590
|
});
|
|
590
591
|
|
|
592
|
+
// subscribe custom event
|
|
593
|
+
(0, _customEventHandler.subscribeToSendCustomEvent)(_omnichannelChatComponents.BroadcastService, facadeChatSDK, _customEventHandler.customEventCallback);
|
|
594
|
+
|
|
591
595
|
// Check for TPC and log in telemetry if blocked
|
|
592
596
|
(0, _defaultClientDataStoreProvider.isCookieAllowed)();
|
|
593
597
|
return () => {
|
|
@@ -186,7 +186,7 @@ const WebChatContainerStateful = props => {
|
|
|
186
186
|
}
|
|
187
187
|
|
|
188
188
|
.webchat__bubble__content>div#ms_lcw_webchat_adaptive_card .ac-textBlock {
|
|
189
|
-
color: ${(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : (_webChatContainerProp2 = webChatContainerProps.adaptiveCardStyles) === null || _webChatContainerProp2 === void 0 ? void 0 : _webChatContainerProp2.color) ?? _defaultAdaptiveCardStyles.defaultAdaptiveCardStyles.color}
|
|
189
|
+
color: ${(webChatContainerProps === null || webChatContainerProps === void 0 ? void 0 : (_webChatContainerProp2 = webChatContainerProps.adaptiveCardStyles) === null || _webChatContainerProp2 === void 0 ? void 0 : _webChatContainerProp2.color) ?? _defaultAdaptiveCardStyles.defaultAdaptiveCardStyles.color};
|
|
190
190
|
}
|
|
191
191
|
|
|
192
192
|
.webchat__stacked-layout__content div.webchat__stacked-layout__message-row div.webchat__bubble--from-user {
|
|
@@ -29,10 +29,12 @@ let DesignerChatAdapter = /*#__PURE__*/function (_MockAdapter) {
|
|
|
29
29
|
_this = _super.call(this);
|
|
30
30
|
setTimeout(() => {
|
|
31
31
|
(0, _chatAdapterUtils.postBotMessageActivity)(_this.activityObserver, "Thank you for contacting us! How can I help you today?", undefined, 0);
|
|
32
|
+
(0, _chatAdapterUtils.postBotMessageActivity)(_this.activityObserver, "Please accept terms and conditions to proceed. Visit the link for terms and conditions <a href=\"\">here</a>.", undefined, 0);
|
|
32
33
|
_this.postUserActivity("I need to change my address.", 0);
|
|
33
34
|
(0, _chatAdapterUtils.postBotMessageActivity)(_this.activityObserver, "Okay, let me connect you with a live agent.", undefined, 100);
|
|
34
35
|
(0, _chatAdapterUtils.postSystemMessageActivity)(_this.activityObserver, "John has joined the chat", 100);
|
|
35
|
-
(0, _chatAdapterUtils.
|
|
36
|
+
(0, _chatAdapterUtils.postAgentMessageActivity)(_this.activityObserver, "I'd be happy to help you update your account.", undefined, 100);
|
|
37
|
+
_this.postUserActivity("I have trouble visiting the signin page <a href=\"\">signin</a>.", 0);
|
|
36
38
|
}, 1000);
|
|
37
39
|
return _this;
|
|
38
40
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.postSystemMessageActivity = exports.postEchoActivity = exports.postBotTypingActivity = exports.postBotMessageActivity = exports.postBotAttachmentActivity = exports.customerUser = exports.botUser = void 0;
|
|
6
|
+
exports.postSystemMessageActivity = exports.postEchoActivity = exports.postBotTypingActivity = exports.postBotMessageActivity = exports.postBotAttachmentActivity = exports.postAgentMessageActivity = exports.customerUser = exports.botUser = exports.agentUser = void 0;
|
|
7
7
|
var _omnichannelChatSdk = require("@microsoft/omnichannel-chat-sdk");
|
|
8
8
|
const customerUser = {
|
|
9
9
|
id: "usedId",
|
|
@@ -16,9 +16,15 @@ const botUser = {
|
|
|
16
16
|
name: "Bot",
|
|
17
17
|
role: "bot"
|
|
18
18
|
};
|
|
19
|
+
exports.botUser = botUser;
|
|
20
|
+
const agentUser = {
|
|
21
|
+
id: "AgentId",
|
|
22
|
+
name: "John",
|
|
23
|
+
role: "bot"
|
|
24
|
+
};
|
|
19
25
|
|
|
20
26
|
// WebChat expects an "echo" activity to confirm the message has been sent successfully
|
|
21
|
-
exports.
|
|
27
|
+
exports.agentUser = agentUser;
|
|
22
28
|
const postEchoActivity = function (activityObserver, activity, user) {
|
|
23
29
|
let delay = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1000;
|
|
24
30
|
const echoActivity = {
|
|
@@ -54,6 +60,25 @@ const postBotMessageActivity = function (activityObserver, text) {
|
|
|
54
60
|
}, delay);
|
|
55
61
|
};
|
|
56
62
|
exports.postBotMessageActivity = postBotMessageActivity;
|
|
63
|
+
const postAgentMessageActivity = function (activityObserver, text) {
|
|
64
|
+
let tags = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
|
|
65
|
+
let delay = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1000;
|
|
66
|
+
setTimeout(() => {
|
|
67
|
+
activityObserver === null || activityObserver === void 0 ? void 0 : activityObserver.next({
|
|
68
|
+
id: (0, _omnichannelChatSdk.uuidv4)(),
|
|
69
|
+
from: {
|
|
70
|
+
...agentUser
|
|
71
|
+
},
|
|
72
|
+
text,
|
|
73
|
+
type: "message",
|
|
74
|
+
channelData: {
|
|
75
|
+
tags
|
|
76
|
+
},
|
|
77
|
+
timestamp: new Date().toISOString()
|
|
78
|
+
});
|
|
79
|
+
}, delay);
|
|
80
|
+
};
|
|
81
|
+
exports.postAgentMessageActivity = postAgentMessageActivity;
|
|
57
82
|
const postSystemMessageActivity = function (activityObserver, text) {
|
|
58
83
|
let delay = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1000;
|
|
59
84
|
postBotMessageActivity(activityObserver, text, "system", delay);
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _WebChatActionType = require("../../enums/WebChatActionType");
|
|
8
|
+
/******
|
|
9
|
+
* CallActionMiddleware
|
|
10
|
+
*
|
|
11
|
+
* Intercepts custom call actions and handles tel: URL navigation
|
|
12
|
+
******/
|
|
13
|
+
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
|
|
15
|
+
const createCallActionMiddleware = () => () => next => action => {
|
|
16
|
+
// Intercept incoming activities to modify suggested actions with call type
|
|
17
|
+
if (action.type === _WebChatActionType.WebChatActionType.DIRECT_LINE_INCOMING_ACTIVITY) {
|
|
18
|
+
var _action$payload, _activity$suggestedAc;
|
|
19
|
+
const activity = (_action$payload = action.payload) === null || _action$payload === void 0 ? void 0 : _action$payload.activity;
|
|
20
|
+
|
|
21
|
+
// Check if activity has suggested actions with call type
|
|
22
|
+
if (activity !== null && activity !== void 0 && (_activity$suggestedAc = activity.suggestedActions) !== null && _activity$suggestedAc !== void 0 && _activity$suggestedAc.actions) {
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
24
|
+
activity.suggestedActions.actions = activity.suggestedActions.actions.map(suggestedAction => {
|
|
25
|
+
if (suggestedAction.type === "call") {
|
|
26
|
+
// Convert call action to openUrl with encoded tel URL scheme
|
|
27
|
+
const telUrl = suggestedAction.value;
|
|
28
|
+
const convertedAction = {
|
|
29
|
+
...suggestedAction,
|
|
30
|
+
type: "openUrl",
|
|
31
|
+
value: `tel:${telUrl}`
|
|
32
|
+
};
|
|
33
|
+
return convertedAction;
|
|
34
|
+
}
|
|
35
|
+
return suggestedAction;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return next(action);
|
|
40
|
+
};
|
|
41
|
+
var _default = createCallActionMiddleware;
|
|
42
|
+
exports.default = _default;
|