@microsoft/omnichannel-chat-widget 1.7.3-main.3d9027c → 1.7.3-main.4c1722d
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/Constants.js +1 -0
- 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/chatDisconnectHelper.js +2 -2
- package/lib/cjs/components/livechatwidget/common/createAdapter.js +15 -2
- package/lib/cjs/components/livechatwidget/common/createInternetConnectionChangeHandler.js +6 -2
- package/lib/cjs/components/livechatwidget/common/createMarkdown.js +2 -2
- package/lib/cjs/components/livechatwidget/common/getMockChatSDKIfApplicable.js +26 -0
- package/lib/cjs/components/livechatwidget/common/helpers/markdownHelper.js +23 -0
- package/lib/cjs/components/livechatwidget/common/overridePropsOnMockIfApplicable.js +41 -0
- package/lib/cjs/components/livechatwidget/common/startChat.js +28 -27
- 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/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +30 -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/createChatTranscript.js +84 -0
- package/lib/cjs/plugins/newMessageEventHandler.js +4 -2
- package/lib/esm/common/Constants.js +1 -0
- 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/chatDisconnectHelper.js +3 -2
- package/lib/esm/components/livechatwidget/common/createAdapter.js +14 -2
- package/lib/esm/components/livechatwidget/common/createInternetConnectionChangeHandler.js +6 -2
- package/lib/esm/components/livechatwidget/common/createMarkdown.js +2 -2
- package/lib/esm/components/livechatwidget/common/getMockChatSDKIfApplicable.js +20 -0
- package/lib/esm/components/livechatwidget/common/helpers/markdownHelper.js +15 -0
- package/lib/esm/components/livechatwidget/common/overridePropsOnMockIfApplicable.js +34 -0
- package/lib/esm/components/livechatwidget/common/startChat.js +28 -27
- 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/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +31 -1
- 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/createChatTranscript.js +84 -0
- package/lib/esm/plugins/newMessageEventHandler.js +4 -2
- package/lib/types/common/Constants.d.ts +1 -0
- 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/helpers/markdownHelper.d.ts +2 -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 +2 -2
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
1
2
|
import { NotificationHandler } from "../../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler";
|
|
2
3
|
import { NotificationScenarios } from "../../webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios";
|
|
3
|
-
import { defaultMiddlewareLocalizedTexts } from "../../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts";
|
|
4
|
-
import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
5
4
|
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
5
|
+
import { defaultMiddlewareLocalizedTexts } from "../../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts";
|
|
6
|
+
|
|
6
7
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7
8
|
const handleChatDisconnect = (props, state, setWebChatStyles) => {
|
|
8
9
|
var _state$appStates, _state$domainStates, _state$domainStates$m, _props$webChatContain, _props$webChatContain2;
|
|
@@ -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;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
2
|
+
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
1
3
|
import { Constants } from "../../../common/Constants";
|
|
2
4
|
import { NotificationHandler } from "../../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler";
|
|
3
5
|
import { NotificationScenarios } from "../../webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios";
|
|
4
|
-
import { defaultMiddlewareLocalizedTexts } from "../../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts";
|
|
5
6
|
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
6
|
-
import {
|
|
7
|
+
import { defaultMiddlewareLocalizedTexts } from "../../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts";
|
|
7
8
|
const isInternetConnected = async () => {
|
|
8
9
|
try {
|
|
9
10
|
const response = await fetch(Constants.internetConnectionTestUrl);
|
|
@@ -26,6 +27,9 @@ export const createInternetConnectionChangeHandler = async () => {
|
|
|
26
27
|
Event: TelemetryEvent.NetworkReconnected
|
|
27
28
|
});
|
|
28
29
|
NotificationHandler.notifySuccess(NotificationScenarios.InternetConnection, defaultMiddlewareLocalizedTexts.MIDDLEWARE_BANNER_INTERNET_BACK_ONLINE);
|
|
30
|
+
BroadcastService.postMessage({
|
|
31
|
+
eventName: BroadcastEvent.NetworkReconnected
|
|
32
|
+
});
|
|
29
33
|
}
|
|
30
34
|
};
|
|
31
35
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Constants } from "../../../common/Constants";
|
|
2
2
|
import MarkdownIt from "markdown-it";
|
|
3
3
|
import MarkdownItForInline from "markdown-it-for-inline";
|
|
4
|
-
import MarkdownSlack from "slack-markdown-it";
|
|
5
4
|
import { defaultMarkdownLocalizedTexts } from "../../webchatcontainerstateful/common/defaultProps/defaultMarkdownLocalizedTexts";
|
|
5
|
+
import { addSlackMarkdownIt } from "./helpers/markdownHelper";
|
|
6
6
|
|
|
7
7
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8
8
|
export const createMarkdown = (disableMarkdownMessageFormatting, disableNewLineMarkdownSupport) => {
|
|
@@ -13,7 +13,7 @@ export const createMarkdown = (disableMarkdownMessageFormatting, disableNewLineM
|
|
|
13
13
|
linkify: true,
|
|
14
14
|
breaks: !disableNewLineMarkdownSupport
|
|
15
15
|
});
|
|
16
|
-
markdown
|
|
16
|
+
markdown = addSlackMarkdownIt(markdown);
|
|
17
17
|
} else {
|
|
18
18
|
markdown = new MarkdownIt(Constants.Zero, {
|
|
19
19
|
html: true,
|
|
@@ -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,15 @@
|
|
|
1
|
+
import SlackMarkdown from "slack-markdown-it";
|
|
2
|
+
export const addSlackMarkdownIt = markdown => {
|
|
3
|
+
try {
|
|
4
|
+
markdown.use(SlackMarkdown);
|
|
5
|
+
} catch (e) {
|
|
6
|
+
// this is to support the case when slack-markdown-it
|
|
7
|
+
// transpiled code doesn't export default (webpack5)
|
|
8
|
+
if (SlackMarkdown.default.apply) {
|
|
9
|
+
markdown.use(SlackMarkdown.default);
|
|
10
|
+
} else {
|
|
11
|
+
console.error("Error while adding slackMarkdown plugin", e);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return markdown;
|
|
15
|
+
};
|
|
@@ -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;
|
|
@@ -2,21 +2,21 @@ import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/teleme
|
|
|
2
2
|
import { Constants, LiveWorkItemState, WidgetLoadCustomErrorString, WidgetLoadTelemetryMessage } from "../../../common/Constants";
|
|
3
3
|
import { checkContactIdError, createTimer, getConversationDetailsCall, getStateFromCache, getWidgetCacheIdfromProps, isNullOrEmptyString, isUndefinedOrEmpty } from "../../../common/utils";
|
|
4
4
|
import { getAuthClientFunction, handleAuthentication } from "./authHelper";
|
|
5
|
+
import { handleChatReconnect, isPersistentEnabled, isReconnectEnabled } from "./reconnectChatHelper";
|
|
6
|
+
import { handleStartChatError, logWidgetLoadComplete } from "./startChatErrorHandler";
|
|
5
7
|
import { ActivityStreamHandler } from "./ActivityStreamHandler";
|
|
6
8
|
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
7
9
|
import { ConversationState } from "../../../contexts/common/ConversationState";
|
|
8
10
|
import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
|
|
9
11
|
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
10
12
|
import { TelemetryTimers } from "../../../common/telemetry/TelemetryManager";
|
|
13
|
+
import { chatSDKStateCleanUp } from "./endChat";
|
|
11
14
|
import { createAdapter } from "./createAdapter";
|
|
12
15
|
import { createOnNewAdapterActivityHandler } from "../../../plugins/newMessageEventHandler";
|
|
13
|
-
import { handleChatReconnect, isPersistentEnabled, isReconnectEnabled } from "./reconnectChatHelper";
|
|
14
|
-
import { setPostChatContextAndLoadSurvey } from "./setPostChatContextAndLoadSurvey";
|
|
15
|
-
import { updateSessionDataForTelemetry } from "./updateSessionDataForTelemetry";
|
|
16
|
-
import { logWidgetLoadComplete, handleStartChatError } from "./startChatErrorHandler";
|
|
17
|
-
import { chatSDKStateCleanUp } from "./endChat";
|
|
18
16
|
import { isPersistentChatEnabled } from "./liveChatConfigUtils";
|
|
17
|
+
import { setPostChatContextAndLoadSurvey } from "./setPostChatContextAndLoadSurvey";
|
|
19
18
|
import { shouldSetPreChatIfPersistentChat } from "./persistentChatHelper";
|
|
19
|
+
import { updateTelemetryData } from "./updateSessionDataForTelemetry";
|
|
20
20
|
|
|
21
21
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
22
|
let optionalParams = {};
|
|
@@ -151,7 +151,7 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
|
|
|
151
151
|
chatSDKStateCleanUp(chatSDK);
|
|
152
152
|
}
|
|
153
153
|
try {
|
|
154
|
-
var _state$appStates2
|
|
154
|
+
var _state$appStates2;
|
|
155
155
|
// Clear disconnect state on start chat
|
|
156
156
|
(state === null || state === void 0 ? void 0 : (_state$appStates2 = state.appStates) === null || _state$appStates2 === void 0 ? void 0 : _state$appStates2.chatDisconnectEventReceived) && dispatch({
|
|
157
157
|
type: LiveChatWidgetActionType.SET_CHAT_DISCONNECT_EVENT_RECEIVED,
|
|
@@ -202,16 +202,7 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
|
|
|
202
202
|
isStartChatSuccessful = false;
|
|
203
203
|
throw error;
|
|
204
204
|
}
|
|
205
|
-
|
|
206
|
-
// New adapter creation
|
|
207
|
-
const newAdapter = await createAdapter(chatSDK);
|
|
208
|
-
setAdapter(newAdapter);
|
|
209
|
-
const chatToken = await chatSDK.getChatToken();
|
|
210
|
-
dispatch({
|
|
211
|
-
type: LiveChatWidgetActionType.SET_CHAT_TOKEN,
|
|
212
|
-
payload: chatToken
|
|
213
|
-
});
|
|
214
|
-
newAdapter === null || newAdapter === void 0 ? void 0 : (_newAdapter$activity$ = newAdapter.activity$) === null || _newAdapter$activity$ === void 0 ? void 0 : _newAdapter$activity$.subscribe(createOnNewAdapterActivityHandler(chatToken === null || chatToken === void 0 ? void 0 : chatToken.chatId, chatToken === null || chatToken === void 0 ? void 0 : chatToken.visitorId));
|
|
205
|
+
await createAdapterAndSubscribe(chatSDK, dispatch, setAdapter, props);
|
|
215
206
|
|
|
216
207
|
// Set app state to Active
|
|
217
208
|
if (isStartChatSuccessful) {
|
|
@@ -232,27 +223,26 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
|
|
|
232
223
|
payload: persistedState
|
|
233
224
|
});
|
|
234
225
|
logWidgetLoadComplete(WidgetLoadTelemetryMessage.PersistedStateRetrievedMessage);
|
|
235
|
-
|
|
226
|
+
// Set post chat context in state, load in background to do not block the load
|
|
227
|
+
setPostChatContextAndLoadSurvey(chatSDK, dispatch, true);
|
|
236
228
|
return;
|
|
237
229
|
}
|
|
238
230
|
|
|
239
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
240
|
-
const liveChatContext = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getCurrentLiveChatContext());
|
|
241
|
-
|
|
242
231
|
// Persistent Chat relies on the `reconnectId` retrieved from reconnectablechats API to reconnect upon start chat and not `liveChatContext`
|
|
243
232
|
if (!persistentChatEnabled) {
|
|
233
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
234
|
+
const liveChatContext = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getCurrentLiveChatContext());
|
|
235
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
244
236
|
dispatch({
|
|
245
237
|
type: LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
|
|
246
238
|
payload: liveChatContext
|
|
247
239
|
});
|
|
248
240
|
}
|
|
249
241
|
logWidgetLoadComplete();
|
|
250
|
-
// Set post chat context in state
|
|
251
|
-
|
|
252
|
-
await setPostChatContextAndLoadSurvey(chatSDK, dispatch);
|
|
253
|
-
|
|
242
|
+
// Set post chat context in state, load in background to do not block the load
|
|
243
|
+
setPostChatContextAndLoadSurvey(chatSDK, dispatch);
|
|
254
244
|
// Updating chat session detail for telemetry
|
|
255
|
-
await
|
|
245
|
+
await updateTelemetryData(chatSDK, dispatch);
|
|
256
246
|
} catch (ex) {
|
|
257
247
|
handleStartChatError(dispatch, chatSDK, props, ex, isStartChatSuccessful);
|
|
258
248
|
} finally {
|
|
@@ -261,6 +251,19 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
|
|
|
261
251
|
}
|
|
262
252
|
};
|
|
263
253
|
|
|
254
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
255
|
+
const createAdapterAndSubscribe = async (chatSDK, dispatch, setAdapter, props) => {
|
|
256
|
+
var _newAdapter$activity$;
|
|
257
|
+
// New adapter creation
|
|
258
|
+
const newAdapter = await createAdapter(chatSDK, props);
|
|
259
|
+
setAdapter(newAdapter);
|
|
260
|
+
const chatToken = await chatSDK.getChatToken();
|
|
261
|
+
dispatch({
|
|
262
|
+
type: LiveChatWidgetActionType.SET_CHAT_TOKEN,
|
|
263
|
+
payload: chatToken
|
|
264
|
+
});
|
|
265
|
+
newAdapter === null || newAdapter === void 0 ? void 0 : (_newAdapter$activity$ = newAdapter.activity$) === null || _newAdapter$activity$ === void 0 ? void 0 : _newAdapter$activity$.subscribe(createOnNewAdapterActivityHandler(chatToken === null || chatToken === void 0 ? void 0 : chatToken.chatId, chatToken === null || chatToken === void 0 ? void 0 : chatToken.visitorId));
|
|
266
|
+
};
|
|
264
267
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
265
268
|
const canConnectToExistingChat = async (props, chatSDK, state, dispatch, setAdapter) => {
|
|
266
269
|
var _state$appStates3, _persistedState$domai6, _persistedState$appSt;
|
|
@@ -349,10 +352,8 @@ const checkIfConversationStillValid = async (chatSDK, dispatch, state) => {
|
|
|
349
352
|
var _state$domainStates8, _state$domainStates8$, _state$domainStates9;
|
|
350
353
|
const requestIdFromCache = (_state$domainStates8 = state.domainStates) === null || _state$domainStates8 === void 0 ? void 0 : (_state$domainStates8$ = _state$domainStates8.liveChatContext) === null || _state$domainStates8$ === void 0 ? void 0 : _state$domainStates8$.requestId;
|
|
351
354
|
const liveChatContext = state === null || state === void 0 ? void 0 : (_state$domainStates9 = state.domainStates) === null || _state$domainStates9 === void 0 ? void 0 : _state$domainStates9.liveChatContext;
|
|
352
|
-
|
|
353
355
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
354
356
|
let conversationDetails = undefined;
|
|
355
|
-
|
|
356
357
|
// Preserve current requestId
|
|
357
358
|
const currentRequestId = chatSDK.requestId ?? "";
|
|
358
359
|
dispatch({
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ChatSDKError, ChatSDKErrorName } from "@microsoft/omnichannel-chat-sdk";
|
|
2
2
|
import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { PrepareEndChatDescriptionConstants, WidgetLoadCustomErrorString, WidgetLoadTelemetryMessage } from "../../../common/Constants";
|
|
4
|
+
import { callingStateCleanUp, chatSDKStateCleanUp, closeChatStateCleanUp, endChatStateCleanUp } from "./endChat";
|
|
5
5
|
import { ConversationState } from "../../../contexts/common/ConversationState";
|
|
6
|
-
import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
|
|
7
|
-
import { callingStateCleanUp, endChatStateCleanUp, closeChatStateCleanUp, chatSDKStateCleanUp } from "./endChat";
|
|
8
6
|
import { DataStoreManager } from "../../../common/contextDataStore/DataStoreManager";
|
|
9
|
-
import {
|
|
10
|
-
import { PrepareEndChatDescriptionConstants, WidgetLoadCustomErrorString, WidgetLoadTelemetryMessage } from "../../../common/Constants";
|
|
7
|
+
import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
|
|
11
8
|
import { StartChatFailureType } from "../../../contexts/common/StartChatFailureType";
|
|
9
|
+
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
10
|
+
import { TelemetryTimers } from "../../../common/telemetry/TelemetryManager";
|
|
11
|
+
import { getWidgetCacheIdfromProps } from "../../../common/utils";
|
|
12
12
|
|
|
13
13
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
14
|
export const handleStartChatError = (dispatch, chatSDK, props, ex, isStartChatSuccessful) => {
|
|
@@ -6,7 +6,13 @@ import { TelemetryManager } from "../../../common/telemetry/TelemetryManager";
|
|
|
6
6
|
import { getConversationDetailsCall } from "../../../common/utils";
|
|
7
7
|
|
|
8
8
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
|
-
export const
|
|
9
|
+
export const updateTelemetryData = async (chatSDK, dispatch) => {
|
|
10
|
+
// load it concurrently, this will reduce the load time
|
|
11
|
+
await Promise.all([updateSessionDataForTelemetry(chatSDK, dispatch), updateConversationDataForTelemetry(chatSDK, dispatch)]);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
|
+
const updateSessionDataForTelemetry = async (chatSDK, dispatch) => {
|
|
10
16
|
if (chatSDK) {
|
|
11
17
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
18
|
const chatSession = await chatSDK.getCurrentLiveChatContext();
|
|
@@ -21,7 +27,6 @@ export const updateSessionDataForTelemetry = async (chatSDK, dispatch) => {
|
|
|
21
27
|
chatSession
|
|
22
28
|
}
|
|
23
29
|
});
|
|
24
|
-
await updateConversationDataForTelemetry(chatSDK, dispatch);
|
|
25
30
|
}
|
|
26
31
|
};
|
|
27
32
|
|
package/lib/esm/components/livechatwidget/interfaces/IBotAuthActivitySubscriberOptionalParams.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -2,7 +2,7 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
|
|
|
2
2
|
import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
3
3
|
import { BroadcastService, BroadcastServiceInitialize, decodeComponentString } from "@microsoft/omnichannel-chat-components";
|
|
4
4
|
import { Components } from "botframework-webchat";
|
|
5
|
-
import { ConfirmationState, Constants, ConversationEndEntity, E2VVOptions, LiveWorkItemState, PrepareEndChatDescriptionConstants, StorageType } from "../../../common/Constants";
|
|
5
|
+
import { ConfirmationState, Constants, ConversationEndEntity, E2VVOptions, LiveWorkItemState, PrepareEndChatDescriptionConstants, StorageType, WidgetLoadCustomErrorString } from "../../../common/Constants";
|
|
6
6
|
import { Stack } from "@fluentui/react";
|
|
7
7
|
import React, { useEffect, useRef, useState } from "react";
|
|
8
8
|
import { TelemetryManager, TelemetryTimers } from "../../../common/telemetry/TelemetryManager";
|
|
@@ -346,6 +346,23 @@ export const LiveChatWidgetStateful = props => {
|
|
|
346
346
|
}
|
|
347
347
|
}
|
|
348
348
|
});
|
|
349
|
+
BroadcastService.getMessageByEventName(BroadcastEvent.NetworkReconnected).subscribe(async () => {
|
|
350
|
+
var _window2, _window2$location;
|
|
351
|
+
if (isThisSessionPopout((_window2 = window) === null || _window2 === void 0 ? void 0 : (_window2$location = _window2.location) === null || _window2$location === void 0 ? void 0 : _window2$location.href)) {
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
const conversationDetails = await getConversationDetailsCall(chatSDK);
|
|
355
|
+
if ((conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.state) === LiveWorkItemState.WrapUp || (conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.state) === LiveWorkItemState.Closed) {
|
|
356
|
+
dispatch({
|
|
357
|
+
type: LiveChatWidgetActionType.SET_CHAT_DISCONNECT_EVENT_RECEIVED,
|
|
358
|
+
payload: true
|
|
359
|
+
});
|
|
360
|
+
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
361
|
+
Event: TelemetryEvent.ChatDisconnectThreadEventReceived,
|
|
362
|
+
Description: "Chat disconnected due to timeout, user went offline or blocked the device (including closing laptop)"
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
});
|
|
349
366
|
|
|
350
367
|
/**
|
|
351
368
|
* This will allow to sync multiple tabs to handle minimize and maximize state,
|
|
@@ -663,11 +680,24 @@ export const LiveChatWidgetStateful = props => {
|
|
|
663
680
|
|
|
664
681
|
// Handle Chat disconnect cases
|
|
665
682
|
useEffect(() => {
|
|
683
|
+
var _inMemoryState$appSta5;
|
|
666
684
|
const inMemoryState = executeReducer(state, {
|
|
667
685
|
type: LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
|
|
668
686
|
payload: null
|
|
669
687
|
});
|
|
670
688
|
handleChatDisconnect(props, inMemoryState, setWebChatStyles);
|
|
689
|
+
const chatDisconnectState = inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta5 = inMemoryState.appStates) === null || _inMemoryState$appSta5 === void 0 ? void 0 : _inMemoryState$appSta5.chatDisconnectEventReceived;
|
|
690
|
+
if (chatDisconnectState && adapter) {
|
|
691
|
+
try {
|
|
692
|
+
adapter.end();
|
|
693
|
+
adapter.close();
|
|
694
|
+
} catch (e) {
|
|
695
|
+
TelemetryHelper.logWebChatEvent(LogLevel.ERROR, {
|
|
696
|
+
Event: TelemetryEvent.EndingAdapterAfterDisconnectionError,
|
|
697
|
+
Description: WidgetLoadCustomErrorString.CloseAdapterAfterDisconnectionErrorString
|
|
698
|
+
});
|
|
699
|
+
}
|
|
700
|
+
}
|
|
671
701
|
}, [state.appStates.chatDisconnectEventReceived]);
|
|
672
702
|
|
|
673
703
|
// if props state gets updates we need to update the renderingMiddlewareProps in the state
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import "rxjs/add/operator/share";
|
|
2
|
+
import "rxjs/add/observable/of";
|
|
3
|
+
import { Observable } from "rxjs/Observable";
|
|
4
|
+
import MockAdapter from "./mockadapter";
|
|
5
|
+
import { customerUser, postBotMessageActivity, postBotAttachmentActivity, postBotTypingActivity, postEchoActivity, postSystemMessageActivity } from "./utils/chatAdapterUtils";
|
|
6
|
+
import { createHeroCardAttachment, createJpgFileAttachment, createSigninCardAttachment, createThumbnailCardAttachment } from "./utils/attachmentActivityUtils";
|
|
7
|
+
import MockBotCommand from "./MockBotCommand";
|
|
8
|
+
import MockBotCardCommandType from "./MockBotCardCommandType";
|
|
9
|
+
export class DemoChatAdapter extends MockAdapter {
|
|
10
|
+
constructor() {
|
|
11
|
+
super();
|
|
12
|
+
setTimeout(() => {
|
|
13
|
+
postSystemMessageActivity(this.activityObserver, "You're currently using a demo.", 0);
|
|
14
|
+
postBotMessageActivity(this.activityObserver, "Type `/help` to learn more", undefined, 0); // send init message from bot
|
|
15
|
+
}, 1000);
|
|
16
|
+
}
|
|
17
|
+
postBotCommandsActivity() {
|
|
18
|
+
let delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1000;
|
|
19
|
+
postBotAttachmentActivity(this.activityObserver, [{
|
|
20
|
+
contentType: "application/vnd.microsoft.card.thumbnail",
|
|
21
|
+
content: {
|
|
22
|
+
buttons: [{
|
|
23
|
+
title: "Send system message",
|
|
24
|
+
type: "imBack",
|
|
25
|
+
value: "send system message"
|
|
26
|
+
}, {
|
|
27
|
+
title: "Send typing",
|
|
28
|
+
type: "imBack",
|
|
29
|
+
value: "send typing"
|
|
30
|
+
}, {
|
|
31
|
+
title: "Send bot message",
|
|
32
|
+
type: "imBack",
|
|
33
|
+
value: "send bot message"
|
|
34
|
+
}],
|
|
35
|
+
title: "Commands"
|
|
36
|
+
}
|
|
37
|
+
}], delay);
|
|
38
|
+
}
|
|
39
|
+
postActivity(activity) {
|
|
40
|
+
if (activity) {
|
|
41
|
+
postEchoActivity(this.activityObserver, activity, customerUser);
|
|
42
|
+
if (activity.text) {
|
|
43
|
+
switch (true) {
|
|
44
|
+
case activity.text === MockBotCommand.Help:
|
|
45
|
+
this.postBotCommandsActivity();
|
|
46
|
+
break;
|
|
47
|
+
case activity.text === MockBotCommand.SendSystemMessage:
|
|
48
|
+
postSystemMessageActivity(this.activityObserver, "Contoso has joined the chat.");
|
|
49
|
+
break;
|
|
50
|
+
case activity.text === MockBotCommand.SendTyping:
|
|
51
|
+
postBotTypingActivity(this.activityObserver);
|
|
52
|
+
break;
|
|
53
|
+
case activity.text === MockBotCommand.SendAttachment:
|
|
54
|
+
postBotAttachmentActivity(this.activityObserver, [createJpgFileAttachment()]);
|
|
55
|
+
break;
|
|
56
|
+
case activity.text === MockBotCommand.SendBotMessage:
|
|
57
|
+
postBotMessageActivity(this.activityObserver, "Hi, how can I help you?");
|
|
58
|
+
break;
|
|
59
|
+
case activity.text === `${MockBotCommand.Card} ${MockBotCardCommandType.Signin}`:
|
|
60
|
+
postBotAttachmentActivity(this.activityObserver, [createSigninCardAttachment()]);
|
|
61
|
+
break;
|
|
62
|
+
case activity.text === `${MockBotCommand.Card} ${MockBotCardCommandType.Hero}`:
|
|
63
|
+
postBotAttachmentActivity(this.activityObserver, [createHeroCardAttachment()]);
|
|
64
|
+
break;
|
|
65
|
+
case activity.text === `${MockBotCommand.Card} ${MockBotCardCommandType.Thumbnail}`:
|
|
66
|
+
postBotAttachmentActivity(this.activityObserver, [createThumbnailCardAttachment()]);
|
|
67
|
+
break;
|
|
68
|
+
case activity.text.startsWith(`${MockBotCommand.Bot} `):
|
|
69
|
+
postBotMessageActivity(this.activityObserver, activity.text.substring(5));
|
|
70
|
+
break;
|
|
71
|
+
case activity.text.startsWith(`${MockBotCommand.System} `):
|
|
72
|
+
postSystemMessageActivity(this.activityObserver, activity.text.substring(8));
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return Observable.of(activity.id || "");
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Observable } from "rxjs/Observable";
|
|
2
|
+
import MockAdapter from "./mockadapter";
|
|
3
|
+
import { customerUser, postBotMessageActivity, postEchoActivity, postSystemMessageActivity } from "./utils/chatAdapterUtils";
|
|
4
|
+
export class DesignerChatAdapter extends MockAdapter {
|
|
5
|
+
constructor() {
|
|
6
|
+
super();
|
|
7
|
+
setTimeout(() => {
|
|
8
|
+
postBotMessageActivity(this.activityObserver, "Id venenatis a condimentum vitae?", undefined, 0);
|
|
9
|
+
this.postUserActivity("Diam donec adipiscing tristique risus nec feugiat in fermentum", 0);
|
|
10
|
+
postSystemMessageActivity(this.activityObserver, "We are finding the best agent for your inquiry, please hold ...", 100);
|
|
11
|
+
postSystemMessageActivity(this.activityObserver, "John has joined the chat", 100);
|
|
12
|
+
postBotMessageActivity(this.activityObserver, "Neque viverra justo nec ultrices dui sapien eget mi proin", undefined, 100);
|
|
13
|
+
}, 1000);
|
|
14
|
+
}
|
|
15
|
+
postUserActivity(text) {
|
|
16
|
+
let delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1000;
|
|
17
|
+
setTimeout(() => {
|
|
18
|
+
postEchoActivity(this.activityObserver, {
|
|
19
|
+
text,
|
|
20
|
+
from: {
|
|
21
|
+
...customerUser
|
|
22
|
+
},
|
|
23
|
+
type: "message"
|
|
24
|
+
}, customerUser, 0);
|
|
25
|
+
}, delay);
|
|
26
|
+
}
|
|
27
|
+
postActivity(activity) {
|
|
28
|
+
if (activity) {
|
|
29
|
+
postEchoActivity(this.activityObserver, activity, customerUser);
|
|
30
|
+
}
|
|
31
|
+
return Observable.of(activity.id || "");
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DesignerChatAdapter } from "./DesignerChatAdapter";
|
|
2
|
+
import { MockChatSDK } from "./mockchatsdk";
|
|
3
|
+
export class DesignerChatSDK extends MockChatSDK {
|
|
4
|
+
constructor() {
|
|
5
|
+
super();
|
|
6
|
+
}
|
|
7
|
+
createChatAdapter() {
|
|
8
|
+
return new DesignerChatAdapter();
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
var MockBotCardCommandType;
|
|
2
|
+
(function (MockBotCardCommandType) {
|
|
3
|
+
MockBotCardCommandType["Hero"] = "hero";
|
|
4
|
+
MockBotCardCommandType["Signin"] = "signin";
|
|
5
|
+
MockBotCardCommandType["Thumbnail"] = "thumbnail";
|
|
6
|
+
})(MockBotCardCommandType || (MockBotCardCommandType = {}));
|
|
7
|
+
export default MockBotCardCommandType;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
var MockBotCommand;
|
|
2
|
+
(function (MockBotCommand) {
|
|
3
|
+
MockBotCommand["Bot"] = "/bot";
|
|
4
|
+
MockBotCommand["Card"] = "/card";
|
|
5
|
+
MockBotCommand["Help"] = "/help";
|
|
6
|
+
MockBotCommand["SendAttachment"] = "send attachment";
|
|
7
|
+
MockBotCommand["SendBotMessage"] = "send bot message";
|
|
8
|
+
MockBotCommand["SendSystemMessage"] = "send system message";
|
|
9
|
+
MockBotCommand["SendTyping"] = "send typing";
|
|
10
|
+
MockBotCommand["System"] = "/system";
|
|
11
|
+
})(MockBotCommand || (MockBotCommand = {}));
|
|
12
|
+
export default MockBotCommand;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export const createJpgFileAttachment = () => {
|
|
2
|
+
return {
|
|
3
|
+
contentType: "image/jpeg",
|
|
4
|
+
name: "600x400.jpg",
|
|
5
|
+
contentUrl: "https://raw.githubusercontent.com/microsoft/omnichannel-chat-sdk/e7e75d4ede351e1cf2e52f13860d2284848c4af0/playwright/public/images/600x400.jpg"
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
export const createHeroCardAttachment = () => {
|
|
9
|
+
return {
|
|
10
|
+
contentType: "application/vnd.microsoft.card.hero",
|
|
11
|
+
content: {
|
|
12
|
+
buttons: [{
|
|
13
|
+
title: "Bellevue",
|
|
14
|
+
type: "imBack",
|
|
15
|
+
value: "Bellevue"
|
|
16
|
+
}, {
|
|
17
|
+
title: "Redmond",
|
|
18
|
+
type: "imBack",
|
|
19
|
+
value: "Redmond"
|
|
20
|
+
}, {
|
|
21
|
+
title: "Seattle",
|
|
22
|
+
type: "imBack",
|
|
23
|
+
value: "Seattle"
|
|
24
|
+
}],
|
|
25
|
+
title: "Choose your location"
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
export const createThumbnailCardAttachment = () => {
|
|
30
|
+
return {
|
|
31
|
+
contentType: "application/vnd.microsoft.card.thumbnail",
|
|
32
|
+
content: {
|
|
33
|
+
title: "Microsoft",
|
|
34
|
+
subtitle: "Our mission is to empower every person and every organization on the planet to achieve more.",
|
|
35
|
+
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.",
|
|
36
|
+
images: [{
|
|
37
|
+
alt: "Microsoft logo",
|
|
38
|
+
url: "https://img-prod-cms-rt-microsoft-com.akamaized.net/cms/api/am/imageFileData/RE1Mu3b?ver=5c31" // logo from https://microsoft.com
|
|
39
|
+
}],
|
|
40
|
+
|
|
41
|
+
buttons: [{
|
|
42
|
+
title: "Learn more",
|
|
43
|
+
type: "openUrl",
|
|
44
|
+
value: "https://www.microsoft.com/"
|
|
45
|
+
}]
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
export const createSigninCardAttachment = () => {
|
|
50
|
+
return {
|
|
51
|
+
contentType: "application/vnd.microsoft.card.signin",
|
|
52
|
+
content: {
|
|
53
|
+
text: "Please login",
|
|
54
|
+
buttons: [{
|
|
55
|
+
type: "signin",
|
|
56
|
+
title: "Signin",
|
|
57
|
+
value: "https://login.live.com/"
|
|
58
|
+
}]
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
};
|