@microsoft/omnichannel-chat-sdk 1.11.9-main.5533dfe → 1.11.9-main.80c0e77

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -44,6 +44,7 @@ Please make sure you have a chat widget configured before using this package or
44
44
  - [Create Chat Adapter](#create-chat-adapter)
45
45
  - [Get Voice & Video Calling](#get-voice--video-calling)
46
46
  - [Get Post Chat Survey Context](#get-post-chat-survey-context)
47
+ - [Get Persistent Chat History](#get-persistent-chat-history)
47
48
  - [Common Scenarios](#common-scenarios)
48
49
  - [Using BotFramework-WebChat](#using-botframework-webchat)
49
50
  - [Escalation to Voice & Video](#escalation-to-voice--video)
@@ -52,6 +53,7 @@ Please make sure you have a chat widget configured before using this package or
52
53
  - [Reconnect to existing Chat](#reconnect-to-existing-chat)
53
54
  - [Authenticated Chat](#authenticated-chat)
54
55
  - [Persistent Chat](#persistent-chat)
56
+ - [Persistent Chat History](#persistent-chat-history)
55
57
  - [Chat Reconnect with Authenticated User](#chat-reconnect-with-authenticated-user)
56
58
  - [Chat Reconnect with Unauthenticated User](#chat-reconnect-with-unauthenticated-user)
57
59
  - [Best Practices for Chat Session Management: Handling Disconnections and Network Instabilit(#best-practices-for-chat-session-management:-handling-disconnections-and-network-instability)
@@ -579,6 +581,24 @@ It gets the participant type that should be used for the survey and both the def
579
581
  const postChatSurveyContext = await chatSDK.getPostChatSurveyContext();
580
582
  ```
581
583
 
584
+ ### Get Persistent Chat History
585
+
586
+ It fetches paginated chat history from previous persistent chat conversations for authenticated users. Returns messages in chronological order along with a pagination token to fetch the next page.
587
+
588
+ > :warning: Requires **persistent chat** to be enabled and the user must be **authenticated**.
589
+
590
+ ```ts
591
+ const optionalParams = {
592
+ pageSize: 25, // Number of messages per page (optional)
593
+ pageToken: '' // Token from a previous response to fetch the next page (optional, omit for first call)
594
+ };
595
+
596
+ const response = await chatSDK.getPersistentChatHistory(optionalParams);
597
+
598
+ // response.chatMessages: PersistentChatHistoryMessage[] — Array of chat messages
599
+ // response.nextPageToken: string | null — Token to pass in the next call; null means no more history
600
+ ```
601
+
582
602
  ### Get Agent Availability
583
603
 
584
604
  It gets information on whether a queue is available, and whether there are agents available in that queue, as well as queue position and average wait time. This call only supports authenticated chat.
@@ -735,6 +755,200 @@ await chatSDK.initialize();
735
755
  // from this point, this acts like a persistent chat
736
756
  ```
737
757
 
758
+ ### Persistent Chat History
759
+
760
+ > See <https://docs.microsoft.com/en-us/dynamics365/customer-service/persistent-chat> on how to set up persistent chat
761
+
762
+ When persistent chat is enabled, you can retrieve the chat history from previous conversations using `getPersistentChatHistory()`. This method returns paginated results, allowing you to load history incrementally (e.g., as the user scrolls up).
763
+
764
+ > :warning: **Prerequisites:**
765
+ > - Persistent chat must be **enabled** in the admin portal (conversation mode set to Persistent Chat) and in the SDK config (`persistentChat.disable: false`)
766
+ > - The user must be **authenticated** (`getAuthToken` must be configured)
767
+ > - `chatSDK.initialize()` and `chatSDK.startChat()` must be called before fetching history
768
+ > - Chat history is available for up to **12 months**
769
+
770
+ #### Page Size
771
+
772
+ The `pageSize` parameter controls how many messages are returned per call.
773
+
774
+ | | Value |
775
+ | --- | --- |
776
+ | **Default** | `50` (used when `pageSize` is omitted) |
777
+ | **Minimum** | `1` |
778
+ | **Maximum** | `100` |
779
+
780
+ If `pageSize` is not provided, the backend defaults to **50**. Values outside the 1–100 range will be rejected with an error.
781
+
782
+ #### How Pagination Works
783
+
784
+ | Call | `pageToken` param | What happens |
785
+ | --- | --- | --- |
786
+ | **First call** | Omit or `undefined` | Fetches the most recent page of messages. The response includes `nextPageToken` if older messages exist. |
787
+ | **Subsequent calls** | Pass the `nextPageToken` from the previous response | Fetches the next (older) page. Again returns `nextPageToken` if more messages remain. |
788
+ | **Last page** | Pass the `nextPageToken` from the previous response | Returns the remaining messages. `nextPageToken` is `null`, indicating there are no more messages in the history. |
789
+
790
+ In short: keep passing the `nextPageToken` from each response into the next call until the backend returns `nextPageToken: null` — that signals the entire history has been retrieved.
791
+
792
+ #### Basic Usage
793
+
794
+ ```ts
795
+ const chatSDKConfig = {
796
+ persistentChat: {
797
+ disable: false,
798
+ tokenUpdateTime: 21600000
799
+ },
800
+ getAuthToken: async () => {
801
+ const response = await fetch("http://contosohelp.com/token");
802
+ if (response.ok) {
803
+ return await response.text();
804
+ }
805
+ else {
806
+ return null
807
+ }
808
+ }
809
+ }
810
+
811
+ const chatSDK = new OmnichannelChatSDK.OmnichannelChatSDK(omnichannelConfig, chatSDKConfig);
812
+ await chatSDK.initialize();
813
+
814
+ await chatSDK.startChat();
815
+
816
+ // Fetch the first page of chat history
817
+ const history = await chatSDK.getPersistentChatHistory({
818
+ pageSize: 25
819
+ });
820
+
821
+ if (history) {
822
+ // Render messages
823
+ history.chatMessages.forEach((message) => {
824
+ console.log(`[${message.createdDateTime}] ${message.content}`);
825
+ });
826
+
827
+ // Check if more history is available
828
+ if (history.nextPageToken) {
829
+ console.log("More history available");
830
+ }
831
+ }
832
+ ```
833
+
834
+ #### Pagination — Loading More History on Scroll Up
835
+
836
+ After the first call returns a `nextPageToken`, you can fetch older pages on demand — for example, each time the customer scrolls up in the chat window. The loop below shows fetching all remaining history, but in practice you would call `getPersistentChatHistory` once per scroll-up action, passing the `nextPageToken` from the previous response.
837
+
838
+ ```ts
839
+ // After the first call (Basic Usage above), save the nextPageToken
840
+ let pageToken: string | undefined = history?.nextPageToken ?? undefined;
841
+
842
+ // Example: fetch the next page when the customer scrolls up
843
+ const loadMoreHistory = async () => {
844
+ if (!pageToken) {
845
+ console.log("No more history to load");
846
+ return;
847
+ }
848
+
849
+ const response = await chatSDK.getPersistentChatHistory({
850
+ pageSize: 25,
851
+ pageToken
852
+ });
853
+
854
+ if (response && response.chatMessages.length > 0) {
855
+ // Render the older messages in the chat UI
856
+ response.chatMessages.forEach((message) => {
857
+ console.log(`[${message.createdDateTime}] ${message.content}`);
858
+ });
859
+
860
+ // Update the token for the next scroll-up action
861
+ pageToken = response.nextPageToken ?? undefined;
862
+ }
863
+ };
864
+
865
+ // Bind to your scroll-up event (e.g., user reaches the top of the chat container)
866
+ chatContainer.addEventListener('scroll', () => {
867
+ if (chatContainer.scrollTop === 0) {
868
+ loadMoreHistory();
869
+ }
870
+ });
871
+ ```
872
+
873
+ Alternatively, to fetch all history at once in a loop:
874
+
875
+ ```ts
876
+ let token: string | undefined = history?.nextPageToken ?? undefined;
877
+ let allMessages = [...(history?.chatMessages ?? [])];
878
+
879
+ while (token) {
880
+ const response = await chatSDK.getPersistentChatHistory({
881
+ pageSize: 25,
882
+ pageToken: token
883
+ });
884
+
885
+ if (response && response.chatMessages.length > 0) {
886
+ allMessages = [...allMessages, ...response.chatMessages];
887
+ token = response.nextPageToken ?? undefined;
888
+ } else {
889
+ break;
890
+ }
891
+ }
892
+
893
+ console.log(`Total messages retrieved: ${allMessages.length}`);
894
+ ```
895
+
896
+ #### Response Shape
897
+
898
+ The response type is exported from the SDK and can be imported for TypeScript usage:
899
+
900
+ ```ts
901
+ import { GetPersistentChatHistoryResponse } from '@microsoft/omnichannel-chat-sdk';
902
+ ```
903
+
904
+ ```ts
905
+ type GetPersistentChatHistoryResponse = {
906
+ chatMessages: PersistentChatHistoryMessage[];
907
+ nextPageToken: string | null; // null when no more pages
908
+ }
909
+
910
+ type PersistentChatHistoryMessage = {
911
+ content: string; // Message text
912
+ contentType: number; // Content type identifier
913
+ createdDateTime: string; // ISO 8601 timestamp
914
+ from: {
915
+ application: { // Sender application info
916
+ displayName: string; // e.g., agent name or bot name
917
+ id: string;
918
+ } | null;
919
+ };
920
+ id: string; // Unique message identifier
921
+ attachments: unknown[]; // File attachments if any
922
+ additionalData: {
923
+ deliveryMode: string; // Delivery channel
924
+ ConversationId: string; // Conversation the message belongs to
925
+ tags: string; // Message tags
926
+ };
927
+ }
928
+ ```
929
+
930
+ #### Error Handling
931
+
932
+ ```ts
933
+ try {
934
+ const history = await chatSDK.getPersistentChatHistory({ pageSize: 25 });
935
+ // Process messages...
936
+ } catch (error) {
937
+ if (error.message === 'ChatSDKNotInitialized') {
938
+ // SDK not initialized — call chatSDK.initialize() first
939
+ }
940
+ if (error.message === 'PersistentChatNotEnabled') {
941
+ // Persistent chat is not enabled for this widget
942
+ }
943
+ if (error.message === 'AuthenticatedUserTokenNotFound') {
944
+ // User is not authenticated — configure getAuthToken
945
+ }
946
+ if (error.message === 'PersistentChatConversationRetrievalFailure') {
947
+ // Server error fetching history — retry or handle gracefully
948
+ }
949
+ }
950
+ ```
951
+
738
952
  ### Chat Reconnect with Authenticated User
739
953
 
740
954
  > See <https://docs.microsoft.com/en-us/dynamics365/customer-service/configure-reconnect-chat?tabs=customerserviceadmincenter#enable-reconnection-to-a-previous-chat-session> on how to set up chat reconnect
@@ -171,6 +171,17 @@ declare class OmnichannelChatSDK {
171
171
  sendMessage(message: ChatSDKMessage): Promise<OmnichannelMessage | void>;
172
172
  onNewMessage(onNewMessageCallback: CallableFunction, optionalParams?: OnNewMessageOptionalParams): Promise<void>;
173
173
  sendTypingEvent(): Promise<void>;
174
+ /**
175
+ * Fetches unread message count for the authenticated user.
176
+ * Auth-only — does not require an active chat session.
177
+ */
178
+ getUnreadMessageCount(): Promise<object>;
179
+ /**
180
+ * Sends a read receipt for a specific message.
181
+ * Authenticated: calls MRT (updates NRD + forwards to ACS).
182
+ * Unauthenticated: calls ACS directly.
183
+ */
184
+ sendReadReceipt(messageId: string): Promise<void>;
174
185
  onTypingEvent(onTypingEventCallback: CallableFunction): Promise<void>;
175
186
  onAgentEndSession(onAgentEndSessionCallback: (message: IRawThread | ParticipantsRemovedEvent) => void): Promise<void>;
176
187
  uploadFileAttachment(fileInfo: IFileInfo | File): Promise<UploadFileAttachmentResponse>;
@@ -2059,6 +2059,109 @@ var OmnichannelChatSDK = /** @class */ (function () {
2059
2059
  });
2060
2060
  });
2061
2061
  };
2062
+ /**
2063
+ * Fetches unread message count for the authenticated user.
2064
+ * Auth-only — does not require an active chat session.
2065
+ */
2066
+ OmnichannelChatSDK.prototype.getUnreadMessageCount = function () {
2067
+ return __awaiter(this, void 0, void 0, function () {
2068
+ var telemetryData, result, error_21, statusCode;
2069
+ var _a;
2070
+ return __generator(this, function (_b) {
2071
+ switch (_b.label) {
2072
+ case 0:
2073
+ telemetryData = {
2074
+ RequestId: this.requestId || ""
2075
+ };
2076
+ this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetUnreadMessageCount, telemetryData);
2077
+ if (!this.authenticatedUserToken) {
2078
+ exceptionThrowers_1.default.throwChatSDKError(ChatSDKError_1.ChatSDKErrorName.UndefinedAuthToken, undefined, this.scenarioMarker, TelemetryEvent_1.default.GetUnreadMessageCount, telemetryData, "getUnreadMessageCount is only supported for authenticated chats");
2079
+ }
2080
+ _b.label = 1;
2081
+ case 1:
2082
+ _b.trys.push([1, 3, , 4]);
2083
+ return [4 /*yield*/, this.OCClient.getUnreadMessageCount(this.authenticatedUserToken)];
2084
+ case 2:
2085
+ result = _b.sent();
2086
+ this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetUnreadMessageCount, telemetryData);
2087
+ return [2 /*return*/, result];
2088
+ case 3:
2089
+ error_21 = _b.sent();
2090
+ statusCode = (_a = error_21 === null || error_21 === void 0 ? void 0 : error_21.response) === null || _a === void 0 ? void 0 : _a.status;
2091
+ if (statusCode === 404) {
2092
+ exceptionThrowers_1.default.throwChatSDKError(ChatSDKError_1.ChatSDKErrorName.InvalidConversation, error_21, this.scenarioMarker, TelemetryEvent_1.default.GetUnreadMessageCount, telemetryData, "Conversation not found");
2093
+ }
2094
+ exceptionThrowers_1.default.throwUnreadMessageCountRetrievalFailure(error_21, this.scenarioMarker, TelemetryEvent_1.default.GetUnreadMessageCount, telemetryData);
2095
+ return [3 /*break*/, 4];
2096
+ case 4:
2097
+ // Unreachable — throwUnreadMessageCountRetrievalFailure always throws.
2098
+ // Required for TypeScript return type satisfaction.
2099
+ return [2 /*return*/, {}];
2100
+ }
2101
+ });
2102
+ });
2103
+ };
2104
+ /**
2105
+ * Sends a read receipt for a specific message.
2106
+ * Authenticated: calls MRT (updates NRD + forwards to ACS).
2107
+ * Unauthenticated: calls ACS directly.
2108
+ */
2109
+ OmnichannelChatSDK.prototype.sendReadReceipt = function (messageId) {
2110
+ return __awaiter(this, void 0, void 0, function () {
2111
+ var telemetryData, error_22, statusCode;
2112
+ var _a, _b;
2113
+ return __generator(this, function (_c) {
2114
+ switch (_c.label) {
2115
+ case 0:
2116
+ telemetryData = {
2117
+ RequestId: this.requestId,
2118
+ ChatId: ((_a = this.chatToken) === null || _a === void 0 ? void 0 : _a.chatId) || ""
2119
+ };
2120
+ this.scenarioMarker.startScenario(TelemetryEvent_1.default.SendReadReceipt, telemetryData);
2121
+ if (!this.isInitialized) {
2122
+ exceptionThrowers_1.default.throwUninitializedChatSDK(this.scenarioMarker, TelemetryEvent_1.default.SendReadReceipt);
2123
+ }
2124
+ if (!messageId) {
2125
+ exceptionThrowers_1.default.throwSendReadReceiptInvalidParams(this.scenarioMarker, TelemetryEvent_1.default.SendReadReceipt, telemetryData);
2126
+ }
2127
+ _c.label = 1;
2128
+ case 1:
2129
+ _c.trys.push([1, 6, , 7]);
2130
+ if (!this.authenticatedUserToken) return [3 /*break*/, 3];
2131
+ // Authenticated: call MRT which updates NRD and forwards to ACS
2132
+ return [4 /*yield*/, this.OCClient.sendReadReceipt(this.requestId, messageId, this.authenticatedUserToken)];
2133
+ case 2:
2134
+ // Authenticated: call MRT which updates NRD and forwards to ACS
2135
+ _c.sent();
2136
+ return [3 /*break*/, 5];
2137
+ case 3:
2138
+ // Unauthenticated: call ACS directly (no MRT, no NRD)
2139
+ if (!this.conversation) {
2140
+ exceptionThrowers_1.default.throwUninitializedChatSDK(this.scenarioMarker, TelemetryEvent_1.default.SendReadReceipt);
2141
+ }
2142
+ return [4 /*yield*/, this.conversation.sendReadReceipt(messageId)];
2143
+ case 4:
2144
+ _c.sent();
2145
+ _c.label = 5;
2146
+ case 5:
2147
+ this.scenarioMarker.completeScenario(TelemetryEvent_1.default.SendReadReceipt, telemetryData);
2148
+ return [3 /*break*/, 7];
2149
+ case 6:
2150
+ error_22 = _c.sent();
2151
+ statusCode = (_b = error_22 === null || error_22 === void 0 ? void 0 : error_22.response) === null || _b === void 0 ? void 0 : _b.status;
2152
+ if (statusCode === 404) {
2153
+ exceptionThrowers_1.default.throwChatSDKError(ChatSDKError_1.ChatSDKErrorName.InvalidConversation, error_22, this.scenarioMarker, TelemetryEvent_1.default.SendReadReceipt, telemetryData, "Conversation not found");
2154
+ }
2155
+ if (statusCode === 400) {
2156
+ exceptionThrowers_1.default.throwChatSDKError(ChatSDKError_1.ChatSDKErrorName.SendReadReceiptInvalidParams, error_22, this.scenarioMarker, TelemetryEvent_1.default.SendReadReceipt, telemetryData, "Invalid parameters");
2157
+ }
2158
+ exceptionThrowers_1.default.throwSendReadReceiptFailure(error_22, this.scenarioMarker, TelemetryEvent_1.default.SendReadReceipt, telemetryData);
2159
+ return [3 /*break*/, 7];
2160
+ case 7: return [2 /*return*/];
2161
+ }
2162
+ });
2163
+ });
2164
+ };
2062
2165
  OmnichannelChatSDK.prototype.onTypingEvent = function (onTypingEventCallback) {
2063
2166
  return __awaiter(this, void 0, void 0, function () {
2064
2167
  var _a;
@@ -2202,7 +2305,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
2202
2305
  };
2203
2306
  OmnichannelChatSDK.prototype.uploadFileAttachment = function (fileInfo) {
2204
2307
  return __awaiter(this, void 0, void 0, function () {
2205
- var amsClient, createObjectResponse, documentId, uploadDocumentResponse, fileIdsProperty, fileMetaProperty, sendMessageRequest, messageToSend, error_21, fileMetadata, messageToSend, error_22;
2308
+ var amsClient, createObjectResponse, documentId, uploadDocumentResponse, fileIdsProperty, fileMetaProperty, sendMessageRequest, messageToSend, error_23, fileMetadata, messageToSend, error_24;
2206
2309
  var _a, _b;
2207
2310
  return __generator(this, function (_c) {
2208
2311
  switch (_c.label) {
@@ -2271,7 +2374,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
2271
2374
  });
2272
2375
  return [2 /*return*/, messageToSend];
2273
2376
  case 6:
2274
- error_21 = _c.sent();
2377
+ error_23 = _c.sent();
2275
2378
  console.error("OmnichannelChatSDK/uploadFileAttachment/sendMessage/error");
2276
2379
  this.scenarioMarker.failScenario(TelemetryEvent_1.default.UploadFileAttachment, {
2277
2380
  RequestId: this.requestId,
@@ -2317,8 +2420,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
2317
2420
  });
2318
2421
  return [2 /*return*/, messageToSend];
2319
2422
  case 15:
2320
- error_22 = _c.sent();
2321
- console.error("OmnichannelChatSDK/uploadFileAttachment/error: ".concat(error_22));
2423
+ error_24 = _c.sent();
2424
+ console.error("OmnichannelChatSDK/uploadFileAttachment/error: ".concat(error_24));
2322
2425
  this.scenarioMarker.failScenario(TelemetryEvent_1.default.UploadFileAttachment, {
2323
2426
  RequestId: this.requestId,
2324
2427
  ChatId: this.chatToken.chatId
@@ -2331,7 +2434,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
2331
2434
  };
2332
2435
  OmnichannelChatSDK.prototype.downloadFileAttachment = function (fileMetadata) {
2333
2436
  return __awaiter(this, void 0, void 0, function () {
2334
- var amsClient, response, view_location, viewResponse, ex_1, downloadedFile, error_23;
2437
+ var amsClient, response, view_location, viewResponse, ex_1, downloadedFile, error_25;
2335
2438
  return __generator(this, function (_a) {
2336
2439
  switch (_a.label) {
2337
2440
  case 0:
@@ -2392,8 +2495,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
2392
2495
  });
2393
2496
  return [2 /*return*/, downloadedFile];
2394
2497
  case 9:
2395
- error_23 = _a.sent();
2396
- console.error("OmnichannelChatSDK/downloadFileAttachment/error: ".concat(error_23));
2498
+ error_25 = _a.sent();
2499
+ console.error("OmnichannelChatSDK/downloadFileAttachment/error: ".concat(error_25));
2397
2500
  this.scenarioMarker.failScenario(TelemetryEvent_1.default.DownloadFileAttachment, {
2398
2501
  RequestId: this.requestId,
2399
2502
  ChatId: this.chatToken.chatId
@@ -2406,7 +2509,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
2406
2509
  };
2407
2510
  OmnichannelChatSDK.prototype.emailLiveChatTranscript = function (body_1) {
2408
2511
  return __awaiter(this, arguments, void 0, function (body, optionalParams) {
2409
- var emailTranscriptOptionalParams, requestId, chatToken, chatId, sessionId, emailRequestBody, error_24;
2512
+ var emailTranscriptOptionalParams, requestId, chatToken, chatId, sessionId, emailRequestBody, error_26;
2410
2513
  var _a;
2411
2514
  if (optionalParams === void 0) { optionalParams = {}; }
2412
2515
  return __generator(this, function (_b) {
@@ -2457,8 +2560,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
2457
2560
  });
2458
2561
  return [3 /*break*/, 4];
2459
2562
  case 3:
2460
- error_24 = _b.sent();
2461
- console.error("OmnichannelChatSDK/emailLiveChatTranscript/error: ".concat(error_24));
2563
+ error_26 = _b.sent();
2564
+ console.error("OmnichannelChatSDK/emailLiveChatTranscript/error: ".concat(error_26));
2462
2565
  this.scenarioMarker.failScenario(TelemetryEvent_1.default.EmailLiveChatTranscript, {
2463
2566
  RequestId: requestId,
2464
2567
  ChatId: chatId
@@ -2471,7 +2574,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
2471
2574
  };
2472
2575
  OmnichannelChatSDK.prototype.getLiveChatTranscript = function () {
2473
2576
  return __awaiter(this, arguments, void 0, function (optionalParams) {
2474
- var getChatTranscriptOptionalParams, requestId, chatToken, chatId, sessionId, transcriptResponse, error_25, telemetryData;
2577
+ var getChatTranscriptOptionalParams, requestId, chatToken, chatId, sessionId, transcriptResponse, error_27, telemetryData;
2475
2578
  var _a, _b;
2476
2579
  if (optionalParams === void 0) { optionalParams = {}; }
2477
2580
  return __generator(this, function (_c) {
@@ -2528,12 +2631,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
2528
2631
  });
2529
2632
  return [2 /*return*/, transcriptResponse];
2530
2633
  case 3:
2531
- error_25 = _c.sent();
2634
+ error_27 = _c.sent();
2532
2635
  telemetryData = {
2533
2636
  RequestId: requestId,
2534
2637
  ChatId: chatId
2535
2638
  };
2536
- exceptionThrowers_1.default.throwLiveChatTranscriptRetrievalFailure(error_25, this.scenarioMarker, TelemetryEvent_1.default.GetLiveChatTranscript, telemetryData);
2639
+ exceptionThrowers_1.default.throwLiveChatTranscriptRetrievalFailure(error_27, this.scenarioMarker, TelemetryEvent_1.default.GetLiveChatTranscript, telemetryData);
2537
2640
  return [3 /*break*/, 4];
2538
2641
  case 4: return [2 /*return*/];
2539
2642
  }
@@ -2853,7 +2956,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
2853
2956
  };
2854
2957
  OmnichannelChatSDK.prototype.authenticateChat = function (tokenOrProvider_1) {
2855
2958
  return __awaiter(this, arguments, void 0, function (tokenOrProvider, optionalParams) {
2856
- var telemetryData, token, _a, e_9, exceptionDetails, exceptionDetails, error_26, exceptionDetails;
2959
+ var telemetryData, token, _a, e_9, exceptionDetails, exceptionDetails, error_28, exceptionDetails;
2857
2960
  var _b, _c, _d, _e, _f;
2858
2961
  if (optionalParams === void 0) { optionalParams = {}; }
2859
2962
  return __generator(this, function (_g) {
@@ -2924,10 +3027,10 @@ var OmnichannelChatSDK = /** @class */ (function () {
2924
3027
  this.scenarioMarker.completeScenario(TelemetryEvent_1.default.MidConversationAuth, telemetryData);
2925
3028
  return [3 /*break*/, 12];
2926
3029
  case 11:
2927
- error_26 = _g.sent();
3030
+ error_28 = _g.sent();
2928
3031
  exceptionDetails = {
2929
3032
  response: ChatSDKError_1.ChatSDKErrorName.MidConversationAuthFailure,
2930
- errorObject: "".concat(error_26)
3033
+ errorObject: "".concat(error_28)
2931
3034
  };
2932
3035
  this.scenarioMarker.failScenario(TelemetryEvent_1.default.MidConversationAuth, __assign(__assign({}, telemetryData), { ExceptionDetails: JSON.stringify(exceptionDetails) }));
2933
3036
  throw new ChatSDKError_1.ChatSDKError(ChatSDKError_1.ChatSDKErrorName.MidConversationAuthFailure, undefined, exceptionDetails);
@@ -3168,7 +3271,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
3168
3271
  };
3169
3272
  OmnichannelChatSDK.prototype.getChatConfig = function () {
3170
3273
  return __awaiter(this, arguments, void 0, function (optionalParams) {
3171
- var sendCacheHeaders, bypassCache, liveChatConfig, error_27, _a;
3274
+ var sendCacheHeaders, bypassCache, liveChatConfig, error_29, _a;
3172
3275
  var _b, _c;
3173
3276
  if (optionalParams === void 0) { optionalParams = {}; }
3174
3277
  return __generator(this, function (_d) {
@@ -3189,8 +3292,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
3189
3292
  this.debug && console.log("[OmnichannelChatSDK][getChatConfig][liveChatVersion] ".concat(this.liveChatVersion));
3190
3293
  return [2 /*return*/, this.liveChatConfig];
3191
3294
  case 3:
3192
- error_27 = _d.sent();
3193
- if (!(0, internalUtils_1.isCoreServicesOrgUrlDNSError)(error_27, this.coreServicesOrgUrl, this.dynamicsLocationCode)) return [3 /*break*/, 6];
3295
+ error_29 = _d.sent();
3296
+ if (!(0, internalUtils_1.isCoreServicesOrgUrlDNSError)(error_29, this.coreServicesOrgUrl, this.dynamicsLocationCode)) return [3 /*break*/, 6];
3194
3297
  this.omnichannelConfig.orgUrl = this.unqServicesOrgUrl;
3195
3298
  _a = this;
3196
3299
  return [4 /*yield*/, ocsdk_1.SDKProvider.getSDK(this.omnichannelConfig, (0, createOcSDKConfiguration_1.default)(false), this.ocSdkLogger)];
@@ -3202,10 +3305,10 @@ var OmnichannelChatSDK = /** @class */ (function () {
3202
3305
  return [3 /*break*/, 7];
3203
3306
  case 6:
3204
3307
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
3205
- if (((_c = (_b = error_27.response) === null || _b === void 0 ? void 0 : _b.headers) === null || _c === void 0 ? void 0 : _c.errorcode) && parseInt(error_27.response.headers.errorcode) === OmnichannelErrorCodes_1.default.WidgetNotFound) {
3308
+ if (((_c = (_b = error_29.response) === null || _b === void 0 ? void 0 : _b.headers) === null || _c === void 0 ? void 0 : _c.errorcode) && parseInt(error_29.response.headers.errorcode) === OmnichannelErrorCodes_1.default.WidgetNotFound) {
3206
3309
  console.warn("No widget with the given app id is present in the system.");
3207
3310
  }
3208
- throw error_27; // Bubble up error by default to throw ChatConfigRetrievalFailure
3311
+ throw error_29; // Bubble up error by default to throw ChatConfigRetrievalFailure
3209
3312
  case 7: return [3 /*break*/, 8];
3210
3313
  case 8: return [2 /*return*/, this.liveChatConfig];
3211
3314
  }
@@ -3240,7 +3343,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
3240
3343
  };
3241
3344
  OmnichannelChatSDK.prototype.updateChatToken = function (newToken, newRegionGTMS) {
3242
3345
  return __awaiter(this, void 0, void 0, function () {
3243
- var sessionInfo, error_28, exceptionDetails;
3346
+ var sessionInfo, error_30, exceptionDetails;
3244
3347
  return __generator(this, function (_a) {
3245
3348
  switch (_a.label) {
3246
3349
  case 0:
@@ -3268,7 +3371,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
3268
3371
  });
3269
3372
  return [3 /*break*/, 5];
3270
3373
  case 4:
3271
- error_28 = _a.sent();
3374
+ error_30 = _a.sent();
3272
3375
  exceptionDetails = {
3273
3376
  response: "UpdateChatTokenFailed"
3274
3377
  };
@@ -3285,7 +3388,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
3285
3388
  };
3286
3389
  OmnichannelChatSDK.prototype.setAuthTokenProvider = function (provider_1) {
3287
3390
  return __awaiter(this, arguments, void 0, function (provider, optionalParams) {
3288
- var token, exceptionDetails, error_29, exceptionDetails, exceptionDetails;
3391
+ var token, exceptionDetails, error_31, exceptionDetails, exceptionDetails;
3289
3392
  if (optionalParams === void 0) { optionalParams = {}; }
3290
3393
  return __generator(this, function (_a) {
3291
3394
  switch (_a.label) {
@@ -3317,12 +3420,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
3317
3420
  }
3318
3421
  return [3 /*break*/, 4];
3319
3422
  case 3:
3320
- error_29 = _a.sent();
3423
+ error_31 = _a.sent();
3321
3424
  exceptionDetails = {
3322
3425
  response: ChatSDKError_1.ChatSDKErrorName.GetAuthTokenFailed
3323
3426
  };
3324
- if (error_29.message == ChatSDKError_1.ChatSDKErrorName.UndefinedAuthToken) {
3325
- exceptionDetails.response = error_29.message;
3427
+ if (error_31.message == ChatSDKError_1.ChatSDKErrorName.UndefinedAuthToken) {
3428
+ exceptionDetails.response = error_31.message;
3326
3429
  }
3327
3430
  this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
3328
3431
  ExceptionDetails: JSON.stringify(exceptionDetails)
@@ -3421,7 +3524,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
3421
3524
  */
3422
3525
  OmnichannelChatSDK.prototype.getPersistentChatHistory = function () {
3423
3526
  return __awaiter(this, arguments, void 0, function (getPersistentChatHistoryOptionalParams) {
3424
- var params, result, error_30, telemetryData;
3527
+ var params, result, error_32, telemetryData;
3425
3528
  var _a, _b, _c, _d, _e;
3426
3529
  if (getPersistentChatHistoryOptionalParams === void 0) { getPersistentChatHistoryOptionalParams = {}; }
3427
3530
  return __generator(this, function (_f) {
@@ -3463,13 +3566,13 @@ var OmnichannelChatSDK = /** @class */ (function () {
3463
3566
  });
3464
3567
  return [2 /*return*/, result];
3465
3568
  case 3:
3466
- error_30 = _f.sent();
3569
+ error_32 = _f.sent();
3467
3570
  telemetryData = {
3468
3571
  RequestId: this.requestId,
3469
3572
  ChatId: (_e = this.chatToken) === null || _e === void 0 ? void 0 : _e.chatId,
3470
- ErrorMessage: (error_30 === null || error_30 === void 0 ? void 0 : error_30.message) || 'Unknown error' // Added error message for better debugging
3573
+ ErrorMessage: (error_32 === null || error_32 === void 0 ? void 0 : error_32.message) || 'Unknown error' // Added error message for better debugging
3471
3574
  };
3472
- exceptionThrowers_1.default.throwPersistentChatConversationRetrievalFailure(error_30, this.scenarioMarker, TelemetryEvent_1.default.GetPersistentChatHistory, telemetryData);
3575
+ exceptionThrowers_1.default.throwPersistentChatConversationRetrievalFailure(error_32, this.scenarioMarker, TelemetryEvent_1.default.GetPersistentChatHistory, telemetryData);
3473
3576
  return [3 /*break*/, 4];
3474
3577
  case 4: return [2 /*return*/];
3475
3578
  }