@microsoft/omnichannel-chat-sdk 1.11.9-main.e47a43c → 2.0.0-main.307c235

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.
Files changed (55) hide show
  1. package/README.md +325 -11
  2. package/lib/OmnichannelChatSDK.d.ts +38 -0
  3. package/lib/OmnichannelChatSDK.js +276 -43
  4. package/lib/OmnichannelChatSDK.js.map +1 -1
  5. package/lib/config/settings.d.ts +2 -2
  6. package/lib/config/settings.js +2 -2
  7. package/lib/config/settings.js.map +1 -1
  8. package/lib/core/ChatSDKError.d.ts +11 -1
  9. package/lib/core/ChatSDKError.js +10 -0
  10. package/lib/core/ChatSDKError.js.map +1 -1
  11. package/lib/core/ChatSDKExceptionDetails.d.ts +6 -0
  12. package/lib/core/StartChatOptionalParams.d.ts +10 -0
  13. package/lib/core/messaging/ACSClient.d.ts +7 -0
  14. package/lib/core/messaging/ACSClient.js +216 -12
  15. package/lib/core/messaging/ACSClient.js.map +1 -1
  16. package/lib/core/messaging/OmnichannelStreamingMessage.d.ts +13 -0
  17. package/lib/core/messaging/OmnichannelStreamingMessage.js +3 -0
  18. package/lib/core/messaging/OmnichannelStreamingMessage.js.map +1 -0
  19. package/lib/core/messaging/OnStreamingMessageOptionalParams.d.ts +8 -0
  20. package/lib/core/messaging/OnStreamingMessageOptionalParams.js +3 -0
  21. package/lib/core/messaging/OnStreamingMessageOptionalParams.js.map +1 -0
  22. package/lib/core/messaging/PolicyViolation.d.ts +8 -0
  23. package/lib/core/messaging/PolicyViolation.js +3 -0
  24. package/lib/core/messaging/PolicyViolation.js.map +1 -0
  25. package/lib/core/messaging/StreamingMetadata.d.ts +11 -0
  26. package/lib/core/messaging/StreamingMetadata.js +3 -0
  27. package/lib/core/messaging/StreamingMetadata.js.map +1 -0
  28. package/lib/index.d.ts +5 -1
  29. package/lib/index.js.map +1 -1
  30. package/lib/telemetry/MessageSource.d.ts +1 -0
  31. package/lib/telemetry/MessageSource.js +1 -0
  32. package/lib/telemetry/MessageSource.js.map +1 -1
  33. package/lib/telemetry/TelemetryEvent.d.ts +23 -1
  34. package/lib/telemetry/TelemetryEvent.js +23 -0
  35. package/lib/telemetry/TelemetryEvent.js.map +1 -1
  36. package/lib/tsconfig.tsbuildinfo +1 -1
  37. package/lib/utils/createOmnichannelMessage.js +27 -1
  38. package/lib/utils/createOmnichannelMessage.js.map +1 -1
  39. package/lib/utils/createOmnichannelStreamingMessage.d.ts +14 -0
  40. package/lib/utils/createOmnichannelStreamingMessage.js +106 -0
  41. package/lib/utils/createOmnichannelStreamingMessage.js.map +1 -0
  42. package/lib/utils/errorClassifier.d.ts +25 -0
  43. package/lib/utils/errorClassifier.js +75 -0
  44. package/lib/utils/errorClassifier.js.map +1 -0
  45. package/lib/utils/exceptionThrowers.d.ts +38 -4
  46. package/lib/utils/exceptionThrowers.js +25 -8
  47. package/lib/utils/exceptionThrowers.js.map +1 -1
  48. package/lib/utils/printers/MessagePrinterFactory.d.ts +3 -2
  49. package/lib/utils/printers/MessagePrinterFactory.js +6 -0
  50. package/lib/utils/printers/MessagePrinterFactory.js.map +1 -1
  51. package/lib/utils/printers/StreamingMessagePrinter.d.ts +5 -0
  52. package/lib/utils/printers/StreamingMessagePrinter.js +33 -0
  53. package/lib/utils/printers/StreamingMessagePrinter.js.map +1 -0
  54. package/lib/utils/printers/types/MessageType.d.ts +2 -1
  55. package/package.json +14 -8
