@microsoft/omnichannel-chat-widget 1.7.8-main.7a07fc5 → 1.7.8-main.f60b0b7
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/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +14 -8
- package/lib/cjs/plugins/createChatTranscript.js +4 -4
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +14 -8
- package/lib/esm/plugins/createChatTranscript.js +4 -4
- package/package.json +1 -1
|
@@ -417,7 +417,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
417
417
|
|
|
418
418
|
// Start chat from SDK Event
|
|
419
419
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.StartChat).subscribe(msg => {
|
|
420
|
-
var _props$chatConfig5, _props$chatConfig5$Li, _props$chatConfig6, _props$chatConfig6$Li, _msg$payload5, _msg$payload6, _msg$payload7, _msg$payload9, _inMemoryState$appSta2, _inMemoryState$appSta3
|
|
420
|
+
var _props$chatConfig5, _props$chatConfig5$Li, _props$chatConfig6, _props$chatConfig6$Li, _msg$payload5, _msg$payload6, _msg$payload7, _msg$payload9, _inMemoryState$appSta2, _inMemoryState$appSta3;
|
|
421
421
|
// If chat is out of operating hours chat widget sets the conversation state to OutOfOffice.
|
|
422
422
|
if (typeof (props === null || props === void 0 ? void 0 : (_props$chatConfig5 = props.chatConfig) === null || _props$chatConfig5 === void 0 ? void 0 : (_props$chatConfig5$Li = _props$chatConfig5.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig5$Li === void 0 ? void 0 : _props$chatConfig5$Li.OutOfOperatingHours) === "string" && (props === null || props === void 0 ? void 0 : (_props$chatConfig6 = props.chatConfig) === null || _props$chatConfig6 === void 0 ? void 0 : (_props$chatConfig6$Li = _props$chatConfig6.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig6$Li === void 0 ? void 0 : _props$chatConfig6$Li.OutOfOperatingHours.toLowerCase()) === "true") {
|
|
423
423
|
(state === null || state === void 0 ? void 0 : state.appStates.isMinimized) && dispatch({
|
|
@@ -455,8 +455,14 @@ const LiveChatWidgetStateful = props => {
|
|
|
455
455
|
});
|
|
456
456
|
inMemoryState.domainStates.customContext = msg === null || msg === void 0 ? void 0 : (_msg$payload9 = msg.payload) === null || _msg$payload9 === void 0 ? void 0 : _msg$payload9.customContext;
|
|
457
457
|
|
|
458
|
-
|
|
459
|
-
|
|
458
|
+
/*
|
|
459
|
+
* If the conversation is in closed state then we start a new chat,
|
|
460
|
+
* else if the conversation is in active state then we maximize the chat
|
|
461
|
+
* If the conversation is in inactive or postchat state then we maximize the chat.
|
|
462
|
+
*
|
|
463
|
+
* To start a new chat, it needs to be called via the close button or close chat via SDK.
|
|
464
|
+
**/
|
|
465
|
+
if (((_inMemoryState$appSta2 = inMemoryState.appStates) === null || _inMemoryState$appSta2 === void 0 ? void 0 : _inMemoryState$appSta2.conversationState) === _ConversationState.ConversationState.Closed) {
|
|
460
466
|
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
461
467
|
eventName: _TelemetryConstants.BroadcastEvent.ChatInitiated
|
|
462
468
|
});
|
|
@@ -465,7 +471,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
465
471
|
}
|
|
466
472
|
|
|
467
473
|
// If minimized, maximize the chat
|
|
468
|
-
if ((inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$
|
|
474
|
+
if ((inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta3 = inMemoryState.appStates) === null || _inMemoryState$appSta3 === void 0 ? void 0 : _inMemoryState$appSta3.isMinimized) === true) {
|
|
469
475
|
var _inMemoryState$domain, _inMemoryState$domain2, _inMemoryState$domain3, _inMemoryState$domain4;
|
|
470
476
|
dispatch({
|
|
471
477
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_MINIMIZED,
|
|
@@ -593,12 +599,12 @@ const LiveChatWidgetStateful = props => {
|
|
|
593
599
|
disablePolling: true
|
|
594
600
|
});
|
|
595
601
|
facadeChatSDK === null || facadeChatSDK === void 0 ? void 0 : facadeChatSDK.onAgentEndSession(event => {
|
|
596
|
-
var _inMemoryState$
|
|
602
|
+
var _inMemoryState$appSta4;
|
|
597
603
|
const inMemoryState = (0, _createReducer.executeReducer)(state, {
|
|
598
604
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
|
|
599
605
|
payload: null
|
|
600
606
|
});
|
|
601
|
-
if ("participantsRemoved" in event && (inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$
|
|
607
|
+
if ("participantsRemoved" in event && (inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta4 = inMemoryState.appStates) === null || _inMemoryState$appSta4 === void 0 ? void 0 : _inMemoryState$appSta4.conversationState) === _ConversationState.ConversationState.Active) {
|
|
602
608
|
setWebChatStyles(styles => {
|
|
603
609
|
return {
|
|
604
610
|
...styles,
|
|
@@ -741,13 +747,13 @@ const LiveChatWidgetStateful = props => {
|
|
|
741
747
|
|
|
742
748
|
// Handle Chat disconnect cases
|
|
743
749
|
(0, _react2.useEffect)(() => {
|
|
744
|
-
var _inMemoryState$
|
|
750
|
+
var _inMemoryState$appSta5;
|
|
745
751
|
const inMemoryState = (0, _createReducer.executeReducer)(state, {
|
|
746
752
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
|
|
747
753
|
payload: null
|
|
748
754
|
});
|
|
749
755
|
(0, _chatDisconnectHelper.handleChatDisconnect)(props, inMemoryState, setWebChatStyles);
|
|
750
|
-
const chatDisconnectState = inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$
|
|
756
|
+
const chatDisconnectState = inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta5 = inMemoryState.appStates) === null || _inMemoryState$appSta5 === void 0 ? void 0 : _inMemoryState$appSta5.chatDisconnectEventReceived;
|
|
751
757
|
if (chatDisconnectState && adapter) {
|
|
752
758
|
try {
|
|
753
759
|
adapter.end();
|
|
@@ -173,7 +173,7 @@ class TranscriptHTMLBuilder {
|
|
|
173
173
|
<script>
|
|
174
174
|
class Translator {
|
|
175
175
|
static convertTranscriptMessageToActivity(message) {
|
|
176
|
-
const {created, OriginalMessageId, id, isControlMessage, content, tags, from, attachments, amsMetadata, amsReferences} = message;
|
|
176
|
+
const {created, OriginalMessageId, id, isControlMessage, content, tags, from, attachments, amsMetadata, amsReferences, amsreferences} = message;
|
|
177
177
|
|
|
178
178
|
//it's required to convert the id to a number, otherwise the webchat will not render the messages in the correct order
|
|
179
179
|
// if the OrginalMessageId is not present, we can use the id as the sequence id, which is always present.
|
|
@@ -220,7 +220,7 @@ class TranscriptHTMLBuilder {
|
|
|
220
220
|
}
|
|
221
221
|
|
|
222
222
|
// Attachments
|
|
223
|
-
if (amsReferences && amsMetadata) {
|
|
223
|
+
if ((amsReferences || amsreferences) && amsMetadata) {
|
|
224
224
|
const metadata = JSON.parse(amsMetadata);
|
|
225
225
|
const { fileName } = metadata[0];
|
|
226
226
|
const text = \`${this.attachmentMessage}\${fileName}\`;
|
|
@@ -244,7 +244,7 @@ class TranscriptHTMLBuilder {
|
|
|
244
244
|
// Message
|
|
245
245
|
if (content) {
|
|
246
246
|
// Adaptive card formatting
|
|
247
|
-
if (content.includes('"
|
|
247
|
+
if (content.includes('"attachments"') || content.includes('"suggestedActions"')) {
|
|
248
248
|
try {
|
|
249
249
|
const partialActivity = JSON.parse(content);
|
|
250
250
|
return {
|
|
@@ -683,7 +683,7 @@ const createChatTranscript = async function (transcript, facadeChatSDK) {
|
|
|
683
683
|
messages = await Promise.all(transcriptMessages.map(async message => {
|
|
684
684
|
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
685
685
|
const {
|
|
686
|
-
amsReferences,
|
|
686
|
+
amsReferences = message.amsreferences,
|
|
687
687
|
amsMetadata
|
|
688
688
|
} = message;
|
|
689
689
|
if (amsReferences && amsMetadata) {
|
|
@@ -409,7 +409,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
409
409
|
|
|
410
410
|
// Start chat from SDK Event
|
|
411
411
|
BroadcastService.getMessageByEventName(BroadcastEvent.StartChat).subscribe(msg => {
|
|
412
|
-
var _props$chatConfig5, _props$chatConfig5$Li, _props$chatConfig6, _props$chatConfig6$Li, _msg$payload5, _msg$payload6, _msg$payload7, _msg$payload9, _inMemoryState$appSta2, _inMemoryState$appSta3
|
|
412
|
+
var _props$chatConfig5, _props$chatConfig5$Li, _props$chatConfig6, _props$chatConfig6$Li, _msg$payload5, _msg$payload6, _msg$payload7, _msg$payload9, _inMemoryState$appSta2, _inMemoryState$appSta3;
|
|
413
413
|
// If chat is out of operating hours chat widget sets the conversation state to OutOfOffice.
|
|
414
414
|
if (typeof (props === null || props === void 0 ? void 0 : (_props$chatConfig5 = props.chatConfig) === null || _props$chatConfig5 === void 0 ? void 0 : (_props$chatConfig5$Li = _props$chatConfig5.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig5$Li === void 0 ? void 0 : _props$chatConfig5$Li.OutOfOperatingHours) === "string" && (props === null || props === void 0 ? void 0 : (_props$chatConfig6 = props.chatConfig) === null || _props$chatConfig6 === void 0 ? void 0 : (_props$chatConfig6$Li = _props$chatConfig6.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig6$Li === void 0 ? void 0 : _props$chatConfig6$Li.OutOfOperatingHours.toLowerCase()) === "true") {
|
|
415
415
|
(state === null || state === void 0 ? void 0 : state.appStates.isMinimized) && dispatch({
|
|
@@ -447,8 +447,14 @@ export const LiveChatWidgetStateful = props => {
|
|
|
447
447
|
});
|
|
448
448
|
inMemoryState.domainStates.customContext = msg === null || msg === void 0 ? void 0 : (_msg$payload9 = msg.payload) === null || _msg$payload9 === void 0 ? void 0 : _msg$payload9.customContext;
|
|
449
449
|
|
|
450
|
-
|
|
451
|
-
|
|
450
|
+
/*
|
|
451
|
+
* If the conversation is in closed state then we start a new chat,
|
|
452
|
+
* else if the conversation is in active state then we maximize the chat
|
|
453
|
+
* If the conversation is in inactive or postchat state then we maximize the chat.
|
|
454
|
+
*
|
|
455
|
+
* To start a new chat, it needs to be called via the close button or close chat via SDK.
|
|
456
|
+
**/
|
|
457
|
+
if (((_inMemoryState$appSta2 = inMemoryState.appStates) === null || _inMemoryState$appSta2 === void 0 ? void 0 : _inMemoryState$appSta2.conversationState) === ConversationState.Closed) {
|
|
452
458
|
BroadcastService.postMessage({
|
|
453
459
|
eventName: BroadcastEvent.ChatInitiated
|
|
454
460
|
});
|
|
@@ -457,7 +463,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
457
463
|
}
|
|
458
464
|
|
|
459
465
|
// If minimized, maximize the chat
|
|
460
|
-
if ((inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$
|
|
466
|
+
if ((inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta3 = inMemoryState.appStates) === null || _inMemoryState$appSta3 === void 0 ? void 0 : _inMemoryState$appSta3.isMinimized) === true) {
|
|
461
467
|
var _inMemoryState$domain, _inMemoryState$domain2, _inMemoryState$domain3, _inMemoryState$domain4;
|
|
462
468
|
dispatch({
|
|
463
469
|
type: LiveChatWidgetActionType.SET_MINIMIZED,
|
|
@@ -585,12 +591,12 @@ export const LiveChatWidgetStateful = props => {
|
|
|
585
591
|
disablePolling: true
|
|
586
592
|
});
|
|
587
593
|
facadeChatSDK === null || facadeChatSDK === void 0 ? void 0 : facadeChatSDK.onAgentEndSession(event => {
|
|
588
|
-
var _inMemoryState$
|
|
594
|
+
var _inMemoryState$appSta4;
|
|
589
595
|
const inMemoryState = executeReducer(state, {
|
|
590
596
|
type: LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
|
|
591
597
|
payload: null
|
|
592
598
|
});
|
|
593
|
-
if ("participantsRemoved" in event && (inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$
|
|
599
|
+
if ("participantsRemoved" in event && (inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta4 = inMemoryState.appStates) === null || _inMemoryState$appSta4 === void 0 ? void 0 : _inMemoryState$appSta4.conversationState) === ConversationState.Active) {
|
|
594
600
|
setWebChatStyles(styles => {
|
|
595
601
|
return {
|
|
596
602
|
...styles,
|
|
@@ -733,13 +739,13 @@ export const LiveChatWidgetStateful = props => {
|
|
|
733
739
|
|
|
734
740
|
// Handle Chat disconnect cases
|
|
735
741
|
useEffect(() => {
|
|
736
|
-
var _inMemoryState$
|
|
742
|
+
var _inMemoryState$appSta5;
|
|
737
743
|
const inMemoryState = executeReducer(state, {
|
|
738
744
|
type: LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
|
|
739
745
|
payload: null
|
|
740
746
|
});
|
|
741
747
|
handleChatDisconnect(props, inMemoryState, setWebChatStyles);
|
|
742
|
-
const chatDisconnectState = inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$
|
|
748
|
+
const chatDisconnectState = inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta5 = inMemoryState.appStates) === null || _inMemoryState$appSta5 === void 0 ? void 0 : _inMemoryState$appSta5.chatDisconnectEventReceived;
|
|
743
749
|
if (chatDisconnectState && adapter) {
|
|
744
750
|
try {
|
|
745
751
|
adapter.end();
|
|
@@ -168,7 +168,7 @@ class TranscriptHTMLBuilder {
|
|
|
168
168
|
<script>
|
|
169
169
|
class Translator {
|
|
170
170
|
static convertTranscriptMessageToActivity(message) {
|
|
171
|
-
const {created, OriginalMessageId, id, isControlMessage, content, tags, from, attachments, amsMetadata, amsReferences} = message;
|
|
171
|
+
const {created, OriginalMessageId, id, isControlMessage, content, tags, from, attachments, amsMetadata, amsReferences, amsreferences} = message;
|
|
172
172
|
|
|
173
173
|
//it's required to convert the id to a number, otherwise the webchat will not render the messages in the correct order
|
|
174
174
|
// if the OrginalMessageId is not present, we can use the id as the sequence id, which is always present.
|
|
@@ -215,7 +215,7 @@ class TranscriptHTMLBuilder {
|
|
|
215
215
|
}
|
|
216
216
|
|
|
217
217
|
// Attachments
|
|
218
|
-
if (amsReferences && amsMetadata) {
|
|
218
|
+
if ((amsReferences || amsreferences) && amsMetadata) {
|
|
219
219
|
const metadata = JSON.parse(amsMetadata);
|
|
220
220
|
const { fileName } = metadata[0];
|
|
221
221
|
const text = \`${this.attachmentMessage}\${fileName}\`;
|
|
@@ -239,7 +239,7 @@ class TranscriptHTMLBuilder {
|
|
|
239
239
|
// Message
|
|
240
240
|
if (content) {
|
|
241
241
|
// Adaptive card formatting
|
|
242
|
-
if (content.includes('"
|
|
242
|
+
if (content.includes('"attachments"') || content.includes('"suggestedActions"')) {
|
|
243
243
|
try {
|
|
244
244
|
const partialActivity = JSON.parse(content);
|
|
245
245
|
return {
|
|
@@ -678,7 +678,7 @@ const createChatTranscript = async function (transcript, facadeChatSDK) {
|
|
|
678
678
|
messages = await Promise.all(transcriptMessages.map(async message => {
|
|
679
679
|
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
680
680
|
const {
|
|
681
|
-
amsReferences,
|
|
681
|
+
amsReferences = message.amsreferences,
|
|
682
682
|
amsMetadata
|
|
683
683
|
} = message;
|
|
684
684
|
if (amsReferences && amsMetadata) {
|