Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More β†’
Socket
Sign inDemoInstall
Socket

@microsoft/omnichannel-chat-sdk

Package Overview
Dependencies
Maintainers
4
Versions
336
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@microsoft/omnichannel-chat-sdk - npm Package Compare versions

Comparing version 0.1.1-main.fadb071 to 0.2.0

lib/api/createVoiceVideoCalling.d.ts

28

CHANGELOG.md

@@ -6,4 +6,32 @@ # Changelog

## [0.2.0] - 2021-04-30
### Added
- React Native sample app using Omnichannel Chat SDK with [react-native-gifted-chat](https://github.com/FaridSafi/react-native-gifted-chat)
- Escalation to Voice & View support (Web Only)
- React sample app using Omnichannel Chat SDK with [BotFramework-WebChat](https://github.com/microsoft/BotFramework-WebChat)
- Expose `sessiontInit`'s `initContext` on `startChat`'s optional paramaters
- Add ability to use custom `ic3Config` & `chatAdapterConfig`
- Add telemetry
- Add `rehydrate` flag for `onNewMessage` to rehydrate all messages of existing conversation
- Add `getConversationDetails`
- Add ability to pass custom `ariaTelemetryKey`
### Changed
- Uptake [@microsoft/ocsdk@0.1.1](https://www.npmjs.com/package/@microsoft/ocsdk/v/0.1.1)
- Uptake [@microsoft/omnichannel-ic3core@0.1.1](https://www.npmjs.com/package/@microsoft/omnichannel-ic3core/v/0.1.1)
- Uptake [jest@26.6.3](https://www.npmjs.com/package/jest/v/26.6.3)
- Uptake [ts-jest@26.5.1](https://www.npmjs.com/package/ts-jest/v/26.5.1)
- Uptake [IC3Client@2021.03.02.1](https://comms.omnichannelengagementhub.com/release/2021.03.02.1/Scripts/SDK/SDK.min.js)
- Uptake [botframework-webchat-adapter-ic3@0.1.0-master.f4dfd7d](https://www.npmjs.com/package/botframework-webchat-adapter-ic3/v/0.1.0-master.f4dfd7d)
### Fixed
- onAgentEndSession triggered on accept voice & video call
- Fix multiple instances of IC3Client initialized
- `uploadFileAttachment` failing on Web
### Security
- Fix eslint errors
## [0.1.0] - 2020-10-26
### Added
- Initial release of Omnichannel Chat SDK v0.1.0

7

lib/config/settings.d.ts

@@ -1,3 +0,4 @@

declare const ic3ClientVersion = "2020.08.24.1";
declare const webChatIC3AdapterVersion = "0.1.0-master.86ac1a0";
export { ic3ClientVersion, webChatIC3AdapterVersion };
declare const ic3ClientVersion = "2021.03.02.1";
declare const webChatIC3AdapterVersion = "0.1.0-master.92b1505";
declare const ariaTelemetryKey = "c7655518acf1403f93ff6b9f77942f0a-d01a02fd-6b50-4de3-a566-62eda11f93bc-7083";
export { ic3ClientVersion, webChatIC3AdapterVersion, ariaTelemetryKey };
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.webChatIC3AdapterVersion = exports.ic3ClientVersion = void 0;
var ic3ClientVersion = '2020.08.24.1';
exports.ariaTelemetryKey = exports.webChatIC3AdapterVersion = exports.ic3ClientVersion = void 0;
var ic3ClientVersion = '2021.03.02.1';
exports.ic3ClientVersion = ic3ClientVersion;
var webChatIC3AdapterVersion = '0.1.0-master.86ac1a0';
var webChatIC3AdapterVersion = '0.1.0-master.92b1505';
exports.webChatIC3AdapterVersion = webChatIC3AdapterVersion;
var ariaTelemetryKey = 'c7655518acf1403f93ff6b9f77942f0a-d01a02fd-6b50-4de3-a566-62eda11f93bc-7083';
exports.ariaTelemetryKey = ariaTelemetryKey;
//# sourceMappingURL=settings.js.map
export default interface IChatConfig {
DataMaskingInfo: unknown;
LiveChatConfigAuthSettings: unknown;
LiveWSAndLiveChatEngJoin: unknown;
LiveWSAndLiveChatEngJoin: any;
}

@@ -0,1 +1,3 @@

import ChatAdapterConfig from "./ChatAdapterConfig";
import IC3Config from "./IC3Config";
interface IDataMaskingSDKConfig {

@@ -5,7 +7,14 @@ disable: boolean;

}
interface TelemetrySDKConfig {
disable: boolean;
ariaTelemetryKey?: string;
}
interface IChatSDKConfig {
dataMasking: IDataMaskingSDKConfig;
dataMasking?: IDataMaskingSDKConfig;
telemetry?: TelemetrySDKConfig;
getAuthToken?: () => Promise<string | null>;
ic3Config?: IC3Config;
chatAdapterConfig?: ChatAdapterConfig;
}
export { IDataMaskingSDKConfig };
export default IChatSDKConfig;

@@ -0,1 +1,2 @@

import InitContext from "@microsoft/ocsdk/lib/Model/InitContext";
import ILiveChatContext from "./ILiveChatContext";

@@ -5,2 +6,8 @@ export default interface IStartChatOptionalParams {

preChatResponse?: object;
customContext?: object;
browser?: string;
os?: string;
locale?: string;
device?: string;
initContext?: InitContext;
}

@@ -9,2 +9,3 @@ import IConversation from "@microsoft/omnichannel-ic3core/lib/model/IConversation";

sdkURL?: string;
sdk?: any;
}

@@ -14,3 +14,6 @@ import IChatConfig from "./core/IChatConfig";

import IStartChatOptionalParams from "./core/IStartChatOptionalParams";
import OnNewMessageOptionalParams from "./core/OnNewMessageOptionalParams";
import LiveWorkItemDetails from "./core/LiveWorkItemDetails";
declare class OmnichannelChatSDK {
private debug;
OCSDKProvider: unknown;

@@ -22,2 +25,3 @@ IC3SDKProvider: unknown;

chatSDKConfig: IChatSDKConfig;
isInitialized: boolean;
requestId: string;

@@ -31,4 +35,9 @@ private chatToken;

private conversation;
private debug;
private callingOption;
private telemetry;
private scenarioMarker;
private ic3ClientLogger;
private ocSdkLogger;
constructor(omnichannelConfig: IOmnichannelConfig, chatSDKConfig?: IChatSDKConfig);
setDebug(flag: boolean): void;
initialize(): Promise<IChatConfig>;

@@ -38,2 +47,3 @@ startChat(optionalParams?: IStartChatOptionalParams): Promise<void>;

getCurrentLiveChatContext(): Promise<ILiveChatContext | {}>;
getConversationDetails(): Promise<LiveWorkItemDetails>;
/**

@@ -47,8 +57,9 @@ * Gets PreChat Survey.

getMessages(): Promise<IMessage[] | undefined>;
getDataMaskingRules(): Promise<any>;
sendMessage(message: IChatSDKMessage): Promise<void>;
onNewMessage(onNewMessageCallback: CallableFunction): void;
onNewMessage(onNewMessageCallback: CallableFunction, optionalParams?: OnNewMessageOptionalParams | unknown): Promise<void>;
sendTypingEvent(): Promise<void>;
onTypingEvent(onTypingEventCallback: CallableFunction): Promise<void>;
onAgentEndSession(onAgentEndSessionCallback: (message: IRawThread) => void): Promise<void>;
uploadFileAttachment(fileInfo: IFileInfo): Promise<IRawMessage>;
uploadFileAttachment(fileInfo: IFileInfo | File): Promise<IRawMessage>;
downloadFileAttachment(fileMetadata: IFileMetadata): Promise<Blob>;

@@ -58,6 +69,8 @@ emailLiveChatTranscript(body: IChatTranscriptBody): Promise<any>;

createChatAdapter(protocol?: string): Promise<unknown>;
setDebug(flag: boolean): void;
getVoiceVideoCalling(params?: any): Promise<any>;
private getIC3Client;
private getChatConfig;
private resolveIC3ClientUrl;
private resolveChatAdapterUrl;
}
export default OmnichannelChatSDK;

@@ -1,8 +0,8 @@

declare const getIC3ClientCDNUrl: () => string;
declare const getIC3AdapterCDNUrl: () => string;
declare const getIC3ClientCDNUrl: (version?: string) => string;
declare const getIC3AdapterCDNUrl: (version?: string) => string;
declare const _default: {
getIC3ClientCDNUrl: () => string;
getIC3AdapterCDNUrl: () => string;
getIC3ClientCDNUrl: (version?: string) => string;
getIC3AdapterCDNUrl: (version?: string) => string;
};
export default _default;
export { getIC3ClientCDNUrl, getIC3AdapterCDNUrl };

@@ -5,9 +5,11 @@ "use strict";

var settings_1 = require("../config/settings");
var getIC3ClientCDNUrl = function () {
var IC3ClientCDNUrl = "https://comms.omnichannelengagementhub.com/release/" + settings_1.ic3ClientVersion + "/Scripts/SDK/SDK.min.js";
var getIC3ClientCDNUrl = function (version) {
if (version === void 0) { version = settings_1.ic3ClientVersion; }
var IC3ClientCDNUrl = "https://comms.omnichannelengagementhub.com/release/" + version + "/Scripts/SDK/SDK.min.js";
return IC3ClientCDNUrl;
};
exports.getIC3ClientCDNUrl = getIC3ClientCDNUrl;
var getIC3AdapterCDNUrl = function () {
var IC3AdapterCDNUrl = "https://webchatic3.blob.core.windows.net/webchat-ic3adapter/" + settings_1.webChatIC3AdapterVersion + "/botframework-webchat-adapter-ic3.production.min.js";
var getIC3AdapterCDNUrl = function (version) {
if (version === void 0) { version = settings_1.webChatIC3AdapterVersion; }
var IC3AdapterCDNUrl = "https://webchatic3.blob.core.windows.net/webchat-ic3adapter/" + version + "/botframework-webchat-adapter-ic3.production.min.js";
return IC3AdapterCDNUrl;

@@ -14,0 +16,0 @@ };

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.defaultChatSDKConfig = void 0;
var settings_1 = require("../config/settings");
var defaultChatSDKConfig = {

@@ -8,2 +9,6 @@ dataMasking: {

maskingCharacter: '#'
},
telemetry: {
disable: false,
ariaTelemetryKey: settings_1.ariaTelemetryKey
}

@@ -18,6 +23,6 @@ };

if (typeof dataMaskingConfig.disable !== "boolean") {
dataMaskingConfig.disable = defaultChatSDKConfig.dataMasking.disable;
dataMaskingConfig.disable = defaultChatSDKConfig.dataMasking.disable; // eslint-disable-line @typescript-eslint/no-non-null-assertion
}
if (typeof dataMaskingConfig.maskingCharacter !== "string" || dataMaskingConfig.maskingCharacter.length !== 1) {
dataMaskingConfig.maskingCharacter = defaultChatSDKConfig.dataMasking.maskingCharacter;
dataMaskingConfig.maskingCharacter = defaultChatSDKConfig.dataMasking.maskingCharacter; // eslint-disable-line @typescript-eslint/no-non-null-assertion
}

@@ -24,0 +29,0 @@ };

{
"name": "@microsoft/omnichannel-chat-sdk",
"version": "0.1.1-main.fadb071",
"version": "0.2.0",
"description": "Microsoft Omnichannel Chat SDK",
"files": [
"lib/**/*"
],
"main": "lib/index.js",
"types": "lib/index.d.ts",
"scripts": {
"build:tsc": "tsc",
"build:tsc": "tsc && cp -r src/external/aria lib/external/",
"test": "jest",

@@ -33,10 +36,10 @@ "lint": "eslint src --ext .ts"

"eslint": "^7.15.0",
"jest": "^26.4.2",
"ts-jest": "^26.3.0",
"jest": "^26.6.3",
"ts-jest": "^26.5.1",
"typescript": "^3.9.5"
},
"dependencies": {
"@microsoft/ocsdk": "^0.1.0",
"@microsoft/omnichannel-ic3core": "^0.1.0"
"@microsoft/ocsdk": "^0.1.1",
"@microsoft/omnichannel-ic3core": "^0.1.1"
}
}

@@ -8,2 +8,46 @@ # Omnichannel Chat SDK

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/configure-live-chat)
## Table of Contents
- [Live Chat Widget vs. Chat SDK](#live-chat-widget-vs-chat-sdk)
- [Installation](#installation)
- [API Reference](#api-reference)
- [API Examples](#api-examples)
- [Sample Apps](samples/)
- [Common Scenarios](#common-scenarios)
- [Feature Comparisons](#feature-comparisons)
- [Telemetry](#telemetry)
## Live Chat Widget vs. Chat SDK
Omnichannel offers an live chat widget (LCW) by default. You can use the Chat SDK to build your custom chat widget if:
- You want to fully customize the user interface of the chat widget to conform with your branding.
- You want to integrate Omnichannel in your mobile app using React Native.
- You want to integrate additional functionalities that LCW does not offer.
- Some other cool ideas. Please share with us on what you've achieved with the Chat SDK! πŸ™‚
### Feature Comparisons
| Feature | Live Chat Widget | Chat SDK | Notes |
| ----- | ----- | ----- | ----- |
| Bring Your Own Widget | ❌ | βœ” | |
| Web Support | βœ” | βœ” |
| React Native Support | ❌ | βœ” |
| Escalation to Voice & Video | βœ” | Web Only |
| Co-browse | βœ” | ❌ |
| Screen Sharing | βœ” | ❌ |
| Authenticated Chat | βœ” | βœ” |
| Pre-chat Survey | βœ” | βœ” |
| Post-chat Survey | βœ” | ❌ |
| Queue Position | βœ” | βœ” |
| Average Wait Time | βœ” | βœ” |
| Download Transcript | βœ” | βœ” |
| Email Transcript | βœ” | βœ” |
| Data Masking | βœ” | βœ” |
| File Attachments | βœ” | βœ” |
| Custom Context | βœ” | βœ” |
| Proactive Chat | βœ” | BYOI **\*** |
**\*** BYOI: Bring Your Own Implementation
## Installation

@@ -15,6 +59,4 @@

## API
## API Reference
### High Level Overview
| Method | Description | Notes |

@@ -27,3 +69,5 @@ | ------ | ----------- | ----- |

| OmnichannelChatSDK.getLiveChatConfig() | Get live chat config | |
| OmnichannelChatSDK.getDataMaskingRules() | Get active data masking rules | |
| OmnichannelChatSDK.getCurrentLiveChatContext() | Get current live chat context information to reconnect to the same chat | |
| OmnichannelChatSDK.getConversationDetails() | Get details of the current conversation such as its state & when the agent joined the conversation | |
| OmnichannelChatSDK.getChatToken() | Get chat token | |

@@ -40,4 +84,7 @@ | OmnichannelChatSDK.getMessages() | Get all messages | |

| OmnichannelChatSDK.downloadFileAttachment() | Download file attachment | |
| OmnichannelChatSDK.createChatAdapter() | Get IC3Adapter (Web only) | |
| OmnichannelChatSDK.createChatAdapter() | Get IC3Adapter | **Web only** |
| OmnichannelChatSDK.getVoiceVideoCalling() | Get VoiceVideoCall SDK for Escalation to Voice & Video| **Web only** |
## API examples
### Import

@@ -57,3 +104,3 @@ ```ts

const chatSDKConfig = { // Optional
DataMasking: {
dataMasking: {
disable: false,

@@ -73,2 +120,7 @@ maskingCharacter: '#'

### Get Conversation Details
```ts
const conversationDetails = await chatSDK.getConversationDetails();
```
### Get Chat Token

@@ -84,2 +136,7 @@ ```ts

### Get Data Masking Rules
```ts
const dataMaskingRules = await chatSDK.getDataMaskingRules();
```
### Get PreChat Survey

@@ -98,5 +155,12 @@ `Option 1`

```ts
const customContext = {
'contextKey1': {'value': 'contextValue1', 'isDisplayable': true},
'contextKey2': {'value': 12.34, 'isDisplayable': false},
'contextKey3': {'value': true}
};
const optionalParams = {
preChatResponse: '', // PreChatSurvey response
liveChatContext: {} // EXISTING chat context data
liveChatContext: {}, // EXISTING chat context data
customContext // Custom Context
};

@@ -113,6 +177,10 @@ await chatSDK.startChat(optionalParams);

```ts
const optionalParams = {
rehydrate: true, // Rehydrate all previous messages of existing conversation (false by default)
}
chatSDK.onNewMessage((message) => {
console.log(`[NewMessage] ${message.content}`); // IC3 protocol message data
console.log(message);
});
}, optionalParams);
```

@@ -202,3 +270,3 @@

## Samples
## Common Scenarios

@@ -332,3 +400,96 @@ ### PreChatSurvey

### Escalation to Voice & Video
**NOTE**: Currently supported on web only
```ts
import OmnichannelChatSDK from '@microsoft/omnichannel-chat-sdk';
...
const chatSDK = new OmnichannelChatSDK.OmnichannelChatSDK(omnichannelConfig, chatSDKConfig);
await chatSDK.initialize();
let VoiceVideoCallingSDK;
try {
VoiceVideoCallingSDK = await chatSDK.getVoiceVideoCalling();
console.log("VoiceVideoCalling loaded");
} catch (e) {
console.log(`Failed to load VoiceVideoCalling: ${e}`);
}
await chatSDK.startChat();
const chatToken: any = await chatSDK.getChatToken();
try {
await VoiceVideoCallingSDK.initialize({
chatToken,
selfVideoHTMLElementId: 'selfVideo', // HTML element id where video stream of the agent will be rendered
remoteVideoHTMLElementId: 'remoteVideo', // HTML element id where video stream of the customer will be rendered
OCClient: chatSDK.OCClient
});
} catch (e) {
console.error("Failed to initialize VoiceVideoCalling!");
}
// Triggered when there's an incoming call
VoiceVideoCallingSDK.onCallAdded(() => {
...
});
// Triggered when local video stream is available (e.g.: Local video added succesfully in selfVideoHTMLElement)
VoiceVideoCallingSDK.onLocalVideoStreamAdded(() => {
...
});
// Triggered when local video stream is unavailable (e.g.: Customer turning off local video)
VoiceVideoCallingSDK.onLocalVideoStreamRemoved(() => {
...
});
// Triggered when remote video stream is available (e.g.: Remote video added succesfully in remoteVideoHTMLElement)
VoiceVideoCallingSDK.onRemoteVideoStreamAdded(() => {
...
});
// Triggered when remote video stream is unavailable (e.g.: Agent turning off remote video)
VoiceVideoCallingSDK.onRemoteVideoStreamRemoved(() => {
...
});
// Triggered when current call has ended or disconnected regardless the party
VoiceVideoCalling.onCallDisconnected(() => {
...
});
// Check if microphone is muted
const isMicrophoneMuted = VoiceVideoCallingSDK.isMicrophoneMuted();
// Check if remote video is available
const isRemoteVideoEnabled = VoiceVideoCallingSDK.isRemoteVideoEnabled();
// Check if local video is available
const isLocalVideoEnabled = VoiceVideoCallingSDK.isLocalVideoEnabled();
// Accepts incoming call
const acceptCallConfig = {
withVideo: true // Accept call with/without video stream
};
await VoiceVideoCallingSDK.acceptCall(acceptCallConfig);
// Rejects incoming call
await VoiceVideoCallingSDK.rejectCall();
// Ends/Stops current call
await VoiceVideoCallingSDK.stopCall();
// Mute/Unmute current call
await VoiceVideoCallingSDK.toggleMute()
// Display/Hide local video of current call
await VoiceVideoCallingSDK.toggleLocalVideo()
// Clean up VoiceVideoCallingSDK (e.g.: Usually called when customer ends chat session)
VoiceVideoCallingSDK.close();
```
## Feature Comparisons

@@ -341,6 +502,6 @@

| Chat Widget UI | Not provided | Basic chat client provided |
| Data Masking | Embedded | Requires `Attachment Middleware` implementation |
| Data Masking | Embedded | Requires `Data Masking Middleware` implementation |
| Send Typing indicator | Embedded | Requires `sendTypingIndicator` flag set to `true` |
| PreChat Survey | Requires Adaptive Cards renderer | Requires Adaptive Cards renderer
| Display Attachments | Requires implementation | Provided & Customizable |
| Display Attachments | Requires implementation | Basic interface provided & Customizable |
| Incoming messages handling | IC3 protocol message data | DirectLine activity data |

@@ -354,3 +515,3 @@

| Data Masking | Embedded | Embedded | X |
| Send Typing indicator | Embedded | WIP | X |
| Send Typing indicator | Embedded | Requires Implementation | X |
| PreChat Survey | Requires Adaptive Cards renderer | Requires Adaptive Cards renderer | X |

@@ -360,3 +521,36 @@ | Display Attachments | Requires implementation| Embedded | X |

## Telemetry
Omnichannel Chat SDK collects telemetry by default to improve the feature’s capabilities, reliability, and performance over time by helping Microsoft understand usage patterns, plan new features, and troubleshoot and fix problem areas.
Some of the data being collected are the following:
| Field | Sample |
| --- | --- |
| Organization Id | `e00e67ee-a60e-4b49-b28c-9d279bf42547` |
| Organization Url | `org60082947.crm.oc.crmlivetie.com` |
| Widget Id | `1893e4ae-2859-4ac4-9cf5-97cffbb9c01b` |
| Browser Name | `Edge` |
| Os Name | `Windows` |
| Anonymized IP Address (last octet redacted) | `19.207.000.000` |
If your organization is concerned about the data collected by the Chat SDK, you have the option to turn off automatic data collection by adding a flag in the `ChatSDKConfig`.
```ts
const omnichannelConfig = {
orgUrl: "",
orgId: "",
widgetId: ""
};
const chatSDKConfig = {
telemetry: {
disable: true // Disable telemetry
}
};
const chatSDK = new OmnichannelChatSDK.OmnichannelChatSDK(omnichannelConfig, chatSDKConfig);
await chatSDK.initialize();
```
# Contributing

@@ -363,0 +557,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚑️ by Socket Inc