Skip to content

Commit 243dcc1

Browse files
authored
Merge pull request #441 from elopezanaya/light-sdk-ams
Load AMS based on config definition
2 parents 700b056 + 04fcce1 commit 243dcc1

12 files changed

+409
-211
lines changed

CHANGELOG.md

+12
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,26 @@ All notable changes to this project will be documented in this file.
44

55
## [Unreleased]
66

7+
### Added
8+
9+
- Load AMS based on config.
10+
11+
### Fixed
12+
13+
- Fix for methods receiving exceptionDetails , but not logging it in telemetry
14+
- Fix to prevent double load of AMS
15+
- Fix to prevent startchat to finish before AMS client loads. (latency detected, future work to be part of AMS client enhancements)
16+
717
## [1.10.16] - 2025-03-27
818

919
### Added
20+
1021
- Added exception details for telemetry for SendMessage
1122
- Expose `OriginalMessageId` to `ChatSDK.onNewMessage()` to handle message ordering
1223
- Update `ChatSDK.sendMessage()` to return `OmnichannelMessage`
1324

1425
### Changed
26+
1527
- Uptake [@microsoft/ocsdk@0.5.13](https://www.npmjs.com/package/@microsoft/ocsdk/v/0.5.13)
1628

1729
## [1.10.15] - 2025-03-11

README.md

+89-69
Original file line numberDiff line numberDiff line change
@@ -14,48 +14,49 @@ Headless Chat SDK to build your own chat widget against Dynamics 365 Omnichannel
1414
Please make sure you have a chat widget configured before using this package or you can follow this [link](https://docs.microsoft.com/en-us/dynamics365/customer-service/add-chat-widget)
1515

1616
## Table of Contents
17+
1718
- [Live Chat Widget vs. Chat SDK](#live-chat-widget-vs-chat-sdk)
1819
- [Releases](#releases)
1920
- [Installation](#installation)
2021
- [Installation on React Native](#installation-on-react-native)
2122
- [SDK Methods](#sdk-methods)
22-
- [Initialization](#initialization)
23-
- [Start Chat](#start-chat)
24-
- [End Chat](#end-chat)
25-
- [Get Pre-Chat Survey](#get-pre-chat-survey)
26-
- [Get Live Chat Config](#get-live-chat-config)
27-
- [Get Current Live Chat Context](#get-current-live-chat-context)
28-
- [Get Data Masking Rules](#get-data-masking-rules)
29-
- [Get Chat Reconnect Context](#get-chat-reconnect-context)
30-
- [Get Conversation Details](#get-conversation-details)
31-
- [Get Chat Token](#get-chat-token)
32-
- [Get Calling Token](#get-calling-token)
33-
- [Get Messages](#get-messages)
34-
- [Send Messages](#send-messages)
35-
- [On New Message](#on-new-message)
36-
- [On Typing Event](#on-typing-event)
37-
- [On Agent End Session](#on-agent-end-session)
38-
- [Send Typing Event](#send-typing-event)
39-
- [Email Live Chat Transcript](#email-live-chat-transcript)
40-
- [Get Live Chat Transcript](#get-live-chat-transcript)
41-
- [Upload File Attachment](#upload-file-attachment)
42-
- [Download File Attachment](#download-file-attachment)
43-
- [Create Chat Adapter](#create-chat-adapter)
44-
- [Get Voice & Video Calling](#get-voice--video-calling)
45-
- [Get Post Chat Survey Context](#get-post-chat-survey-context)
23+
- [Initialization](#initialization)
24+
- [Start Chat](#start-chat)
25+
- [End Chat](#end-chat)
26+
- [Get Pre-Chat Survey](#get-pre-chat-survey)
27+
- [Get Live Chat Config](#get-live-chat-config)
28+
- [Get Current Live Chat Context](#get-current-live-chat-context)
29+
- [Get Data Masking Rules](#get-data-masking-rules)
30+
- [Get Chat Reconnect Context](#get-chat-reconnect-context)
31+
- [Get Conversation Details](#get-conversation-details)
32+
- [Get Chat Token](#get-chat-token)
33+
- [Get Calling Token](#get-calling-token)
34+
- [Get Messages](#get-messages)
35+
- [Send Messages](#send-messages)
36+
- [On New Message](#on-new-message)
37+
- [On Typing Event](#on-typing-event)
38+
- [On Agent End Session](#on-agent-end-session)
39+
- [Send Typing Event](#send-typing-event)
40+
- [Email Live Chat Transcript](#email-live-chat-transcript)
41+
- [Get Live Chat Transcript](#get-live-chat-transcript)
42+
- [Upload File Attachment](#upload-file-attachment)
43+
- [Download File Attachment](#download-file-attachment)
44+
- [Create Chat Adapter](#create-chat-adapter)
45+
- [Get Voice & Video Calling](#get-voice--video-calling)
46+
- [Get Post Chat Survey Context](#get-post-chat-survey-context)
4647
- [Common Scenarios](#common-scenarios)
47-
- [Using BotFramework-WebChat](#using-botframework-webchat)
48-
- [Escalation to Voice & Video](#escalation-to-voice--video)
49-
- [Pre-Chat Survey](#pre-chat-survey)
50-
- [Post-Chat Survey](#post-chat-survey)
51-
- [Reconnect to existing Chat](#reconnect-to-existing-chat)
52-
- [Authenticated Chat](#authenticated-chat)
53-
- [Persistent Chat](#persistent-chat)
54-
- [Chat Reconnect with Authenticated User](#chat-reconnect-with-authenticated-user)
55-
- [Chat Reconnect with Unauthenticated User](#chat-reconnect-with-unauthenticated-user)
56-
- [Handling chat Disconnect on Mobile platform](#handling-chat-disconnect-on-mobile-platform)
57-
- [Operating Hours](#operating-hours)
58-
- [Single Sign-on for Bots](/docs/scenarios/SINGLE_SIGN_ON_FOR_BOTS.md)
48+
- [Using BotFramework-WebChat](#using-botframework-webchat)
49+
- [Escalation to Voice & Video](#escalation-to-voice--video)
50+
- [Pre-Chat Survey](#pre-chat-survey)
51+
- [Post-Chat Survey](#post-chat-survey)
52+
- [Reconnect to existing Chat](#reconnect-to-existing-chat)
53+
- [Authenticated Chat](#authenticated-chat)
54+
- [Persistent Chat](#persistent-chat)
55+
- [Chat Reconnect with Authenticated User](#chat-reconnect-with-authenticated-user)
56+
- [Chat Reconnect with Unauthenticated User](#chat-reconnect-with-unauthenticated-user)
57+
- [Handling chat Disconnect on Mobile platform](#handling-chat-disconnect-on-mobile-platform)
58+
- [Operating Hours](#operating-hours)
59+
- [Single Sign-on for Bots](/docs/scenarios/SINGLE_SIGN_ON_FOR_BOTS.md)
5960
- [Sample Apps](https://github.com/microsoft/omnichannel-chat-sdk-samples)
6061
- [Feature Comparisons](#feature-comparisons)
6162
- [Telemetry](#telemetry)
@@ -65,6 +66,7 @@ Please make sure you have a chat widget configured before using this package or
6566
## Live Chat Widget vs. Chat SDK
6667

6768
Omnichannel offers a live chat widget (LCW) by default. You can use the Chat SDK to build your custom chat widget if:
69+
6870
- You want to fully customize the user interface of the chat widget to conform with your branding.
6971
- You want to integrate Omnichannel into your mobile app using React Native.
7072
- You want to integrate additional functionalities that LCW does not offer.
@@ -75,24 +77,24 @@ Omnichannel offers a live chat widget (LCW) by default. You can use the Chat SDK
7577
| Feature | Live Chat Widget | Chat SDK | Notes |
7678
| ----- | ----- | ----- | ----- |
7779
| Bring Your Own Widget ||| |
78-
| Web Support |||
79-
| React Native Support |||
80+
| Web Support ||||
81+
| React Native Support ||| |
8082
| Escalation to Voice & Video ||| Only supported on Web |
8183
| Co-browse || 3rd party add-on | Only supported on Web |
8284
| Screen Sharing || 3rd party add-on | Only supported on Web |
83-
| Authenticated Chat |||
84-
| Pre-chat Survey |||
85-
| Post-chat Survey |||
86-
| Download Transcript |||
87-
| Email Transcript |||
88-
| Data Masking |||
89-
| File Attachments |||
90-
| Custom Context |||
91-
| Proactive Chat || BYOI **\*** |
92-
| Persistent Chat |||
93-
| Chat Reconnect |||
94-
| Operating Hours |||
95-
| Get Agent Availability |||
85+
| Authenticated Chat ||| |
86+
| Pre-chat Survey ||| |
87+
| Post-chat Survey ||| |
88+
| Download Transcript ||| |
89+
| Email Transcript ||| |
90+
| Data Masking ||| |
91+
| File Attachments ||| |
92+
| Custom Context ||| |
93+
| Proactive Chat || BYOI **\*** | |
94+
| Persistent Chat ||| |
95+
| Chat Reconnect ||| |
96+
| Operating Hours ||| |
97+
| Get Agent Availability ||| |
9698
| Queue Position ||| No SDK method. Handled as *system message* |
9799
| Average Wait Time ||| No SDK method. Handled as *system message* |
98100

@@ -142,7 +144,7 @@ New releases are published on a regular basis to ensure the product quality.
142144

143145
## Installation
144146

145-
```
147+
```console
146148
npm install @microsoft/omnichannel-chat-sdk --save
147149
```
148150

@@ -151,31 +153,37 @@ npm install @microsoft/omnichannel-chat-sdk --save
151153
The following steps will be required to run Omnichannel Chat SDK on React Native:
152154

153155
1. Install `node-libs-react-native`
154-
```
156+
157+
```console
155158
npm install node-libs-react-native --save-dev
156159
```
157160

158161
1. Install `react-native-randomBytes`
159-
```
162+
163+
```console
160164
npm install react-native-randombytes --save-dev
161165
```
162166

163167
1. Install `react-native-get-random-values`
164-
```
168+
169+
```console
165170
npm install react-native-get-random-values --save-dev
166171
```
167172

168173
1. Install `react-native-url-polyfill`
169-
```
174+
175+
```console
170176
npm install react-native-url-polyfill --save-dev
171177
```
172178

173179
1. Install `@azure/core-asynciterator-polyfill`
174-
```
180+
181+
```console
175182
npm install @azure/core-asynciterator-polyfill --save-dev
176183
```
177184

178185
1. Update *metro.config.js* to use React Native compatible Node Core modules
186+
179187
```ts
180188
module.exports = {
181189
// ...
@@ -190,6 +198,7 @@ The following steps will be required to run Omnichannel Chat SDK on React Native
190198
```
191199

192200
1. Add the following *import* on top of your entry point file
201+
193202
```ts
194203
import 'node-libs-react-native/globals';
195204
import 'react-native-get-random-values';
@@ -223,10 +232,14 @@ const chatSDK = new OmnichannelChatSDK.OmnichannelChatSDK(omnichannelConfig, cha
223232

224233
const optionalParams = {
225234
getLiveChatConfigOptionalParams: {
226-
sendCacheHeaders: false // Whether to send Cache-Control HTTP header to GetChatConfig call
235+
sendCacheHeaders: false,// Whether to send Cache-Control HTTP header to GetChatConfig call
236+
useSequentialLoad: false // Whether to use sequential load for chat config, if not present, by default uses parallel load for faster initialization
237+
227238
}
228239
};
229240

241+
242+
// For the case when the widget doesnt have enabled support for attachments, Upload/download operations wont be supported
230243
await chatSDK.initialize(optionalParams);
231244
```
232245

@@ -394,6 +407,7 @@ chatSDK.onNewMessage((message) => {
394407
console.log(message);
395408
}, optionalParams);
396409
```
410+
397411
### On Typing Event
398412

399413
It subscribes to an agent typing event.
@@ -512,6 +526,7 @@ try {
512526
}
513527
}
514528
```
529+
515530
### Get Post Chat Survey Context
516531

517532
It gets the participant type that should be used for the survey and both the default and bot survey details.
@@ -532,7 +547,7 @@ const agentAvailability = await chatSDK.getAgentAvailability();
532547

533548
### Pre-Chat Survey
534549

535-
> See https://docs.microsoft.com/en-us/dynamics365/customer-service/configure-pre-chat-survey?tabs=customerserviceadmincenter on how to set up pre-conversation surveys
550+
> See <https://docs.microsoft.com/en-us/dynamics365/customer-service/configure-pre-chat-survey?tabs=customerserviceadmincenter> on how to set up pre-conversation surveys
536551

537552
```ts
538553
import * as AdaptiveCards, { Action } from "adaptivecards";
@@ -567,7 +582,7 @@ const agentAvailability = await chatSDK.getAgentAvailability();
567582

568583
### Post-Chat Survey
569584

570-
> See https://docs.microsoft.com/en-us/dynamics365/customer-service/configure-post-conversation-survey?tabs=customerserviceadmincenter on how to set up post-conversation surveys
585+
> See <https://docs.microsoft.com/en-us/dynamics365/customer-service/configure-post-conversation-survey?tabs=customerserviceadmincenter> on how to set up post-conversation surveys
571586

572587
>`chatSDK.getPostChatSurveyContext()` needs to be called before `chatSDK.endChat()` is called
573588

@@ -626,7 +641,7 @@ messages.reverse().forEach((message: any) => renderMessage(message)); // Logic t
626641

627642
### Authenticated Chat
628643

629-
> See https://docs.microsoft.com/en-us/dynamics365/customer-service/create-chat-auth-settings?tabs=customerserviceadmincenter#create-a-chat-authentication-setting-record on how to set up an authenticated chat
644+
> See <https://docs.microsoft.com/en-us/dynamics365/customer-service/create-chat-auth-settings?tabs=customerserviceadmincenter#create-a-chat-authentication-setting-record> on how to set up an authenticated chat
630645

631646
```ts
632647
const chatSDKConfig = {
@@ -649,7 +664,7 @@ await chatSDK.initialize();
649664

650665
### Persistent Chat
651666

652-
> See https://docs.microsoft.com/en-us/dynamics365/customer-service/persistent-chat on how to set up persistent chat
667+
> See <https://docs.microsoft.com/en-us/dynamics365/customer-service/persistent-chat> on how to set up persistent chat
653668

654669
```ts
655670
const chatSDKConfig = {
@@ -673,9 +688,10 @@ await chatSDK.initialize();
673688
674689
// from this point, this acts like a persistent chat
675690
```
691+
676692
### Chat Reconnect with Authenticated User
677693

678-
> 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
694+
> 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
679695

680696
```ts
681697
const chatSDKConfig = {
@@ -715,7 +731,7 @@ chatSDK.startChat();
715731

716732
### Chat Reconnect with Unauthenticated User
717733

718-
> 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
734+
> 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
719735

720736
```ts
721737
const chatSDKConfig = {
@@ -759,7 +775,7 @@ if (chatReconnectContext.reconnectId) {
759775

760776
### Operating Hours
761777

762-
> See https://docs.microsoft.com/en-us/dynamics365/customer-service/create-operating-hours?tabs=customerserviceadmincenter on how to set up operating hours
778+
> See <https://docs.microsoft.com/en-us/dynamics365/customer-service/create-operating-hours?tabs=customerserviceadmincenter> on how to set up operating hours
763779

764780
```ts
765781
const chatConfig = await chatSDK.getLiveChatConfig();
@@ -796,11 +812,12 @@ window.addEventListener("visibilitychange", async () => {
796812
});
797813
```
798814

799-
800815
### Using [BotFramework-WebChat](https://github.com/microsoft/BotFramework-WebChat)
816+
>
801817
> :warning: Currently supported on web only
802818

803819
Minimum Requirement Checklist
820+
804821
1. [ ] Initialize ChatSDK
805822
1. [ ] Start new conversation
806823
1. [ ] Create Chat Adapter
@@ -838,9 +855,10 @@ const store = createStore(
838855
```
839856

840857
### Escalation to Voice & Video
858+
>
841859
> :warning: Currently supported on web only
842860

843-
> See https://docs.microsoft.com/en-us/dynamics365/customer-service/call-options-visual-engagement on how to set up calling options
861+
> See <https://docs.microsoft.com/en-us/dynamics365/customer-service/call-options-visual-engagement> on how to set up calling options
844862

845863
```ts
846864
import OmnichannelChatSDK from '@microsoft/omnichannel-chat-sdk';
@@ -948,17 +966,19 @@ if (VoiceVideoCallingSDK) {
948966
## Feature Comparisons
949967

950968
### Web
969+
951970
| | Custom Control | WebChat Control |
952971
| --- | --- | --- |
953972
| **Features** | | |
954973
| Chat Widget UI | Not provided | Basic chat client provided |
955974
| Data Masking | Embedded | Requires `Data Masking Middleware` implementation |
956975
| Send Typing indicator | Embedded | Requires `sendTypingIndicator` flag set to `true` |
957-
| PreChat Survey | Requires Adaptive Cards renderer | Requires Adaptive Cards renderer
976+
| PreChat Survey | Requires Adaptive Cards renderer | Requires Adaptive Cards renderer|
958977
| Display Attachments | Requires implementation | Basic interface provided & Customizable |
959978
| Incoming messages handling | IC3 protocol message data | DirectLine activity data |
960979

961980
### React Native
981+
962982
| | Custom Control | Gifted Chat Control | WebChat Control |
963983
| --- | --- | --- | --- |
964984
| **Features** | | | Currently not supported |
@@ -1007,7 +1027,7 @@ await chatSDK.initialize();
10071027

10081028
This project welcomes contributions and suggestions. Most contributions require you to agree to a
10091029
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
1010-
the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
1030+
the rights to use your contribution. For details, visit <https://cla.opensource.microsoft.com>.
10111031

10121032
When you submit a pull request, a CLA bot will automatically determine whether you need to provide
10131033
a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions

__tests__/OmnichannelChatSDK.node.spec.ts

+3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ describe('Omnichannel Chat SDK (Node), Sequential', () => {
3636

3737
const chatSDK = new OmnichannelChatSDK(omnichannelConfig);
3838
chatSDK.getChatConfig = jest.fn();
39+
chatSDK["isAMSClientAllowed"] = true;
3940

4041
await chatSDK.initialize();
4142

@@ -82,6 +83,7 @@ describe('Omnichannel Chat SDK (Node), Sequential', () => {
8283
};
8384
chatSDK.getChatConfig = jest.fn();
8485
chatSDK.getChatToken = jest.fn();
86+
chatSDK["isAMSClientAllowed"] = true;
8587

8688
await chatSDK.initialize();
8789

@@ -113,6 +115,7 @@ describe('Omnichannel Chat SDK (Node), Sequential', () => {
113115
};
114116
chatSDK.getChatConfig = jest.fn();
115117
chatSDK.getChatToken = jest.fn();
118+
chatSDK["isAMSClientAllowed"] = true;
116119

117120
await chatSDK.initialize();
118121

0 commit comments

Comments
 (0)