@microsoft/omnichannel-chat-sdk 1.11.6 → 1.11.7-main.3418dc3
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/OmnichannelChatSDK.d.ts +7 -1
- package/lib/OmnichannelChatSDK.js +101 -71
- package/lib/OmnichannelChatSDK.js.map +1 -1
- package/lib/core/ChatSDKError.d.ts +3 -1
- package/lib/core/ChatSDKError.js +2 -0
- package/lib/core/ChatSDKError.js.map +1 -1
- package/lib/core/GetPersistentChatHistoryOptionalParams.d.ts +10 -0
- package/lib/core/GetPersistentChatHistoryOptionalParams.js +3 -0
- package/lib/core/GetPersistentChatHistoryOptionalParams.js.map +1 -0
- package/lib/index.d.ts +2 -2
- package/lib/index.js.map +1 -1
- package/lib/telemetry/TelemetryEvent.d.ts +2 -1
- package/lib/telemetry/TelemetryEvent.js +1 -0
- package/lib/telemetry/TelemetryEvent.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/utils/exceptionThrowers.d.ts +6 -0
- package/lib/utils/exceptionThrowers.js +8 -2
- package/lib/utils/exceptionThrowers.js.map +1 -1
- package/package.json +2 -2
@@ -1,6 +1,6 @@
|
|
1
1
|
import ACSClient from "./core/messaging/ACSClient";
|
2
2
|
import { VoiceVideoCallingOptionalParams } from "./types/config";
|
3
|
-
import { ChatAdapter, GetAgentAvailabilityResponse, GetCurrentLiveChatContextResponse, GetLiveChatTranscriptResponse, GetMessagesResponse, GetPreChatSurveyResponse, GetVoiceVideoCallingResponse, MaskingRules, UploadFileAttachmentResponse } from "./types/response";
|
3
|
+
import { ChatAdapter, GetAgentAvailabilityResponse, GetCurrentLiveChatContextResponse, GetLiveChatTranscriptResponse, GetMessagesResponse, GetPersistentChatHistoryResponse, GetPreChatSurveyResponse, GetVoiceVideoCallingResponse, MaskingRules, UploadFileAttachmentResponse } from "./types/response";
|
4
4
|
import { ParticipantsRemovedEvent } from '@azure/communication-signaling';
|
5
5
|
import ChatAdapterOptionalParams from "./core/messaging/ChatAdapterOptionalParams";
|
6
6
|
import ChatConfig from "./core/ChatConfig";
|
@@ -21,6 +21,7 @@ import GetChatTokenOptionalParams from "./core/GetChatTokenOptionalParams";
|
|
21
21
|
import GetConversationDetailsOptionalParams from "./core/GetConversationDetailsOptionalParams";
|
22
22
|
import GetLiveChatConfigOptionalParams from "./core/GetLiveChatConfigOptionalParams";
|
23
23
|
import GetLiveChatTranscriptOptionalParams from "./core/GetLiveChatTranscriptOptionalParams";
|
24
|
+
import GetPersistentChatHistoryOptionalParams from "./core/GetPersistentChatHistoryOptionalParams";
|
24
25
|
import IChatToken from "./external/IC3Adapter/IChatToken";
|
25
26
|
import IFileInfo from "@microsoft/omnichannel-ic3core/lib/interfaces/IFileInfo";
|
26
27
|
import IFileMetadata from "@microsoft/omnichannel-ic3core/lib/model/IFileMetadata";
|
@@ -186,5 +187,10 @@ declare class OmnichannelChatSDK {
|
|
186
187
|
* @private
|
187
188
|
*/
|
188
189
|
private handleConversationJoinFailure;
|
190
|
+
/**
|
191
|
+
* Get persistent chat history for authenticated users.
|
192
|
+
* @param getPersistentChatHistoryOptionalParams Optional parameters for persistent chat history retrieval.
|
193
|
+
*/
|
194
|
+
getPersistentChatHistory(getPersistentChatHistoryOptionalParams?: GetPersistentChatHistoryOptionalParams): Promise<GetPersistentChatHistoryResponse | undefined>;
|
189
195
|
}
|
190
196
|
export default OmnichannelChatSDK;
|
@@ -1972,8 +1972,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1972
1972
|
OmnichannelChatSDK.prototype.onAgentEndSession = function (onAgentEndSessionCallback) {
|
1973
1973
|
return __awaiter(this, void 0, void 0, function () {
|
1974
1974
|
var _this = this;
|
1975
|
-
|
1976
|
-
return __generator(this, function (_b) {
|
1975
|
+
return __generator(this, function (_a) {
|
1977
1976
|
this.scenarioMarker.startScenario(TelemetryEvent_1.default.OnAgentEndSession, {
|
1978
1977
|
RequestId: this.requestId,
|
1979
1978
|
ChatId: this.chatToken.chatId
|
@@ -1981,59 +1980,32 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1981
1980
|
if (!this.isInitialized) {
|
1982
1981
|
exceptionThrowers_1.default.throwUninitializedChatSDK(this.scenarioMarker, TelemetryEvent_1.default.OnAgentEndSession);
|
1983
1982
|
}
|
1984
|
-
|
1985
|
-
|
1986
|
-
|
1987
|
-
|
1988
|
-
|
1989
|
-
|
1990
|
-
|
1991
|
-
|
1992
|
-
|
1993
|
-
|
1994
|
-
|
1995
|
-
|
1996
|
-
|
1997
|
-
return [2 /*return*/];
|
1998
|
-
}
|
1999
|
-
});
|
2000
|
-
}); });
|
2001
|
-
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.OnAgentEndSession, {
|
2002
|
-
RequestId: this.requestId,
|
2003
|
-
ChatId: this.chatToken.chatId
|
2004
|
-
});
|
2005
|
-
}
|
2006
|
-
catch (error) {
|
2007
|
-
this.scenarioMarker.failScenario(TelemetryEvent_1.default.OnAgentEndSession, {
|
2008
|
-
RequestId: this.requestId,
|
2009
|
-
ChatId: this.chatToken.chatId
|
2010
|
-
});
|
2011
|
-
}
|
2012
|
-
}
|
2013
|
-
else {
|
2014
|
-
try {
|
2015
|
-
(_a = this.conversation) === null || _a === void 0 ? void 0 : _a.registerOnThreadUpdate(function (message) {
|
2016
|
-
var members = message.members;
|
2017
|
-
// Agent ending conversation would have 1 member left in the chat thread
|
2018
|
-
if (members.length === 1) {
|
2019
|
-
onAgentEndSessionCallback(message);
|
2020
|
-
if (_this.refreshTokenTimer !== null) {
|
2021
|
-
clearInterval(_this.refreshTokenTimer);
|
2022
|
-
_this.refreshTokenTimer = null;
|
2023
|
-
}
|
1983
|
+
try {
|
1984
|
+
this.conversation.registerOnThreadUpdate(function (event) { return __awaiter(_this, void 0, void 0, function () {
|
1985
|
+
var liveWorkItemDetails;
|
1986
|
+
return __generator(this, function (_a) {
|
1987
|
+
switch (_a.label) {
|
1988
|
+
case 0: return [4 /*yield*/, this.getConversationDetails()];
|
1989
|
+
case 1:
|
1990
|
+
liveWorkItemDetails = _a.sent();
|
1991
|
+
if (Object.keys(liveWorkItemDetails).length === 0 || liveWorkItemDetails.state == LiveWorkItemState_1.default.WrapUp || liveWorkItemDetails.state == LiveWorkItemState_1.default.Closed) {
|
1992
|
+
onAgentEndSessionCallback(event);
|
1993
|
+
this.stopPolling();
|
1994
|
+
}
|
1995
|
+
return [2 /*return*/];
|
2024
1996
|
}
|
2025
1997
|
});
|
2026
|
-
|
2027
|
-
|
2028
|
-
|
2029
|
-
|
2030
|
-
}
|
2031
|
-
|
2032
|
-
|
2033
|
-
|
2034
|
-
|
2035
|
-
|
2036
|
-
}
|
1998
|
+
}); });
|
1999
|
+
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.OnAgentEndSession, {
|
2000
|
+
RequestId: this.requestId,
|
2001
|
+
ChatId: this.chatToken.chatId
|
2002
|
+
});
|
2003
|
+
}
|
2004
|
+
catch (error) {
|
2005
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.OnAgentEndSession, {
|
2006
|
+
RequestId: this.requestId,
|
2007
|
+
ChatId: this.chatToken.chatId
|
2008
|
+
});
|
2037
2009
|
}
|
2038
2010
|
return [2 /*return*/];
|
2039
2011
|
});
|
@@ -2486,7 +2458,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2486
2458
|
};
|
2487
2459
|
OmnichannelChatSDK.prototype.getPostChatSurveyContext = function () {
|
2488
2460
|
return __awaiter(this, void 0, void 0, function () {
|
2489
|
-
var conversationId, chatConfig, liveWSAndLiveChatEngJoin, msdyn_postconversationsurveyenable, msfp_sourcesurveyidentifier, msfp_botsourcesurveyidentifier, postConversationSurveyOwnerId, postConversationBotSurveyOwnerId, msdyn_surveyprovider, surveyProvider, liveWorkItemDetails, participantJoined, participantType, agentSurveyInviteLinkRequest, botSurveyInviteLinkRequest, optionalParams, agentSurveyInviteLinkResponse, botSurveyInviteLinkResponse,
|
2461
|
+
var conversationId, chatConfig, liveWSAndLiveChatEngJoin, msdyn_postconversationsurveyenable, msfp_sourcesurveyidentifier, msfp_botsourcesurveyidentifier, postConversationSurveyOwnerId, postConversationBotSurveyOwnerId, msdyn_surveyprovider, surveyProvider, liveWorkItemDetails, participantJoined, participantType, agentSurveyInviteLinkRequest, botSurveyInviteLinkRequest, optionalParams, _a, agentSurveyInviteLinkResponse, botSurveyInviteLinkResponse, agentSurveyInviteLink, agentFormsProLocale, botSurveyInviteLink, botFormsProLocale, postChatContext, ex_1;
|
2490
2462
|
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
2491
2463
|
return __generator(this, function (_o) {
|
2492
2464
|
switch (_o.label) {
|
@@ -2500,7 +2472,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2500
2472
|
}
|
2501
2473
|
_o.label = 1;
|
2502
2474
|
case 1:
|
2503
|
-
_o.trys.push([1,
|
2475
|
+
_o.trys.push([1, 6, , 7]);
|
2504
2476
|
chatConfig = this.liveChatConfig;
|
2505
2477
|
liveWSAndLiveChatEngJoin = chatConfig.LiveWSAndLiveChatEngJoin;
|
2506
2478
|
msdyn_postconversationsurveyenable = liveWSAndLiveChatEngJoin.msdyn_postconversationsurveyenable, msfp_sourcesurveyidentifier = liveWSAndLiveChatEngJoin.msfp_sourcesurveyidentifier, msfp_botsourcesurveyidentifier = liveWSAndLiveChatEngJoin.msfp_botsourcesurveyidentifier, postConversationSurveyOwnerId = liveWSAndLiveChatEngJoin.postConversationSurveyOwnerId, postConversationBotSurveyOwnerId = liveWSAndLiveChatEngJoin.postConversationBotSurveyOwnerId, msdyn_surveyprovider = liveWSAndLiveChatEngJoin.msdyn_surveyprovider;
|
@@ -2513,7 +2485,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2513
2485
|
});
|
2514
2486
|
return [2 /*return*/, Promise.reject("GetPostChatSurveyContext : msfp_sourcesurveyidentifier is mandatory for survey provider ".concat(SurveyProvider_1.SurveyProvider.CustomerVoice, "."))];
|
2515
2487
|
}
|
2516
|
-
if (!((0, parsers_1.parseLowerCaseString)(msdyn_postconversationsurveyenable) === "true")) return [3 /*break*/,
|
2488
|
+
if (!((0, parsers_1.parseLowerCaseString)(msdyn_postconversationsurveyenable) === "true")) return [3 /*break*/, 4];
|
2517
2489
|
return [4 /*yield*/, this.getConversationDetails()];
|
2518
2490
|
case 2:
|
2519
2491
|
liveWorkItemDetails = _o.sent();
|
@@ -2556,17 +2528,14 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2556
2528
|
if (this.authenticatedUserToken) {
|
2557
2529
|
optionalParams.authenticatedUserToken = this.authenticatedUserToken;
|
2558
2530
|
}
|
2559
|
-
return [4 /*yield*/,
|
2531
|
+
return [4 /*yield*/, Promise.all([
|
2532
|
+
this.OCClient.getSurveyInviteLink(postConversationSurveyOwnerId, agentSurveyInviteLinkRequest, optionalParams),
|
2533
|
+
(postConversationBotSurveyOwnerId && msfp_botsourcesurveyidentifier)
|
2534
|
+
? this.OCClient.getSurveyInviteLink(postConversationBotSurveyOwnerId, botSurveyInviteLinkRequest, optionalParams)
|
2535
|
+
: Promise.resolve(null)
|
2536
|
+
])];
|
2560
2537
|
case 3:
|
2561
|
-
|
2562
|
-
_a = postConversationBotSurveyOwnerId && msfp_botsourcesurveyidentifier;
|
2563
|
-
if (!_a) return [3 /*break*/, 5];
|
2564
|
-
return [4 /*yield*/, this.OCClient.getSurveyInviteLink(postConversationBotSurveyOwnerId, botSurveyInviteLinkRequest, optionalParams)];
|
2565
|
-
case 4:
|
2566
|
-
_a = (_o.sent());
|
2567
|
-
_o.label = 5;
|
2568
|
-
case 5:
|
2569
|
-
botSurveyInviteLinkResponse = _a;
|
2538
|
+
_a = _o.sent(), agentSurveyInviteLinkResponse = _a[0], botSurveyInviteLinkResponse = _a[1];
|
2570
2539
|
agentSurveyInviteLink = void 0, agentFormsProLocale = void 0, botSurveyInviteLink = void 0, botFormsProLocale = void 0;
|
2571
2540
|
if (agentSurveyInviteLinkResponse != null) {
|
2572
2541
|
if (agentSurveyInviteLinkResponse.inviteList != null && agentSurveyInviteLinkResponse.inviteList.length == 1) {
|
@@ -2615,16 +2584,16 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2615
2584
|
});
|
2616
2585
|
return [2 /*return*/, Promise.reject("surveyInviteLinkResponse is null.")];
|
2617
2586
|
}
|
2618
|
-
return [3 /*break*/,
|
2619
|
-
case
|
2587
|
+
return [3 /*break*/, 5];
|
2588
|
+
case 4:
|
2620
2589
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetPostChatSurveyContext, {
|
2621
2590
|
RequestId: this.requestId,
|
2622
2591
|
ChatId: (_l = this.chatToken) === null || _l === void 0 ? void 0 : _l.chatId,
|
2623
2592
|
ExceptionDetails: "Post Chat Survey is disabled. Please check the Omnichannel Administration Portal."
|
2624
2593
|
});
|
2625
2594
|
return [2 /*return*/, Promise.reject("Post Chat is disabled from admin side, or chat doesnt have a survey as part of their configuration.")];
|
2626
|
-
case
|
2627
|
-
case
|
2595
|
+
case 5: return [3 /*break*/, 7];
|
2596
|
+
case 6:
|
2628
2597
|
ex_1 = _o.sent();
|
2629
2598
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetPostChatSurveyContext, {
|
2630
2599
|
ConversationId: conversationId !== null && conversationId !== void 0 ? conversationId : "",
|
@@ -2633,7 +2602,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2633
2602
|
ExceptionDetails: JSON.stringify(ex_1)
|
2634
2603
|
});
|
2635
2604
|
return [2 /*return*/, Promise.reject("Retrieving post chat context failed " + JSON.stringify(ex_1))];
|
2636
|
-
case
|
2605
|
+
case 7: return [2 /*return*/];
|
2637
2606
|
}
|
2638
2607
|
});
|
2639
2608
|
});
|
@@ -3157,6 +3126,67 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
3157
3126
|
});
|
3158
3127
|
});
|
3159
3128
|
};
|
3129
|
+
/**
|
3130
|
+
* Get persistent chat history for authenticated users.
|
3131
|
+
* @param getPersistentChatHistoryOptionalParams Optional parameters for persistent chat history retrieval.
|
3132
|
+
*/
|
3133
|
+
OmnichannelChatSDK.prototype.getPersistentChatHistory = function () {
|
3134
|
+
return __awaiter(this, arguments, void 0, function (getPersistentChatHistoryOptionalParams) {
|
3135
|
+
var params, result, error_28, telemetryData;
|
3136
|
+
var _a, _b, _c, _d, _e;
|
3137
|
+
if (getPersistentChatHistoryOptionalParams === void 0) { getPersistentChatHistoryOptionalParams = {}; }
|
3138
|
+
return __generator(this, function (_f) {
|
3139
|
+
switch (_f.label) {
|
3140
|
+
case 0:
|
3141
|
+
if (!this.requestId) {
|
3142
|
+
this.requestId = (0, ocsdk_1.uuidv4)();
|
3143
|
+
}
|
3144
|
+
this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetPersistentChatHistory, {
|
3145
|
+
RequestId: this.requestId
|
3146
|
+
});
|
3147
|
+
if (!this.isInitialized) {
|
3148
|
+
exceptionThrowers_1.default.throwUninitializedChatSDK(this.scenarioMarker, TelemetryEvent_1.default.GetPersistentChatHistory);
|
3149
|
+
}
|
3150
|
+
if (!this.isPersistentChat || ((_a = this.chatSDKConfig.persistentChat) === null || _a === void 0 ? void 0 : _a.disable) === true) {
|
3151
|
+
exceptionThrowers_1.default.throwNotPersistentChatEnabled(this.scenarioMarker, TelemetryEvent_1.default.GetPersistentChatHistory, {
|
3152
|
+
RequestId: this.requestId,
|
3153
|
+
ChatId: (_b = this.chatToken) === null || _b === void 0 ? void 0 : _b.chatId
|
3154
|
+
});
|
3155
|
+
}
|
3156
|
+
if (!this.authenticatedUserToken) {
|
3157
|
+
exceptionThrowers_1.default.throwChatSDKError(ChatSDKError_1.ChatSDKErrorName.AuthenticatedUserTokenNotFound, new Error('Authenticated user token not found'), this.scenarioMarker, TelemetryEvent_1.default.GetPersistentChatHistory, {
|
3158
|
+
RequestId: this.requestId,
|
3159
|
+
ChatId: (_c = this.chatToken) === null || _c === void 0 ? void 0 : _c.chatId
|
3160
|
+
});
|
3161
|
+
}
|
3162
|
+
_f.label = 1;
|
3163
|
+
case 1:
|
3164
|
+
_f.trys.push([1, 3, , 4]);
|
3165
|
+
params = {};
|
3166
|
+
params.pageSize = getPersistentChatHistoryOptionalParams.pageSize || undefined;
|
3167
|
+
params.pageToken = getPersistentChatHistoryOptionalParams.pageToken || undefined;
|
3168
|
+
return [4 /*yield*/, this.OCClient.getPersistentChatHistory(this.requestId, __assign(__assign({}, params), { authenticatedUserToken: this.authenticatedUserToken }))];
|
3169
|
+
case 2:
|
3170
|
+
result = _f.sent();
|
3171
|
+
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetPersistentChatHistory, {
|
3172
|
+
RequestId: this.requestId,
|
3173
|
+
ChatId: (_d = this.chatToken) === null || _d === void 0 ? void 0 : _d.chatId
|
3174
|
+
});
|
3175
|
+
return [2 /*return*/, result];
|
3176
|
+
case 3:
|
3177
|
+
error_28 = _f.sent();
|
3178
|
+
telemetryData = {
|
3179
|
+
RequestId: this.requestId,
|
3180
|
+
ChatId: (_e = this.chatToken) === null || _e === void 0 ? void 0 : _e.chatId,
|
3181
|
+
ErrorMessage: (error_28 === null || error_28 === void 0 ? void 0 : error_28.message) || 'Unknown error' // Added error message for better debugging
|
3182
|
+
};
|
3183
|
+
exceptionThrowers_1.default.throwPersistentChatConversationRetrievalFailure(error_28, this.scenarioMarker, TelemetryEvent_1.default.GetPersistentChatHistory, telemetryData);
|
3184
|
+
return [3 /*break*/, 4];
|
3185
|
+
case 4: return [2 /*return*/];
|
3186
|
+
}
|
3187
|
+
});
|
3188
|
+
});
|
3189
|
+
};
|
3160
3190
|
return OmnichannelChatSDK;
|
3161
3191
|
}());
|
3162
3192
|
exports.default = OmnichannelChatSDK;
|