@microsoft/omnichannel-chat-widget 1.7.3-main.112d01b → 1.7.3-main.3609616
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/lib/cjs/common/telemetry/TelemetryConstants.js +2 -0
- package/lib/cjs/components/livechatwidget/LiveChatWidget.js +6 -1
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +15 -6
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/HiddenAdaptiveCardActivitySubscriber.js +77 -0
- package/lib/cjs/components/livechatwidget/common/createAdapter.js +15 -2
- package/lib/cjs/components/livechatwidget/common/endChat.js +20 -5
- package/lib/cjs/components/livechatwidget/common/getMockChatSDKIfApplicable.js +26 -0
- package/lib/cjs/components/livechatwidget/common/overridePropsOnMockIfApplicable.js +41 -0
- package/lib/cjs/components/livechatwidget/common/startChat.js +37 -28
- package/lib/cjs/components/livechatwidget/common/startChatErrorHandler.js +6 -6
- package/lib/cjs/components/livechatwidget/common/updateSessionDataForTelemetry.js +8 -3
- package/lib/cjs/components/livechatwidget/interfaces/IBotAuthActivitySubscriberOptionalParams.js +1 -0
- package/lib/cjs/components/livechatwidget/interfaces/IMockProps.js +7 -0
- package/lib/cjs/components/webchatcontainerstateful/common/DemoChatAdapter.js +87 -0
- package/lib/cjs/components/webchatcontainerstateful/common/DemoChatSDK.js +17 -0
- package/lib/cjs/components/webchatcontainerstateful/common/DesignerChatAdapter.js +41 -0
- package/lib/cjs/components/webchatcontainerstateful/common/DesignerChatSDK.js +17 -0
- package/lib/cjs/components/webchatcontainerstateful/common/MockBotCardCommandType.js +14 -0
- package/lib/cjs/components/webchatcontainerstateful/common/MockBotCommand.js +19 -0
- package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +3 -0
- package/lib/cjs/components/webchatcontainerstateful/common/utils/attachmentActivityUtils.js +71 -0
- package/lib/cjs/components/webchatcontainerstateful/common/utils/chatAdapterUtils.js +90 -0
- package/lib/cjs/components/webchatcontainerstateful/interfaces/IBotAuthConfig.js +1 -0
- package/lib/cjs/plugins/newMessageEventHandler.js +4 -2
- package/lib/esm/common/telemetry/TelemetryConstants.js +2 -0
- package/lib/esm/components/livechatwidget/LiveChatWidget.js +6 -1
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +15 -6
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/HiddenAdaptiveCardActivitySubscriber.js +70 -0
- package/lib/esm/components/livechatwidget/common/createAdapter.js +14 -2
- package/lib/esm/components/livechatwidget/common/endChat.js +20 -5
- package/lib/esm/components/livechatwidget/common/getMockChatSDKIfApplicable.js +20 -0
- package/lib/esm/components/livechatwidget/common/overridePropsOnMockIfApplicable.js +34 -0
- package/lib/esm/components/livechatwidget/common/startChat.js +37 -28
- package/lib/esm/components/livechatwidget/common/startChatErrorHandler.js +7 -7
- package/lib/esm/components/livechatwidget/common/updateSessionDataForTelemetry.js +7 -2
- package/lib/esm/components/livechatwidget/interfaces/IBotAuthActivitySubscriberOptionalParams.js +1 -0
- package/lib/esm/components/livechatwidget/interfaces/IMockProps.js +6 -0
- package/lib/esm/components/webchatcontainerstateful/common/DemoChatAdapter.js +79 -0
- package/lib/esm/components/webchatcontainerstateful/common/DemoChatSDK.js +10 -0
- package/lib/esm/components/webchatcontainerstateful/common/DesignerChatAdapter.js +33 -0
- package/lib/esm/components/webchatcontainerstateful/common/DesignerChatSDK.js +10 -0
- package/lib/esm/components/webchatcontainerstateful/common/MockBotCardCommandType.js +7 -0
- package/lib/esm/components/webchatcontainerstateful/common/MockBotCommand.js +12 -0
- package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +3 -0
- package/lib/esm/components/webchatcontainerstateful/common/utils/attachmentActivityUtils.js +61 -0
- package/lib/esm/components/webchatcontainerstateful/common/utils/chatAdapterUtils.js +77 -0
- package/lib/esm/components/webchatcontainerstateful/interfaces/IBotAuthConfig.js +1 -0
- package/lib/esm/plugins/newMessageEventHandler.js +4 -2
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +3 -1
- package/lib/types/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.d.ts +4 -1
- package/lib/types/components/livechatwidget/common/ActivitySubscriber/HiddenAdaptiveCardActivitySubscriber.d.ts +7 -0
- package/lib/types/components/livechatwidget/common/createAdapter.d.ts +2 -1
- package/lib/types/components/livechatwidget/common/getMockChatSDKIfApplicable.d.ts +1 -0
- package/lib/types/components/livechatwidget/common/overridePropsOnMockIfApplicable.d.ts +3 -0
- package/lib/types/components/livechatwidget/common/updateSessionDataForTelemetry.d.ts +1 -1
- package/lib/types/components/livechatwidget/interfaces/IBotAuthActivitySubscriberOptionalParams.d.ts +4 -0
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +2 -0
- package/lib/types/components/livechatwidget/interfaces/IMockProps.d.ts +8 -0
- package/lib/types/components/webchatcontainerstateful/common/DemoChatAdapter.d.ts +10 -0
- package/lib/types/components/webchatcontainerstateful/common/DemoChatSDK.d.ts +6 -0
- package/lib/types/components/webchatcontainerstateful/common/DesignerChatAdapter.d.ts +8 -0
- package/lib/types/components/webchatcontainerstateful/common/DesignerChatSDK.d.ts +6 -0
- package/lib/types/components/webchatcontainerstateful/common/MockBotCardCommandType.d.ts +6 -0
- package/lib/types/components/webchatcontainerstateful/common/MockBotCommand.d.ts +11 -0
- package/lib/types/components/webchatcontainerstateful/common/mockadapter.d.ts +2 -1
- package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +6 -0
- package/lib/types/components/webchatcontainerstateful/common/utils/attachmentActivityUtils.d.ts +9 -0
- package/lib/types/components/webchatcontainerstateful/common/utils/chatAdapterUtils.d.ts +9 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IBotAuthConfig.d.ts +4 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts +2 -0
- package/package.json +3 -3
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.DesignerChatAdapter = void 0;
|
|
7
|
+
var _Observable = require("rxjs/Observable");
|
|
8
|
+
var _mockadapter = _interopRequireDefault(require("./mockadapter"));
|
|
9
|
+
var _chatAdapterUtils = require("./utils/chatAdapterUtils");
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
class DesignerChatAdapter extends _mockadapter.default {
|
|
12
|
+
constructor() {
|
|
13
|
+
super();
|
|
14
|
+
setTimeout(() => {
|
|
15
|
+
(0, _chatAdapterUtils.postBotMessageActivity)(this.activityObserver, "Id venenatis a condimentum vitae?", undefined, 0);
|
|
16
|
+
this.postUserActivity("Diam donec adipiscing tristique risus nec feugiat in fermentum", 0);
|
|
17
|
+
(0, _chatAdapterUtils.postSystemMessageActivity)(this.activityObserver, "We are finding the best agent for your inquiry, please hold ...", 100);
|
|
18
|
+
(0, _chatAdapterUtils.postSystemMessageActivity)(this.activityObserver, "John has joined the chat", 100);
|
|
19
|
+
(0, _chatAdapterUtils.postBotMessageActivity)(this.activityObserver, "Neque viverra justo nec ultrices dui sapien eget mi proin", undefined, 100);
|
|
20
|
+
}, 1000);
|
|
21
|
+
}
|
|
22
|
+
postUserActivity(text) {
|
|
23
|
+
let delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1000;
|
|
24
|
+
setTimeout(() => {
|
|
25
|
+
(0, _chatAdapterUtils.postEchoActivity)(this.activityObserver, {
|
|
26
|
+
text,
|
|
27
|
+
from: {
|
|
28
|
+
..._chatAdapterUtils.customerUser
|
|
29
|
+
},
|
|
30
|
+
type: "message"
|
|
31
|
+
}, _chatAdapterUtils.customerUser, 0);
|
|
32
|
+
}, delay);
|
|
33
|
+
}
|
|
34
|
+
postActivity(activity) {
|
|
35
|
+
if (activity) {
|
|
36
|
+
(0, _chatAdapterUtils.postEchoActivity)(this.activityObserver, activity, _chatAdapterUtils.customerUser);
|
|
37
|
+
}
|
|
38
|
+
return _Observable.Observable.of(activity.id || "");
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.DesignerChatAdapter = DesignerChatAdapter;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.DesignerChatSDK = void 0;
|
|
7
|
+
var _DesignerChatAdapter = require("./DesignerChatAdapter");
|
|
8
|
+
var _mockchatsdk = require("./mockchatsdk");
|
|
9
|
+
class DesignerChatSDK extends _mockchatsdk.MockChatSDK {
|
|
10
|
+
constructor() {
|
|
11
|
+
super();
|
|
12
|
+
}
|
|
13
|
+
createChatAdapter() {
|
|
14
|
+
return new _DesignerChatAdapter.DesignerChatAdapter();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.DesignerChatSDK = DesignerChatSDK;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var MockBotCardCommandType;
|
|
8
|
+
(function (MockBotCardCommandType) {
|
|
9
|
+
MockBotCardCommandType["Hero"] = "hero";
|
|
10
|
+
MockBotCardCommandType["Signin"] = "signin";
|
|
11
|
+
MockBotCardCommandType["Thumbnail"] = "thumbnail";
|
|
12
|
+
})(MockBotCardCommandType || (MockBotCardCommandType = {}));
|
|
13
|
+
var _default = MockBotCardCommandType;
|
|
14
|
+
exports.default = _default;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var MockBotCommand;
|
|
8
|
+
(function (MockBotCommand) {
|
|
9
|
+
MockBotCommand["Bot"] = "/bot";
|
|
10
|
+
MockBotCommand["Card"] = "/card";
|
|
11
|
+
MockBotCommand["Help"] = "/help";
|
|
12
|
+
MockBotCommand["SendAttachment"] = "send attachment";
|
|
13
|
+
MockBotCommand["SendBotMessage"] = "send bot message";
|
|
14
|
+
MockBotCommand["SendSystemMessage"] = "send system message";
|
|
15
|
+
MockBotCommand["SendTyping"] = "send typing";
|
|
16
|
+
MockBotCommand["System"] = "/system";
|
|
17
|
+
})(MockBotCommand || (MockBotCommand = {}));
|
|
18
|
+
var _default = MockBotCommand;
|
|
19
|
+
exports.default = _default;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createThumbnailCardAttachment = exports.createSigninCardAttachment = exports.createJpgFileAttachment = exports.createHeroCardAttachment = void 0;
|
|
7
|
+
const createJpgFileAttachment = () => {
|
|
8
|
+
return {
|
|
9
|
+
contentType: "image/jpeg",
|
|
10
|
+
name: "600x400.jpg",
|
|
11
|
+
contentUrl: "https://raw.githubusercontent.com/microsoft/omnichannel-chat-sdk/e7e75d4ede351e1cf2e52f13860d2284848c4af0/playwright/public/images/600x400.jpg"
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
exports.createJpgFileAttachment = createJpgFileAttachment;
|
|
15
|
+
const createHeroCardAttachment = () => {
|
|
16
|
+
return {
|
|
17
|
+
contentType: "application/vnd.microsoft.card.hero",
|
|
18
|
+
content: {
|
|
19
|
+
buttons: [{
|
|
20
|
+
title: "Bellevue",
|
|
21
|
+
type: "imBack",
|
|
22
|
+
value: "Bellevue"
|
|
23
|
+
}, {
|
|
24
|
+
title: "Redmond",
|
|
25
|
+
type: "imBack",
|
|
26
|
+
value: "Redmond"
|
|
27
|
+
}, {
|
|
28
|
+
title: "Seattle",
|
|
29
|
+
type: "imBack",
|
|
30
|
+
value: "Seattle"
|
|
31
|
+
}],
|
|
32
|
+
title: "Choose your location"
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
exports.createHeroCardAttachment = createHeroCardAttachment;
|
|
37
|
+
const createThumbnailCardAttachment = () => {
|
|
38
|
+
return {
|
|
39
|
+
contentType: "application/vnd.microsoft.card.thumbnail",
|
|
40
|
+
content: {
|
|
41
|
+
title: "Microsoft",
|
|
42
|
+
subtitle: "Our mission is to empower every person and every organization on the planet to achieve more.",
|
|
43
|
+
text: "Microsoft creates platforms and tools powered by AI to deliver innovative solutions that meet the evolving needs of our customers. The technology company is committed to making AI available broadly and doing so responsibly, with a mission to empower every person and every organization on the planet to achieve more.",
|
|
44
|
+
images: [{
|
|
45
|
+
alt: "Microsoft logo",
|
|
46
|
+
url: "https://img-prod-cms-rt-microsoft-com.akamaized.net/cms/api/am/imageFileData/RE1Mu3b?ver=5c31" // logo from https://microsoft.com
|
|
47
|
+
}],
|
|
48
|
+
|
|
49
|
+
buttons: [{
|
|
50
|
+
title: "Learn more",
|
|
51
|
+
type: "openUrl",
|
|
52
|
+
value: "https://www.microsoft.com/"
|
|
53
|
+
}]
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
exports.createThumbnailCardAttachment = createThumbnailCardAttachment;
|
|
58
|
+
const createSigninCardAttachment = () => {
|
|
59
|
+
return {
|
|
60
|
+
contentType: "application/vnd.microsoft.card.signin",
|
|
61
|
+
content: {
|
|
62
|
+
text: "Please login",
|
|
63
|
+
buttons: [{
|
|
64
|
+
type: "signin",
|
|
65
|
+
title: "Signin",
|
|
66
|
+
value: "https://login.live.com/"
|
|
67
|
+
}]
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
exports.createSigninCardAttachment = createSigninCardAttachment;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.postSystemMessageActivity = exports.postEchoActivity = exports.postBotTypingActivity = exports.postBotMessageActivity = exports.postBotAttachmentActivity = exports.customerUser = exports.botUser = void 0;
|
|
7
|
+
var _omnichannelChatSdk = require("@microsoft/omnichannel-chat-sdk");
|
|
8
|
+
const customerUser = {
|
|
9
|
+
id: "usedId",
|
|
10
|
+
name: "User",
|
|
11
|
+
role: "user"
|
|
12
|
+
};
|
|
13
|
+
exports.customerUser = customerUser;
|
|
14
|
+
const botUser = {
|
|
15
|
+
id: "botId",
|
|
16
|
+
name: "Bot",
|
|
17
|
+
role: "bot"
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
// WebChat expects an "echo" activity to confirm the message has been sent successfully
|
|
21
|
+
exports.botUser = botUser;
|
|
22
|
+
const postEchoActivity = function (activityObserver, activity, user) {
|
|
23
|
+
let delay = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1000;
|
|
24
|
+
const echoActivity = {
|
|
25
|
+
...activity,
|
|
26
|
+
id: (0, _omnichannelChatSdk.uuidv4)(),
|
|
27
|
+
from: {
|
|
28
|
+
...activity.from,
|
|
29
|
+
...user
|
|
30
|
+
},
|
|
31
|
+
timestamp: new Date().toISOString()
|
|
32
|
+
};
|
|
33
|
+
setTimeout(() => {
|
|
34
|
+
activityObserver === null || activityObserver === void 0 ? void 0 : activityObserver.next(echoActivity); // mock message sent activity
|
|
35
|
+
}, delay);
|
|
36
|
+
};
|
|
37
|
+
exports.postEchoActivity = postEchoActivity;
|
|
38
|
+
const postBotMessageActivity = function (activityObserver, text) {
|
|
39
|
+
let tags = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
|
|
40
|
+
let delay = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1000;
|
|
41
|
+
setTimeout(() => {
|
|
42
|
+
activityObserver === null || activityObserver === void 0 ? void 0 : activityObserver.next({
|
|
43
|
+
id: (0, _omnichannelChatSdk.uuidv4)(),
|
|
44
|
+
from: {
|
|
45
|
+
...botUser
|
|
46
|
+
},
|
|
47
|
+
text,
|
|
48
|
+
type: "message",
|
|
49
|
+
channelData: {
|
|
50
|
+
tags
|
|
51
|
+
},
|
|
52
|
+
timestamp: new Date().toISOString()
|
|
53
|
+
});
|
|
54
|
+
}, delay);
|
|
55
|
+
};
|
|
56
|
+
exports.postBotMessageActivity = postBotMessageActivity;
|
|
57
|
+
const postSystemMessageActivity = function (activityObserver, text) {
|
|
58
|
+
let delay = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1000;
|
|
59
|
+
postBotMessageActivity(activityObserver, text, "system", delay);
|
|
60
|
+
};
|
|
61
|
+
exports.postSystemMessageActivity = postSystemMessageActivity;
|
|
62
|
+
const postBotTypingActivity = function (activityObserver) {
|
|
63
|
+
let delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1000;
|
|
64
|
+
setTimeout(() => {
|
|
65
|
+
activityObserver === null || activityObserver === void 0 ? void 0 : activityObserver.next({
|
|
66
|
+
id: (0, _omnichannelChatSdk.uuidv4)(),
|
|
67
|
+
from: {
|
|
68
|
+
...botUser
|
|
69
|
+
},
|
|
70
|
+
type: "typing"
|
|
71
|
+
});
|
|
72
|
+
}, delay);
|
|
73
|
+
};
|
|
74
|
+
exports.postBotTypingActivity = postBotTypingActivity;
|
|
75
|
+
const postBotAttachmentActivity = function (activityObserver) {
|
|
76
|
+
let attachments = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
77
|
+
let delay = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1000;
|
|
78
|
+
setTimeout(() => {
|
|
79
|
+
activityObserver === null || activityObserver === void 0 ? void 0 : activityObserver.next({
|
|
80
|
+
id: (0, _omnichannelChatSdk.uuidv4)(),
|
|
81
|
+
from: {
|
|
82
|
+
...botUser
|
|
83
|
+
},
|
|
84
|
+
attachments,
|
|
85
|
+
type: "message",
|
|
86
|
+
timestamp: new Date().toISOString()
|
|
87
|
+
});
|
|
88
|
+
}, delay);
|
|
89
|
+
};
|
|
90
|
+
exports.postBotAttachmentActivity = postBotAttachmentActivity;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -20,7 +20,7 @@ const createOnNewAdapterActivityHandler = (chatId, userId) => {
|
|
|
20
20
|
const raiseMessageEvent = (activity, isHistoryMessage) => {
|
|
21
21
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
22
|
const polyfillMessagePayloadForEvent = payload => {
|
|
23
|
-
var _activity$conversatio, _TelemetryManager$Int;
|
|
23
|
+
var _activity$conversatio, _TelemetryManager$Int, _attachments;
|
|
24
24
|
return {
|
|
25
25
|
...payload,
|
|
26
26
|
channelData: activity === null || activity === void 0 ? void 0 : activity.channelData,
|
|
@@ -29,7 +29,9 @@ const createOnNewAdapterActivityHandler = (chatId, userId) => {
|
|
|
29
29
|
id: activity === null || activity === void 0 ? void 0 : activity.id,
|
|
30
30
|
isChatComplete: false,
|
|
31
31
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
32
|
-
text: activity === null || activity === void 0 ? void 0 : activity.text
|
|
32
|
+
text: activity === null || activity === void 0 ? void 0 : activity.text,
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
34
|
+
attachment: (activity === null || activity === void 0 ? void 0 : (_attachments = activity.attachments) === null || _attachments === void 0 ? void 0 : _attachments.length) >= 1 ? activity === null || activity === void 0 ? void 0 : activity.attachments : []
|
|
33
35
|
};
|
|
34
36
|
};
|
|
35
37
|
if ((activity === null || activity === void 0 ? void 0 : activity.type) === _Constants.Constants.message) {
|
|
@@ -95,6 +95,7 @@ export let TelemetryEvent;
|
|
|
95
95
|
TelemetryEvent["GetConversationDetailsCallStarted"] = "GetConversationDetailsCallStarted";
|
|
96
96
|
TelemetryEvent["GetConversationDetailsCallFailed"] = "GetConversationDetailsCallFailed";
|
|
97
97
|
TelemetryEvent["EndChatSDKCallFailed"] = "EndChatSDKCallFailed";
|
|
98
|
+
TelemetryEvent["DisconnectEndChatSDKCallFailed"] = "DisconnectEndChatSDKCallFailed";
|
|
98
99
|
TelemetryEvent["GetChatReconnectContextSDKCallStarted"] = "GetChatReconnectContextSDKCallStarted";
|
|
99
100
|
TelemetryEvent["GetChatReconnectContextSDKCallFailed"] = "GetChatReconnectContextSDKCallFailed";
|
|
100
101
|
TelemetryEvent["ParseAdaptiveCardFailed"] = "ParseAdaptiveCardFailed";
|
|
@@ -208,6 +209,7 @@ export let TelemetryEvent;
|
|
|
208
209
|
TelemetryEvent["PostChatSurveyLoadingPaneLoaded"] = "PostChatSurveyLoadingPaneLoaded";
|
|
209
210
|
TelemetryEvent["PostChatSurveyLoaded"] = "PostChatSurveyLoaded";
|
|
210
211
|
TelemetryEvent["ChatDisconnectThreadEventReceived"] = "ChatDisconnectThreadEventReceived";
|
|
212
|
+
TelemetryEvent["HiddenAdaptiveCardMessageReceived"] = "HiddenAdaptiveCardMessageReceived";
|
|
211
213
|
})(TelemetryEvent || (TelemetryEvent = {}));
|
|
212
214
|
export class TelemetryConstants {
|
|
213
215
|
static map(eventTypeOrScenarioType) {
|
|
@@ -5,13 +5,18 @@ import { ChatSDKStore } from "../../contexts/ChatSDKStore";
|
|
|
5
5
|
import LiveChatWidgetStateful from "./livechatwidgetstateful/LiveChatWidgetStateful";
|
|
6
6
|
import { createReducer } from "../../contexts/createReducer";
|
|
7
7
|
import { getLiveChatWidgetContextInitialState } from "../../contexts/common/LiveChatWidgetContextInitialState";
|
|
8
|
+
import { getMockChatSDKIfApplicable } from "./common/getMockChatSDKIfApplicable";
|
|
9
|
+
import overridePropsOnMockIfApplicable from "./common/overridePropsOnMockIfApplicable";
|
|
8
10
|
export const LiveChatWidget = props => {
|
|
11
|
+
var _props$mock;
|
|
9
12
|
const reducer = createReducer();
|
|
10
13
|
const [state, dispatch] = useReducer(reducer, getLiveChatWidgetContextInitialState(props));
|
|
11
14
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
15
|
const [adapter, setAdapter] = useState(undefined);
|
|
16
|
+
const chatSDK = getMockChatSDKIfApplicable(props.chatSDK, props === null || props === void 0 ? void 0 : (_props$mock = props.mock) === null || _props$mock === void 0 ? void 0 : _props$mock.type);
|
|
17
|
+
overridePropsOnMockIfApplicable(props);
|
|
13
18
|
return /*#__PURE__*/React.createElement(ChatSDKStore.Provider, {
|
|
14
|
-
value:
|
|
19
|
+
value: chatSDK
|
|
15
20
|
}, /*#__PURE__*/React.createElement(ChatAdapterStore.Provider, {
|
|
16
21
|
value: [adapter, setAdapter]
|
|
17
22
|
}, /*#__PURE__*/React.createElement(ChatContextStore.Provider, {
|
package/lib/esm/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js
CHANGED
|
@@ -9,8 +9,6 @@ import { TelemetryHelper } from "../../../../common/telemetry/TelemetryHelper";
|
|
|
9
9
|
const supportedSignInCardContentTypes = ["application/vnd.microsoft.card.signin", "application/vnd.microsoft.card.oauth"];
|
|
10
10
|
const botOauthUrlRegex = /[\S]+.botframework.com\/api\/oauth\/signin\?signin=([\S]+)/;
|
|
11
11
|
const delay = t => new Promise(resolve => setTimeout(resolve, t));
|
|
12
|
-
const fetchBotAuthConfigRetries = 3;
|
|
13
|
-
const fetchBotAuthConfigRetryInterval = 1000;
|
|
14
12
|
let response;
|
|
15
13
|
const extractSignInId = signInUrl => {
|
|
16
14
|
const result = botOauthUrlRegex.exec(signInUrl);
|
|
@@ -39,7 +37,7 @@ const extractSasUrl = async attachment => {
|
|
|
39
37
|
}
|
|
40
38
|
return sasUrl;
|
|
41
39
|
};
|
|
42
|
-
const fetchBotAuthConfig = async retries => {
|
|
40
|
+
const fetchBotAuthConfig = async (retries, interval) => {
|
|
43
41
|
TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
|
|
44
42
|
Event: TelemetryEvent.SetBotAuthProviderFetchConfig
|
|
45
43
|
});
|
|
@@ -60,14 +58,25 @@ const fetchBotAuthConfig = async retries => {
|
|
|
60
58
|
// Base Case
|
|
61
59
|
throw new Error();
|
|
62
60
|
}
|
|
63
|
-
await delay(
|
|
64
|
-
return await fetchBotAuthConfig(--retries);
|
|
61
|
+
await delay(interval);
|
|
62
|
+
return await fetchBotAuthConfig(--retries, interval);
|
|
65
63
|
};
|
|
66
64
|
export class BotAuthActivitySubscriber {
|
|
67
65
|
constructor() {
|
|
66
|
+
let optionalParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
68
67
|
_defineProperty(this, "observer", void 0);
|
|
69
68
|
_defineProperty(this, "signInCardSeen", void 0);
|
|
69
|
+
_defineProperty(this, "fetchBotAuthConfigRetries", void 0);
|
|
70
|
+
_defineProperty(this, "fetchBotAuthConfigRetryInterval", void 0);
|
|
70
71
|
this.signInCardSeen = new Set();
|
|
72
|
+
this.fetchBotAuthConfigRetries = 3;
|
|
73
|
+
this.fetchBotAuthConfigRetryInterval = 1000;
|
|
74
|
+
if (optionalParams.fetchBotAuthConfigRetries) {
|
|
75
|
+
this.fetchBotAuthConfigRetries = optionalParams.fetchBotAuthConfigRetries;
|
|
76
|
+
}
|
|
77
|
+
if (optionalParams.fetchBotAuthConfigRetryInterval) {
|
|
78
|
+
this.fetchBotAuthConfigRetryInterval = optionalParams.fetchBotAuthConfigRetryInterval;
|
|
79
|
+
}
|
|
71
80
|
}
|
|
72
81
|
applicable(activity) {
|
|
73
82
|
var _activity$attachments;
|
|
@@ -106,7 +115,7 @@ export class BotAuthActivitySubscriber {
|
|
|
106
115
|
BroadcastService.postMessage(event);
|
|
107
116
|
}
|
|
108
117
|
try {
|
|
109
|
-
const response = await fetchBotAuthConfig(fetchBotAuthConfigRetries);
|
|
118
|
+
const response = await fetchBotAuthConfig(this.fetchBotAuthConfigRetries, this.fetchBotAuthConfigRetryInterval);
|
|
110
119
|
if (response === false) {
|
|
111
120
|
TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
|
|
112
121
|
Event: TelemetryEvent.SetBotAuthProviderHideCard
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
3
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
4
|
+
import { Constants } from "../../../../common/Constants";
|
|
5
|
+
import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../../common/telemetry/TelemetryConstants";
|
|
6
|
+
import { TelemetryHelper } from "../../../../common/telemetry/TelemetryHelper";
|
|
7
|
+
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
8
|
+
export class HiddenAdaptiveCardActivitySubscriber {
|
|
9
|
+
constructor() {
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11
|
+
_defineProperty(this, "observer", void 0);
|
|
12
|
+
}
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
|
+
async apply(activity) {
|
|
15
|
+
const {
|
|
16
|
+
attachments,
|
|
17
|
+
attachment
|
|
18
|
+
} = activity;
|
|
19
|
+
this.observer.next(false);
|
|
20
|
+
BroadcastService.postMessage({
|
|
21
|
+
eventName: BroadcastEvent.NewMessageReceived,
|
|
22
|
+
payload: {
|
|
23
|
+
attachments: attachments || [attachment],
|
|
24
|
+
text: "Custom Event"
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
|
|
31
|
+
applicable(activity) {
|
|
32
|
+
const {
|
|
33
|
+
attachments,
|
|
34
|
+
attachment
|
|
35
|
+
} = activity;
|
|
36
|
+
|
|
37
|
+
// Use `attachments` or `attachment` (whichever exists)
|
|
38
|
+
const cards = attachments || [attachment];
|
|
39
|
+
|
|
40
|
+
// Check if contentType is "AdaptiveCard"
|
|
41
|
+
const adaptiveCard = cards === null || cards === void 0 ? void 0 : cards.find(
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
43
|
+
item => Constants.supportedAdaptiveCardContentTypes.indexOf(item === null || item === void 0 ? void 0 : item.contentType) >= 0);
|
|
44
|
+
if (adaptiveCard && adaptiveCard.content) {
|
|
45
|
+
const {
|
|
46
|
+
body
|
|
47
|
+
} = adaptiveCard.content;
|
|
48
|
+
if (Array.isArray(body)) {
|
|
49
|
+
// Check if all elements in `body` have `isVisible: false`
|
|
50
|
+
const allInvisible = body.every(item => item.isVisible === false);
|
|
51
|
+
if (allInvisible) {
|
|
52
|
+
TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
|
|
53
|
+
Event: TelemetryEvent.HiddenAdaptiveCardMessageReceived,
|
|
54
|
+
Description: "All elements in AdaptiveCard are invisible"
|
|
55
|
+
});
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
64
|
+
async next(activity) {
|
|
65
|
+
if (this.applicable(activity)) {
|
|
66
|
+
return await this.apply(activity);
|
|
67
|
+
}
|
|
68
|
+
return activity;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -5,9 +5,14 @@ import { defaultMiddlewareLocalizedTexts } from "../../webchatcontainerstateful/
|
|
|
5
5
|
import { ChatAdapterShim } from "./ChatAdapterShim";
|
|
6
6
|
import { PauseActivitySubscriber } from "./ActivitySubscriber/PauseActivitySubscriber";
|
|
7
7
|
import { BotAuthActivitySubscriber } from "./ActivitySubscriber/BotAuthActivitySubscriber";
|
|
8
|
+
import { HiddenAdaptiveCardActivitySubscriber } from "./ActivitySubscriber/HiddenAdaptiveCardActivitySubscriber";
|
|
9
|
+
const defaultBotAuthConfig = {
|
|
10
|
+
fetchBotAuthConfigRetries: 3,
|
|
11
|
+
fetchBotAuthConfigRetryInterval: 1000
|
|
12
|
+
};
|
|
8
13
|
|
|
9
14
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
|
-
export const createAdapter = async chatSDK => {
|
|
15
|
+
export const createAdapter = async (chatSDK, props) => {
|
|
11
16
|
const chatAdapterOptionalParams = {
|
|
12
17
|
IC3Adapter: {
|
|
13
18
|
options: {
|
|
@@ -33,9 +38,16 @@ export const createAdapter = async chatSDK => {
|
|
|
33
38
|
let adapter = await chatSDK.createChatAdapter(chatAdapterOptionalParams);
|
|
34
39
|
//so far, there is no need to convert to the shim adapter when using visual tests
|
|
35
40
|
if (chatSDK.isMockModeOn !== true) {
|
|
41
|
+
var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _props$webChatContain4;
|
|
42
|
+
const botAuthActivitySubscriberOptionalParams = {
|
|
43
|
+
fetchBotAuthConfigRetries: (props === null || props === void 0 ? void 0 : (_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : (_props$webChatContain2 = _props$webChatContain.botAuthConfig) === null || _props$webChatContain2 === void 0 ? void 0 : _props$webChatContain2.fetchBotAuthConfigRetries) || defaultBotAuthConfig.fetchBotAuthConfigRetries,
|
|
44
|
+
fetchBotAuthConfigRetryInterval: (props === null || props === void 0 ? void 0 : (_props$webChatContain3 = props.webChatContainerProps) === null || _props$webChatContain3 === void 0 ? void 0 : (_props$webChatContain4 = _props$webChatContain3.botAuthConfig) === null || _props$webChatContain4 === void 0 ? void 0 : _props$webChatContain4.fetchBotAuthConfigRetryInterval) || defaultBotAuthConfig.fetchBotAuthConfigRetryInterval
|
|
45
|
+
};
|
|
36
46
|
adapter = new ChatAdapterShim(adapter);
|
|
37
47
|
adapter.addSubscriber(new PauseActivitySubscriber());
|
|
38
|
-
adapter.addSubscriber(new BotAuthActivitySubscriber());
|
|
48
|
+
adapter.addSubscriber(new BotAuthActivitySubscriber(botAuthActivitySubscriberOptionalParams));
|
|
49
|
+
// Remove this code after ICM ID:544623085 is fixed
|
|
50
|
+
adapter.addSubscriber(new HiddenAdaptiveCardActivitySubscriber());
|
|
39
51
|
return adapter.chatAdapter;
|
|
40
52
|
}
|
|
41
53
|
return adapter;
|
|
@@ -135,12 +135,27 @@ const endChat = async (props, chatSDK, state, dispatch, setAdapter, setWebChatSt
|
|
|
135
135
|
await handleAuthentication(chatSDK, props.chatConfig, props.getAuthToken);
|
|
136
136
|
await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.endChat());
|
|
137
137
|
} catch (ex) {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}
|
|
138
|
+
var _inMemoryState$appSta;
|
|
139
|
+
const inMemoryState = executeReducer(state, {
|
|
140
|
+
type: LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
|
|
141
|
+
payload: null
|
|
143
142
|
});
|
|
143
|
+
// if the chat was disconnected or ended by the agent, we don't want to log the error
|
|
144
|
+
if (!(inMemoryState !== null && inMemoryState !== void 0 && (_inMemoryState$appSta = inMemoryState.appStates) !== null && _inMemoryState$appSta !== void 0 && _inMemoryState$appSta.chatDisconnectEventReceived)) {
|
|
145
|
+
TelemetryHelper.logSDKEvent(LogLevel.ERROR, {
|
|
146
|
+
Event: TelemetryEvent.EndChatSDKCallFailed,
|
|
147
|
+
ExceptionDetails: {
|
|
148
|
+
exception: ex
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
} else {
|
|
152
|
+
TelemetryHelper.logSDKEvent(LogLevel.WARN, {
|
|
153
|
+
Event: TelemetryEvent.DisconnectEndChatSDKCallFailed,
|
|
154
|
+
ExceptionDetails: {
|
|
155
|
+
exception: ex
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
}
|
|
144
159
|
postMessageToOtherTab = false;
|
|
145
160
|
} finally {
|
|
146
161
|
await endChatStateCleanUp(dispatch);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { DemoChatSDK } from "../../webchatcontainerstateful/common/DemoChatSDK";
|
|
2
|
+
import { DesignerChatSDK } from "../../webchatcontainerstateful/common/DesignerChatSDK";
|
|
3
|
+
import { MockChatSDK } from "../../webchatcontainerstateful/common/mockchatsdk";
|
|
4
|
+
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
|
+
export const getMockChatSDKIfApplicable = (chatSDK, type) => {
|
|
7
|
+
if (type) {
|
|
8
|
+
switch (type.toLowerCase()) {
|
|
9
|
+
case "demo":
|
|
10
|
+
chatSDK = new DemoChatSDK();
|
|
11
|
+
break;
|
|
12
|
+
case "designer":
|
|
13
|
+
chatSDK = new DesignerChatSDK();
|
|
14
|
+
break;
|
|
15
|
+
default:
|
|
16
|
+
chatSDK = new MockChatSDK();
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return chatSDK;
|
|
20
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const overridePropsOnMockIfApplicable = props => {
|
|
2
|
+
var _props$mock, _props$mock2;
|
|
3
|
+
if (props !== null && props !== void 0 && (_props$mock = props.mock) !== null && _props$mock !== void 0 && _props$mock.type && (props === null || props === void 0 ? void 0 : (_props$mock2 = props.mock) === null || _props$mock2 === void 0 ? void 0 : _props$mock2.type.toLowerCase()) === "designer") {
|
|
4
|
+
if (!props.webChatContainerProps) {
|
|
5
|
+
props.webChatContainerProps = {};
|
|
6
|
+
}
|
|
7
|
+
if (!props.webChatContainerProps.webChatProps) {
|
|
8
|
+
props.webChatContainerProps.webChatProps = {};
|
|
9
|
+
}
|
|
10
|
+
if (!props.webChatContainerProps.webChatStyles) {
|
|
11
|
+
props.webChatContainerProps.webChatStyles = {};
|
|
12
|
+
}
|
|
13
|
+
if (!props.webChatContainerProps.webChatProps.overrideLocalizedStrings) {
|
|
14
|
+
props.webChatContainerProps.webChatProps.overrideLocalizedStrings = {};
|
|
15
|
+
}
|
|
16
|
+
props.webChatContainerProps = {
|
|
17
|
+
...props.webChatContainerProps,
|
|
18
|
+
webChatProps: {
|
|
19
|
+
disabled: true,
|
|
20
|
+
...props.webChatContainerProps.webChatProps,
|
|
21
|
+
overrideLocalizedStrings: {
|
|
22
|
+
TEXT_INPUT_PLACEHOLDER: "Send a message . . .",
|
|
23
|
+
...props.webChatContainerProps.webChatProps.overrideLocalizedStrings
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
webChatStyles: {
|
|
27
|
+
hideUploadButton: false,
|
|
28
|
+
sendBoxBackground: "rgb(243, 242, 241)",
|
|
29
|
+
...props.webChatContainerProps.webChatStyles
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
export default overridePropsOnMockIfApplicable;
|