package/README.md CHANGED
@@ -2,12 +2,12 @@
2
2
 
3
3
  [![npm version](https://badge.fury.io/js/%40microsoft%2Fomnichannel-chat-sdk.svg)](https://badge.fury.io/js/%40microsoft%2Fomnichannel-chat-sdk)
4
4
  [![install size](https://packagephobia.com/badge?p=@microsoft/omnichannel-chat-sdk)](https://packagephobia.com/result?p=@microsoft/omnichannel-chat-sdk)
5
- ![Release CI](https://github.com/microsoft/omnichannel-chat-sdk/workflows/Release%20CI/badge.svg)
5
+ [![npm Release](https://github.com/microsoft/omnichannel-chat-sdk/actions/workflows/npm-release.yml/badge.svg)](https://github.com/microsoft/omnichannel-chat-sdk/actions/workflows/npm-release.yml)
6
6
  ![npm](https://img.shields.io/npm/dm/@microsoft/omnichannel-chat-sdk)
7
7
 
8
- > ❗ We recommend using official release versions in production as listed [here](#releases). Support will be provided only on official versions.
9
-
10
- > 📢 Try out our new React component library [omnichannel-chat-widget](https://github.com/microsoft/omnichannel-chat-widget) with Chat SDK
8
+ > [!IMPORTANT]
9
+ > * We recommend using official release versions in production as listed [here](#releases). Support will be provided only on official versions.
10
+ > * Microsoft provides this SDK to ensure a scaleable and secure use of our platform. Do not directly access the APIs used in this repository — you may experience breaking changes, and we will not be able to provide support for any issues.
11
11
 
12
12
  Headless Chat SDK to build your own chat widget against Dynamics 365 Omnichannel Services.
13
13
 
@@ -22,6 +22,7 @@ Please make sure you have a chat widget configured before using this package or
22
22
  - [SDK Methods](#sdk-methods)
23
23
  - [Initialization](#initialization)
24
24
  - [Start Chat](#start-chat)
25
+ - [Authenticate Chat](#authenticate-chat)
25
26
  - [End Chat](#end-chat)
26
27
  - [Get Pre-Chat Survey](#get-pre-chat-survey)
27
28
  - [Get Live Chat Config](#get-live-chat-config)
@@ -34,6 +35,7 @@ Please make sure you have a chat widget configured before using this package or
34
35
  - [Get Messages](#get-messages)
35
36
  - [Send Messages](#send-messages)
36
37
  - [On New Message](#on-new-message)
38
+ - [On Streaming Message](#on-streaming-message)
37
39
  - [On Typing Event](#on-typing-event)
38
40
  - [On Agent End Session](#on-agent-end-session)
39
41
  - [Send Typing Event](#send-typing-event)
@@ -44,6 +46,9 @@ Please make sure you have a chat widget configured before using this package or
44
46
  - [Create Chat Adapter](#create-chat-adapter)
45
47
  - [Get Voice & Video Calling](#get-voice--video-calling)
46
48
  - [Get Post Chat Survey Context](#get-post-chat-survey-context)
49
+ - [Get Persistent Chat History](#get-persistent-chat-history)
50
+ - [Send Read Receipt](#send-read-receipt)
51
+ - [Get Unread Message Count](#get-unread-message-count)
47
52
  - [Common Scenarios](#common-scenarios)
48
53
  - [Using BotFramework-WebChat](#using-botframework-webchat)
49
54
  - [Escalation to Voice & Video](#escalation-to-voice--video)
@@ -52,9 +57,10 @@ Please make sure you have a chat widget configured before using this package or
52
57
  - [Reconnect to existing Chat](#reconnect-to-existing-chat)
53
58
  - [Authenticated Chat](#authenticated-chat)
54
59
  - [Persistent Chat](#persistent-chat)
60
+ - [Persistent Chat History](#persistent-chat-history)
55
61
  - [Chat Reconnect with Authenticated User](#chat-reconnect-with-authenticated-user)
56
62
  - [Chat Reconnect with Unauthenticated User](#chat-reconnect-with-unauthenticated-user)
57
- - [Best Practices for Chat Session Management: Handling Disconnections and Network Instabilit(#best-practices-for-chat-session-management:-handling-disconnections-and-network-instability)
63
+ - [Best Practices for Chat Session Management: Handling Disconnections and Network Instability](#best-practices-for-chat-session-management-handling-disconnections-and-network-instability)
58
64
  - [Operating Hours](#operating-hours)
59
65
  - [Single Sign-on for Bots](/docs/scenarios/SINGLE_SIGN_ON_FOR_BOTS.md)
60
66
  - [Sample Apps](https://github.com/microsoft/omnichannel-chat-sdk-samples)
@@ -104,22 +110,39 @@ Omnichannel offers a live chat widget (LCW) by default. You can use the Chat SDK
104
110
 
105
111
  New releases are published on a regular basis to ensure the product quality.
106
112
 
107
- for a detailed tracking of the releases, please refer to the [Changelog document](https://github.com/microsoft/omnichannel-chat-sdk/blob/main/CHANGELOG.md)
108
-
109
- _**Important Note:**_ Versions below 1.11.0 will not be supported after November 1st, 2025. Please update to recent versions to ensure you have the latest features and bug fixes.
113
+ For a detailed tracking of the releases, please refer to the [Changelog document](https://github.com/microsoft/omnichannel-chat-sdk/blob/main/CHANGELOG.md)
110
114
 
115
+ _**Important Note:**_ Versions below 1.11.0 are no longer supported after November 1st, 2025. Please update to recent versions to ensure you have the latest features and bug fixes.
111
116
 
112
117
  | Version | Docs | Release Date | End of Support | Deprecated |
113
118
  | -- | -- | -- | -- | -- |
119
+ | 2.0.0 | [Migration Guide](docs/MIGRATION_2.0.md) / [Release Notes](https://github.com/microsoft/omnichannel-chat-sdk/releases/tag/v2.0.0) | Aug 13th 2026 | Aug 13th 2027 | |
114
120
  | 1.11.4 | [Release Notes](https://github.com/microsoft/omnichannel-chat-sdk/releases/tag/v1.11.4) | Jul 17th 2025 | Jul 17th 2026 | |
115
121
  | 1.11.3 | [Release Notes](https://github.com/microsoft/omnichannel-chat-sdk/releases/tag/v1.11.3) | Jul 14th 2025 | Jul 14th 2026 | |
116
122
  | 1.11.2 | [Release Notes](https://github.com/microsoft/omnichannel-chat-sdk/releases/tag/v1.11.2) | Jun 24th 2025 | Jun 24th 2026 | |
117
123
  | 1.11.1 | [Release Notes](https://github.com/microsoft/omnichannel-chat-sdk/releases/tag/v1.11.1) | Jun 5th 2025 | Jun 5th 2026 | |
118
124
  | 1.11.0 | [Release Notes](https://github.com/microsoft/omnichannel-chat-sdk/releases/tag/v1.11.0) | May 27th 2025 | May 27th 2026 | |
119
125
 
126
+ ### Upgrade to 2.0.0
127
+
128
+ Version `2.0.0` requires Node.js `>=22.12.0`. This requirement also applies to the official OC SDK and AMS client dependencies.
129
+
130
+ ```bash
131
+ npm install @microsoft/omnichannel-chat-sdk@2.0.0 --save-exact
132
+ ```
133
+
134
+ The npm `latest` dist-tag can point to a `main` prerelease. Use the exact version for production.
135
+
136
+ Regenerate the application lockfile after the update. Then run the application build and tests on Node.js 22.
137
+
138
+ Version `2.0.0` adds progressive bot-message streaming, mid-conversation authentication, read receipts, and unread-message counts. Existing `onNewMessage` handlers continue to receive final streaming messages.
139
+
140
+ See the [2.0 migration guide](docs/MIGRATION_2.0.md) for the complete upgrade and validation procedure.
120
141
 
121
142
  ## Installation
122
143
 
144
+ Node.js `>=22.12.0` is required.
145
+
123
146
  ```console
124
147
  npm install @microsoft/omnichannel-chat-sdk --save
125
148
  ```
@@ -308,6 +331,32 @@ const optionalParams = {
308
331
  await chatSDK.startChat(optionalParams);
309
332
  ```
310
333
 
334
+ ### Authenticate Chat
335
+
336
+ It authenticates an active unauthenticated conversation. Enable optional authenticated sign-in for the workstream before you use this method.
337
+
338
+ Call `initialize()` and `startChat()` before `authenticateChat()`. The first argument can be a token or an asynchronous token provider.
339
+
340
+ ```ts
341
+ await chatSDK.initialize();
342
+ await chatSDK.startChat();
343
+
344
+ await chatSDK.authenticateChat(async () => {
345
+ const response = await fetch("https://contoso.example/token");
346
+ if (!response.ok) {
347
+ throw new Error("Token request failed");
348
+ }
349
+
350
+ return response.text();
351
+ }, {
352
+ refreshChatToken: true
353
+ });
354
+ ```
355
+
356
+ Set `refreshChatToken` to `true` when subsequent SDK calls must use a refreshed authenticated chat token.
357
+
358
+ The method throws `InvalidConversation` when no conversation is active. It throws `MidConversationAuthFailure` when token resolution or authentication fails.
359
+
311
360
  ### End Chat
312
361
 
313
362
  It ends the current Omnichannel conversation.
@@ -452,6 +501,38 @@ chatSDK.onNewMessage((message) => {
452
501
  }, optionalParams);
453
502
  ```
454
503
 
504
+ ### On Streaming Message
505
+
506
+ It subscribes to progressive ACS bot-message updates. This API is available only for Live Chat version 2.
507
+
508
+ Enable streaming when you start the conversation. Then register the handler after `startChat()` completes.
509
+
510
+ ```ts
511
+ await chatSDK.initialize();
512
+ await chatSDK.startChat({
513
+ supportsLcwStreaming: true
514
+ });
515
+
516
+ await chatSDK.onStreamingMessage((message) => {
517
+ const { streamingMessageType, streamEndReason } = message.streamingMetadata;
518
+
519
+ // Each event contains the full assembled content, not only the new text.
520
+ renderStreamingMessage(message.id, message.content);
521
+
522
+ if (message.policyViolation) {
523
+ handlePolicyViolation(message.policyViolation.result);
524
+ }
525
+
526
+ if (streamingMessageType === "final") {
527
+ completeStreamingMessage(message.id, streamEndReason);
528
+ }
529
+ });
530
+ ```
531
+
532
+ `streamingMessageType` can be `start`, `informative`, `streaming`, or `final`. A final message also reaches existing `onNewMessage` handlers.
533
+
534
+ Calling this method before `startChat()` throws `UninitializedConversation`. Calling it for another Live Chat version throws `UnsupportedLiveChatVersion`.
535
+
455
536
  ### On Typing Event
456
537
 
457
538
  It subscribes to an agent typing event.
@@ -579,6 +660,24 @@ It gets the participant type that should be used for the survey and both the def
579
660
  const postChatSurveyContext = await chatSDK.getPostChatSurveyContext();
580
661
  ```
581
662
 
663
+ ### Get Persistent Chat History
664
+
665
+ 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.
666
+
667
+ > :warning: Requires **persistent chat** to be enabled and the user must be **authenticated**.
668
+
669
+ ```ts
670
+ const optionalParams = {
671
+ pageSize: 25, // Number of messages per page (optional)
672
+ pageToken: '' // Token from a previous response to fetch the next page (optional, omit for first call)
673
+ };
674
+
675
+ const response = await chatSDK.getPersistentChatHistory(optionalParams);
676
+
677
+ // response.chatMessages: PersistentChatHistoryMessage[] — Array of chat messages
678
+ // response.nextPageToken: string | null — Token to pass in the next call; null means no more history
679
+ ```
680
+
582
681
  ### Get Agent Availability
583
682
 
584
683
  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.
@@ -587,6 +686,27 @@ It gets information on whether a queue is available, and whether there are agent
587
686
  const agentAvailability = await chatSDK.getAgentAvailability();
588
687
  ```
589
688
 
689
+ ### Send Read Receipt
690
+
691
+ Logs a particular message (and all previous messages) as read by the user. Read indicators will appear for Contact Center Representatives and Admins in the Admin Center.
692
+
693
+ Authenticated chat sends the receipt through Messaging Runtime. Unauthenticated chat sends it through ACS and requires Live Chat version 2.
694
+
695
+ ```ts
696
+ await chatSDK.sendReadReceipt(messageId: string);
697
+ ```
698
+
699
+ ### Get Unread Message Count
700
+
701
+ Returns unread-message data for an authenticated user. An active chat session is not required. This call is **authenticated-only** — the user must be authenticated, otherwise an `UndefinedAuthToken` error is thrown.
702
+
703
+ ```ts
704
+ const response = await chatSDK.getUnreadMessageCount();
705
+
706
+ // response.unreadMessageCount: number — Number of unread messages in the conversation
707
+ // response.mostRecentUnreadMessage: object | null — The most recent unread message, or null if there are none
708
+ ```
709
+
590
710
  ## Common Scenarios
591
711
 
592
712
  ### Pre-Chat Survey
@@ -735,6 +855,200 @@ await chatSDK.initialize();
735
855
  // from this point, this acts like a persistent chat
736
856
  ```
737
857
 
858
+ ### Persistent Chat History
859
+
860
+ > See <https://docs.microsoft.com/en-us/dynamics365/customer-service/persistent-chat> on how to set up persistent chat
861
+
862
+ 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).
863
+
864
+ > :warning: **Prerequisites:**
865
+ > - Persistent chat must be **enabled** in the admin portal (conversation mode set to Persistent Chat) and in the SDK config (`persistentChat.disable: false`)
866
+ > - The user must be **authenticated** (`getAuthToken` must be configured)
867
+ > - `chatSDK.initialize()` and `chatSDK.startChat()` must be called before fetching history
868
+ > - Chat history is available for up to **12 months**
869
+
870
+ #### Page Size
871
+
872
+ The `pageSize` parameter controls how many messages are returned per call.
873
+
874
+ | | Value |
875
+ | --- | --- |
876
+ | **Default** | `50` (used when `pageSize` is omitted) |
877
+ | **Minimum** | `1` |
878
+ | **Maximum** | `100` |
879
+
880
+ If `pageSize` is not provided, the backend defaults to **50**. Values outside the 1–100 range will be rejected with an error.
881
+
882
+ #### How Pagination Works
883
+
884
+ | Call | `pageToken` param | What happens |
885
+ | --- | --- | --- |
886
+ | **First call** | Omit or `undefined` | Fetches the most recent page of messages. The response includes `nextPageToken` if older messages exist. |
887
+ | **Subsequent calls** | Pass the `nextPageToken` from the previous response | Fetches the next (older) page. Again returns `nextPageToken` if more messages remain. |
888
+ | **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. |
889
+
890
+ 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.
891
+
892
+ #### Basic Usage
893
+
894
+ ```ts
895
+ const chatSDKConfig = {
896
+ persistentChat: {
897
+ disable: false,
898
+ tokenUpdateTime: 21600000
899
+ },
900
+ getAuthToken: async () => {
901
+ const response = await fetch("http://contosohelp.com/token");
902
+ if (response.ok) {
903
+ return await response.text();
904
+ }
905
+ else {
906
+ return null
907
+ }
908
+ }
909
+ }
910
+
911
+ const chatSDK = new OmnichannelChatSDK.OmnichannelChatSDK(omnichannelConfig, chatSDKConfig);
912
+ await chatSDK.initialize();
913
+
914
+ await chatSDK.startChat();
915
+
916
+ // Fetch the first page of chat history
917
+ const history = await chatSDK.getPersistentChatHistory({
918
+ pageSize: 25
919
+ });
920
+
921
+ if (history) {
922
+ // Render messages
923
+ history.chatMessages.forEach((message) => {
924
+ console.log(`[${message.createdDateTime}] ${message.content}`);
925
+ });
926
+
927
+ // Check if more history is available
928
+ if (history.nextPageToken) {
929
+ console.log("More history available");
930
+ }
931
+ }
932
+ ```
933
+
934
+ #### Pagination — Loading More History on Scroll Up
935
+
936
+ 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.
937
+
938
+ ```ts
939
+ // After the first call (Basic Usage above), save the nextPageToken
940
+ let pageToken: string | undefined = history?.nextPageToken ?? undefined;
941
+
942
+ // Example: fetch the next page when the customer scrolls up
943
+ const loadMoreHistory = async () => {
944
+ if (!pageToken) {
945
+ console.log("No more history to load");
946
+ return;
947
+ }
948
+
949
+ const response = await chatSDK.getPersistentChatHistory({
950
+ pageSize: 25,
951
+ pageToken
952
+ });
953
+
954
+ if (response && response.chatMessages.length > 0) {
955
+ // Render the older messages in the chat UI
956
+ response.chatMessages.forEach((message) => {
957
+ console.log(`[${message.createdDateTime}] ${message.content}`);
958
+ });
959
+
960
+ // Update the token for the next scroll-up action
961
+ pageToken = response.nextPageToken ?? undefined;
962
+ }
963
+ };
964
+
965
+ // Bind to your scroll-up event (e.g., user reaches the top of the chat container)
966
+ chatContainer.addEventListener('scroll', () => {
967
+ if (chatContainer.scrollTop === 0) {
968
+ loadMoreHistory();
969
+ }
970
+ });
971
+ ```
972
+
973
+ Alternatively, to fetch all history at once in a loop:
974
+
975
+ ```ts
976
+ let token: string | undefined = history?.nextPageToken ?? undefined;
977
+ let allMessages = [...(history?.chatMessages ?? [])];
978
+
979
+ while (token) {
980
+ const response = await chatSDK.getPersistentChatHistory({
981
+ pageSize: 25,
982
+ pageToken: token
983
+ });
984
+
985
+ if (response && response.chatMessages.length > 0) {
986
+ allMessages = [...allMessages, ...response.chatMessages];
987
+ token = response.nextPageToken ?? undefined;
988
+ } else {
989
+ break;
990
+ }
991
+ }
992
+
993
+ console.log(`Total messages retrieved: ${allMessages.length}`);
994
+ ```
995
+
996
+ #### Response Shape
997
+
998
+ The response type is exported from the SDK and can be imported for TypeScript usage:
999
+
1000
+ ```ts
1001
+ import { GetPersistentChatHistoryResponse } from '@microsoft/omnichannel-chat-sdk';
1002
+ ```
1003
+
1004
+ ```ts
1005
+ type GetPersistentChatHistoryResponse = {
1006
+ chatMessages: PersistentChatHistoryMessage[];
1007
+ nextPageToken: string | null; // null when no more pages
1008
+ }
1009
+
1010
+ type PersistentChatHistoryMessage = {
1011
+ content: string; // Message text
1012
+ contentType: number; // Content type identifier
1013
+ createdDateTime: string; // ISO 8601 timestamp
1014
+ from: {
1015
+ application: { // Sender application info
1016
+ displayName: string; // e.g., agent name or bot name
1017
+ id: string;
1018
+ } | null;
1019
+ };
1020
+ id: string; // Unique message identifier
1021
+ attachments: unknown[]; // File attachments if any
1022
+ additionalData: {
1023
+ deliveryMode: string; // Delivery channel
1024
+ ConversationId: string; // Conversation the message belongs to
1025
+ tags: string; // Message tags
1026
+ };
1027
+ }
1028
+ ```
1029
+
1030
+ #### Error Handling
1031
+
1032
+ ```ts
1033
+ try {
1034
+ const history = await chatSDK.getPersistentChatHistory({ pageSize: 25 });
1035
+ // Process messages...
1036
+ } catch (error) {
1037
+ if (error.message === 'ChatSDKNotInitialized') {
1038
+ // SDK not initialized — call chatSDK.initialize() first
1039
+ }
1040
+ if (error.message === 'PersistentChatNotEnabled') {
1041
+ // Persistent chat is not enabled for this widget
1042
+ }
1043
+ if (error.message === 'AuthenticatedUserTokenNotFound') {
1044
+ // User is not authenticated — configure getAuthToken
1045
+ }
1046
+ if (error.message === 'PersistentChatConversationRetrievalFailure') {
1047
+ // Server error fetching history — retry or handle gracefully
1048
+ }
1049
+ }
1050
+ ```
1051
+
738
1052
  ### Chat Reconnect with Authenticated User
739
1053
 
740
1054
  > 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
@@ -1088,11 +1402,11 @@ const chatSDK = new OmnichannelChatSDK.OmnichannelChatSDK(omnichannelConfig, cha
1088
1402
  await chatSDK.initialize();
1089
1403
  ```
1090
1404
 
1091
- # Releasing
1405
+ ## Releasing
1092
1406
 
1093
- See [docs/RELEASING.md](docs/RELEASING.md) for how to publish new versions to npm.
1407
+ See [docs/RELEASING.md](docs/RELEASING.md) for development builds, official npm and GitHub releases, release notes, and hotfixes.
1094
1408
 
1095
- # Contributing
1409
+ ## Contributing
1096
1410
 
1097
1411
  This project welcomes contributions and suggestions. Most contributions require you to agree to a
1098
1412
  Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
@@ -30,7 +30,9 @@ import InitializeOptionalParams from "./core/InitializeOptionalParams";
30
30
  import LiveWorkItemDetails from "./core/LiveWorkItemDetails";
31
31
  import OmnichannelConfig from "./core/OmnichannelConfig";
32
32
  import OmnichannelMessage from "./core/messaging/OmnichannelMessage";
33
+ import OmnichannelStreamingMessage from "./core/messaging/OmnichannelStreamingMessage";
33
34
  import OnNewMessageOptionalParams from "./core/messaging/OnNewMessageOptionalParams";
35
+ import OnStreamingMessageOptionalParams from "./core/messaging/OnStreamingMessageOptionalParams";
34
36
  import PostChatContext from "./core/PostChatContext";
35
37
  import StartChatOptionalParams from "./core/StartChatOptionalParams";
36
38
  declare class OmnichannelChatSDK {
@@ -171,7 +173,36 @@ declare class OmnichannelChatSDK {
171
173
  sendMessage(message: ChatSDKMessage): Promise<OmnichannelMessage | void>;
172
174
  onNewMessage(onNewMessageCallback: CallableFunction, optionalParams?: OnNewMessageOptionalParams): Promise<void>;
173
175
  sendTypingEvent(): Promise<void>;
176
+ /**
177
+ * Fetches unread message count for the authenticated user.
178
+ * Auth-only — does not require an active chat session.
179
+ */
180
+ getUnreadMessageCount(): Promise<object>;
181
+ /**
182
+ * Sends a read receipt for a specific message.
183
+ * Authenticated: calls MRT (updates NRD + forwards to ACS).
184
+ * Unauthenticated: calls ACS directly.
185
+ */
186
+ sendReadReceipt(messageId: string): Promise<void>;
174
187
  onTypingEvent(onTypingEventCallback: CallableFunction): Promise<void>;
188
+ /**
189
+ * Subscribes to ACS-driven streaming message chunks for progressive bot message rendering.
190
+ * Each chunk contains the full assembled text so far (not just the delta).
191
+ * Existing onNewMessage consumers continue receiving final messages without changes.
192
+ *
193
+ * Available only in LiveChatVersion.V2. Must call startChat() before registering.
194
+ *
195
+ * @param onStreamingMessageCallback - Called for each streaming chunk
196
+ * @param optionalParams - Reserved for future configuration
197
+ * @example
198
+ * chatSDK.onStreamingMessage((message) => {
199
+ * switch (message.streamingMetadata.streamingMessageType) {
200
+ * case "streaming": // Update bubble with message.content
201
+ * case "final": // Stream complete
202
+ * }
203
+ * });
204
+ */
205
+ onStreamingMessage(onStreamingMessageCallback: (message: OmnichannelStreamingMessage) => void, optionalParams?: OnStreamingMessageOptionalParams): Promise<void>;
175
206
  onAgentEndSession(onAgentEndSessionCallback: (message: IRawThread | ParticipantsRemovedEvent) => void): Promise<void>;
176
207
  uploadFileAttachment(fileInfo: IFileInfo | File): Promise<UploadFileAttachmentResponse>;
177
208
  downloadFileAttachment(fileMetadata: FileMetadata | IFileMetadata): Promise<Blob>;
@@ -198,6 +229,13 @@ declare class OmnichannelChatSDK {
198
229
  private setCallingOptionConfiguration;
199
230
  private setLiveChatVersionConfiguration;
200
231
  private setWidgetSnippetBaseUrl;
232
+ /**
233
+ * Creates diagnostic data for getChatConfig errors using the error classifier
234
+ * @param e The error object
235
+ * @param clientElapsedMs Optional elapsed time in milliseconds from client's perspective
236
+ * @returns Diagnostic data with clientElapsedMs, online status, and cancellation reason
237
+ */
238
+ private createGetChatConfigDiagnosticData;
201
239
  private getChatConfig;
202
240
  private buildConfigurations;
203
241
  private resolveIC3ClientUrl;