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
347
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.197fbdd to 0.1.1-main.19bda01

lib/api/createVoiceVideoCalling.d.ts

24

CHANGELOG.md

@@ -5,5 +5,29 @@ # Changelog

## [Unreleased]
### 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`
### 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
### 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 = "07172c8dd08d4de7a594b5b5cf81e668-92304109-4cd9-41b6-8806-714387b256e8-7337";
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 = '07172c8dd08d4de7a594b5b5cf81e668-92304109-4cd9-41b6-8806-714387b256e8-7337';
exports.ariaTelemetryKey = ariaTelemetryKey;
//# sourceMappingURL=settings.js.map
export default interface IChatConfig {
DataMaskingInfo: any;
LiveChatConfigAuthSettings: any;
DataMaskingInfo: unknown;
LiveChatConfigAuthSettings: 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;
}
"use strict";
/* eslint-disable @typescript-eslint/no-explicit-any */
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=IChatToken.js.map

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

sdkURL?: string;
sdk?: any;
}

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

import IFileMetadata from "@microsoft/omnichannel-ic3core/lib/model/IFileMetadata";
import ILiveChatContext from "./core/ILiveChatContext";
import IMessage from "@microsoft/omnichannel-ic3core/lib/model/IMessage";
import IOmnichannelConfig from "./core/IOmnichannelConfig";
import IRawMessage from "@microsoft/omnichannel-ic3core/lib/model/IRawMessage";
import IRawThread from "@microsoft/omnichannel-ic3core/lib/interfaces/IRawThread";
import IStartChatOptionalParams from "./core/IStartChatOptionalParams";
import OnNewMessageOptionalParams from "./core/OnNewMessageOptionalParams";
import LiveWorkItemDetails from "./core/LiveWorkItemDetails";
declare class OmnichannelChatSDK {
OCSDKProvider: any;
IC3SDKProvider: any;
private debug;
OCSDKProvider: unknown;
IC3SDKProvider: unknown;
OCClient: any;

@@ -19,2 +25,3 @@ IC3Client: any;

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

@@ -28,8 +35,14 @@ 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>;
startChat(optionalParams?: IStartChatOptionalParams): Promise<any>;
endChat(): Promise<any>;
getCurrentLiveChatContext(): Promise<{}>;
startChat(optionalParams?: IStartChatOptionalParams): Promise<void>;
endChat(): Promise<void>;
getCurrentLiveChatContext(): Promise<ILiveChatContext | {}>;
getConversationDetails(): Promise<LiveWorkItemDetails>;
/**

@@ -40,11 +53,12 @@ * Gets PreChat Survey.

getPreChatSurvey(parse?: boolean): Promise<any>;
getLiveChatConfig(cached?: boolean): Promise<any>;
getLiveChatConfig(cached?: boolean): Promise<IChatConfig>;
getChatToken(cached?: boolean): Promise<IChatToken>;
getMessages(): Promise<import("@microsoft/omnichannel-ic3core/lib/model/IMessage").default[] | undefined>;
getMessages(): Promise<IMessage[] | undefined>;
getDataMaskingRules(): Promise<any>;
sendMessage(message: IChatSDKMessage): Promise<void>;
onNewMessage(onNewMessageCallback: CallableFunction): void;
sendTypingEvent(): Promise<any>;
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<any>;
uploadFileAttachment(fileInfo: IFileInfo | File): Promise<IRawMessage>;
downloadFileAttachment(fileMetadata: IFileMetadata): Promise<Blob>;

@@ -54,6 +68,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;
"use strict";
/* eslint-disable @typescript-eslint/no-non-null-assertion */
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -54,10 +66,26 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

var SDKConfigValidators_1 = require("./validators/SDKConfigValidators");
var WebUtils_1 = require("./utils/WebUtils");
var createVoiceVideoCalling_1 = require("./api/createVoiceVideoCalling");
var CallingOptionsOptionSetNumber_1 = require("./core/CallingOptionsOptionSetNumber");
var createTelemetry_1 = require("./utils/createTelemetry");
var TelemetryEvent_1 = require("./telemetry/TelemetryEvent");
var ScenarioMarker_1 = require("./telemetry/ScenarioMarker");
var loggers_1 = require("./utils/loggers");
var LiveWorkItemState_1 = require("./core/LiveWorkItemState");
var OmnichannelChatSDK = /** @class */ (function () {
function OmnichannelChatSDK(omnichannelConfig, chatSDKConfig) {
if (chatSDKConfig === void 0) { chatSDKConfig = SDKConfigValidators_1.defaultChatSDKConfig; }
var _a, _b, _c, _d;
this.authSettings = null;
this.authenticatedUserToken = null;
this.conversation = null;
this.callingOption = CallingOptionsOptionSetNumber_1.default.NoCalling;
this.telemetry = null;
this.ic3ClientLogger = null;
this.ocSdkLogger = null;
this.debug = false;
this.omnichannelConfig = omnichannelConfig;
this.chatSDKConfig = chatSDKConfig;
this.chatSDKConfig = __assign(__assign({}, SDKConfigValidators_1.defaultChatSDKConfig), chatSDKConfig // overrides
);
this.isInitialized = false;
this.requestId = ocsdk_1.uuidv4();

@@ -69,22 +97,59 @@ this.chatToken = {};

this.preChatSurvey = null;
this.debug = false;
this.telemetry = createTelemetry_1.default(this.debug);
this.scenarioMarker = new ScenarioMarker_1.default(this.omnichannelConfig);
this.ic3ClientLogger = loggers_1.createIC3ClientLogger(this.omnichannelConfig);
this.ocSdkLogger = loggers_1.createOCSDKLogger(this.omnichannelConfig);
this.scenarioMarker.useTelemetry(this.telemetry);
this.ic3ClientLogger.useTelemetry(this.telemetry);
this.ocSdkLogger.useTelemetry(this.telemetry);
OmnichannelConfigValidator_1.default(omnichannelConfig);
SDKConfigValidators_1.default(chatSDKConfig);
((_a = this.chatSDKConfig.telemetry) === null || _a === void 0 ? void 0 : _a.disable) && ((_b = this.telemetry) === null || _b === void 0 ? void 0 : _b.disable());
(_c = this.ic3ClientLogger) === null || _c === void 0 ? void 0 : _c.setRequestId(this.requestId);
(_d = this.ocSdkLogger) === null || _d === void 0 ? void 0 : _d.setRequestId(this.requestId);
}
/* istanbul ignore next */
OmnichannelChatSDK.prototype.setDebug = function (flag) {
var _a, _b, _c;
this.debug = flag;
(_a = this.telemetry) === null || _a === void 0 ? void 0 : _a.setDebug(flag);
this.scenarioMarker.setDebug(flag);
(_b = this.ic3ClientLogger) === null || _b === void 0 ? void 0 : _b.setDebug(flag);
(_c = this.ocSdkLogger) === null || _c === void 0 ? void 0 : _c.setDebug(flag);
};
OmnichannelChatSDK.prototype.initialize = function () {
return __awaiter(this, void 0, void 0, function () {
var _a, _b;
return __generator(this, function (_c) {
switch (_c.label) {
var OCClient, IC3Client, _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
this.scenarioMarker.startScenario(TelemetryEvent_1.default.InitializeChatSDK);
if (this.isInitialized) {
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.InitializeChatSDK);
return [2 /*return*/, this.liveChatConfig];
}
_b.label = 1;
case 1:
_b.trys.push([1, 5, , 6]);
this.OCSDKProvider = ocsdk_1.SDKProvider;
_a = this;
return [4 /*yield*/, ocsdk_1.SDKProvider.getSDK(this.omnichannelConfig, {}, undefined)];
case 1:
_a.OCClient = _c.sent();
_b = this;
return [4 /*yield*/, ocsdk_1.SDKProvider.getSDK(this.omnichannelConfig, {}, this.ocSdkLogger)];
case 2:
OCClient = _b.sent();
return [4 /*yield*/, this.getIC3Client()];
case 2:
_b.IC3Client = _c.sent();
return [2 /*return*/, this.getChatConfig()];
case 3:
IC3Client = _b.sent();
// Assign & Update flag only if all dependencies have been initialized succesfully
this.OCClient = OCClient;
this.IC3Client = IC3Client;
return [4 /*yield*/, this.getChatConfig()];
case 4:
_b.sent();
this.isInitialized = true;
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.InitializeChatSDK);
return [3 /*break*/, 6];
case 5:
_a = _b.sent();
this.scenarioMarker.failScenario(TelemetryEvent_1.default.InitializeChatSDK);
return [3 /*break*/, 6];
case 6: return [2 /*return*/, this.liveChatConfig];
}

@@ -95,40 +160,101 @@ });

OmnichannelChatSDK.prototype.startChat = function (optionalParams) {
var _a, _b;
if (optionalParams === void 0) { optionalParams = {}; }
return __awaiter(this, void 0, void 0, function () {
var sessionInitOptionalParams, error_1, error_2, _a, error_3;
return __generator(this, function (_b) {
switch (_b.label) {
var conversationDetails, exceptionDetails, exceptionDetails, sessionInitOptionalParams, error_1, exceptionDetails, error_2, exceptionDetails, _c, error_3, exceptionDetails;
return __generator(this, function (_d) {
switch (_d.label) {
case 0:
if (optionalParams.liveChatContext) {
this.chatToken = optionalParams.liveChatContext.chatToken || {};
this.requestId = optionalParams.liveChatContext.requestId || ocsdk_1.uuidv4();
this.scenarioMarker.startScenario(TelemetryEvent_1.default.StartChat, {
RequestId: this.requestId
});
if (!optionalParams.liveChatContext) return [3 /*break*/, 2];
this.chatToken = optionalParams.liveChatContext.chatToken || {};
this.requestId = optionalParams.liveChatContext.requestId || ocsdk_1.uuidv4();
return [4 /*yield*/, this.getConversationDetails()];
case 1:
conversationDetails = _d.sent();
if (Object.keys(conversationDetails).length === 0) {
exceptionDetails = {
response: "InvalidConversation"
};
this.scenarioMarker.failScenario(TelemetryEvent_1.default.StartChat, {
RequestId: this.requestId,
ChatId: this.chatToken.chatId,
ExceptionDetails: JSON.stringify(exceptionDetails)
});
console.error("Conversation not found");
throw Error(exceptionDetails.response);
}
if (!(this.chatToken && Object.keys(this.chatToken).length === 0)) return [3 /*break*/, 2];
if (conversationDetails.state === LiveWorkItemState_1.default.WrapUp || conversationDetails.state === LiveWorkItemState_1.default.Closed) {
exceptionDetails = {
response: "ClosedConversation"
};
this.scenarioMarker.failScenario(TelemetryEvent_1.default.StartChat, {
RequestId: this.requestId,
ChatId: this.chatToken.chatId,
ExceptionDetails: JSON.stringify(exceptionDetails)
});
console.error("Unable to join conversation that's in '" + conversationDetails.state + "' state");
throw Error(exceptionDetails.response);
}
_d.label = 2;
case 2:
if (!(this.chatToken && Object.keys(this.chatToken).length === 0)) return [3 /*break*/, 4];
return [4 /*yield*/, this.getChatToken(false)];
case 1:
_b.sent();
_b.label = 2;
case 2:
case 3:
_d.sent();
_d.label = 4;
case 4:
(_a = this.ic3ClientLogger) === null || _a === void 0 ? void 0 : _a.setChatId(this.chatToken.chatId || '');
(_b = this.ocSdkLogger) === null || _b === void 0 ? void 0 : _b.setChatId(this.chatToken.chatId || '');
sessionInitOptionalParams = {
initContext: {}
};
if (optionalParams.customContext) {
sessionInitOptionalParams.initContext.customContextData = optionalParams.customContext; // eslint-disable-line @typescript-eslint/no-explicit-any
}
if (optionalParams.browser) {
sessionInitOptionalParams.initContext.browser = optionalParams.browser;
}
if (optionalParams.os) {
sessionInitOptionalParams.initContext.os = optionalParams.os;
}
if (optionalParams.locale) {
sessionInitOptionalParams.initContext.locale = optionalParams.locale;
}
if (optionalParams.device) {
sessionInitOptionalParams.initContext.device = optionalParams.device;
}
if (optionalParams.preChatResponse) {
sessionInitOptionalParams.initContext.preChatResponse = optionalParams.preChatResponse;
}
// Override initContext completely
if (optionalParams.initContext) {
sessionInitOptionalParams.initContext = optionalParams.initContext;
}
if (this.authenticatedUserToken) {
sessionInitOptionalParams.authenticatedUserToken = this.authenticatedUserToken;
}
_b.label = 3;
case 3:
_b.trys.push([3, 5, , 6]);
_d.label = 5;
case 5:
_d.trys.push([5, 7, , 8]);
return [4 /*yield*/, this.OCClient.sessionInit(this.requestId, sessionInitOptionalParams)];
case 4:
_b.sent();
return [3 /*break*/, 6];
case 5:
error_1 = _b.sent();
case 6:
_d.sent();
return [3 /*break*/, 8];
case 7:
error_1 = _d.sent();
exceptionDetails = {
response: "OCClientSessionInitFailed"
};
this.scenarioMarker.failScenario(TelemetryEvent_1.default.StartChat, {
RequestId: this.requestId,
ChatId: this.chatToken.chatId,
ExceptionDetails: JSON.stringify(exceptionDetails)
});
console.error("OmnichannelChatSDK/startChat/sessionInit/error " + error_1);
return [2 /*return*/, error_1];
case 6:
_b.trys.push([6, 8, , 9]);
case 8:
_d.trys.push([8, 10, , 11]);
return [4 /*yield*/, this.IC3Client.initialize({

@@ -139,21 +265,41 @@ token: this.chatToken.token,

})];
case 7:
_b.sent();
return [3 /*break*/, 9];
case 8:
error_2 = _b.sent();
case 9:
_d.sent();
return [3 /*break*/, 11];
case 10:
error_2 = _d.sent();
exceptionDetails = {
response: "IC3ClientInitializeFailed"
};
this.scenarioMarker.failScenario(TelemetryEvent_1.default.StartChat, {
RequestId: this.requestId,
ChatId: this.chatToken.chatId,
ExceptionDetails: JSON.stringify(exceptionDetails)
});
console.error("OmnichannelChatSDK/startChat/initialize/error " + error_2);
return [2 /*return*/, error_2];
case 9:
_b.trys.push([9, 11, , 12]);
_a = this;
case 11:
_d.trys.push([11, 13, , 14]);
_c = this;
return [4 /*yield*/, this.IC3Client.joinConversation(this.chatToken.chatId)];
case 10:
_a.conversation = _b.sent();
return [3 /*break*/, 12];
case 11:
error_3 = _b.sent();
case 12:
_c.conversation = _d.sent();
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.StartChat, {
RequestId: this.requestId,
ChatId: this.chatToken.chatId
});
return [3 /*break*/, 14];
case 13:
error_3 = _d.sent();
exceptionDetails = {
response: "IC3ClientJoinConversationFailed"
};
this.scenarioMarker.failScenario(TelemetryEvent_1.default.StartChat, {
RequestId: this.requestId,
ChatId: this.chatToken.chatId,
ExceptionDetails: JSON.stringify(exceptionDetails)
});
console.error("OmnichannelChatSDK/startChat/joinConversation/error " + error_3);
return [2 /*return*/, error_3];
case 12: return [2 /*return*/];
case 14: return [2 /*return*/];
}

@@ -164,7 +310,12 @@ });

OmnichannelChatSDK.prototype.endChat = function () {
var _a, _b, _c, _d;
return __awaiter(this, void 0, void 0, function () {
var sessionCloseOptionalParams, error_4;
return __generator(this, function (_a) {
switch (_a.label) {
var sessionCloseOptionalParams, error_4, exceptionDetails;
return __generator(this, function (_e) {
switch (_e.label) {
case 0:
this.scenarioMarker.startScenario(TelemetryEvent_1.default.EndChat, {
RequestId: this.requestId,
ChatId: this.chatToken.chatId
});
sessionCloseOptionalParams = {};

@@ -174,8 +325,12 @@ if (this.authenticatedUserToken) {

}
_a.label = 1;
_e.label = 1;
case 1:
_a.trys.push([1, 3, , 4]);
_e.trys.push([1, 3, , 4]);
return [4 /*yield*/, this.OCClient.sessionClose(this.requestId, sessionCloseOptionalParams)];
case 2:
_a.sent();
_e.sent();
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.EndChat, {
RequestId: this.requestId,
ChatId: this.chatToken.chatId
});
this.conversation.disconnect();

@@ -185,5 +340,17 @@ this.conversation = null;

this.chatToken = {};
(_a = this.ic3ClientLogger) === null || _a === void 0 ? void 0 : _a.setRequestId(this.requestId);
(_b = this.ic3ClientLogger) === null || _b === void 0 ? void 0 : _b.setChatId('');
(_c = this.ocSdkLogger) === null || _c === void 0 ? void 0 : _c.setRequestId(this.requestId);
(_d = this.ocSdkLogger) === null || _d === void 0 ? void 0 : _d.setChatId('');
return [3 /*break*/, 4];
case 3:
error_4 = _a.sent();
error_4 = _e.sent();
exceptionDetails = {
response: "OCClientSessionCloseFailed"
};
this.scenarioMarker.failScenario(TelemetryEvent_1.default.EndChat, {
RequestId: this.requestId,
ChatId: this.chatToken.chatId,
ExceptionDetails: JSON.stringify(exceptionDetails),
});
console.error("OmnichannelChatSDK/endChat/error " + error_4);

@@ -217,2 +384,45 @@ return [2 /*return*/, error_4];

};
OmnichannelChatSDK.prototype.getConversationDetails = function () {
var _a, _b;
return __awaiter(this, void 0, void 0, function () {
var lwiDetails, state, conversationId, agentAcceptedOn, liveWorkItemDetails, error_5;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetConversationDetails, {
RequestId: this.requestId,
ChatId: ((_a = this.chatToken) === null || _a === void 0 ? void 0 : _a.chatId) || '',
});
_c.label = 1;
case 1:
_c.trys.push([1, 3, , 4]);
return [4 /*yield*/, this.OCClient.getLWIDetails(this.requestId)];
case 2:
lwiDetails = _c.sent();
state = lwiDetails.State, conversationId = lwiDetails.ConversationId, agentAcceptedOn = lwiDetails.AgentAcceptedOn;
liveWorkItemDetails = {
state: state,
conversationId: conversationId
};
if (agentAcceptedOn) {
liveWorkItemDetails.agentAcceptedOn = agentAcceptedOn;
}
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetConversationDetails, {
RequestId: this.requestId,
ChatId: ((_b = this.chatToken) === null || _b === void 0 ? void 0 : _b.chatId) || '',
});
return [2 /*return*/, liveWorkItemDetails];
case 3:
error_5 = _c.sent();
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetConversationDetails, {
RequestId: this.requestId,
ChatId: this.chatToken.chatId || '',
});
console.error("OmnichannelChatSDK/getConversationDetails/error " + error_5);
return [3 /*break*/, 4];
case 4: return [2 /*return*/, {}];
}
});
});
};
/**

@@ -244,7 +454,10 @@ * Gets PreChat Survey.

return __awaiter(this, void 0, void 0, function () {
var getChatTokenOptionalParams, chatToken, chatId, token, regionGtms, expiresIn, visitorId, voiceVideoCallToken, error_5;
var getChatTokenOptionalParams, chatToken, chatId, token, regionGtms, expiresIn, visitorId, voiceVideoCallToken, error_6, exceptionDetails;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!!cached) return [3 /*break*/, 4];
this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetChatToken, {
RequestId: this.requestId
});
if (!!cached) return [3 /*break*/, 5];
_a.label = 1;

@@ -270,8 +483,27 @@ case 1:

};
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetChatToken, {
RequestId: this.requestId,
ChatId: this.chatToken.chatId
});
return [3 /*break*/, 4];
case 3:
error_5 = _a.sent();
console.error("OmnichannelChatSDK/getChatToken/error " + error_5);
error_6 = _a.sent();
exceptionDetails = {
response: "OCClientGetChatTokenFailed"
};
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetChatToken, {
RequestId: this.requestId,
ChatId: this.chatToken.chatId,
ExceptionDetails: JSON.stringify(exceptionDetails),
});
console.error("OmnichannelChatSDK/getChatToken/error " + error_6);
return [3 /*break*/, 4];
case 4: return [2 /*return*/, this.chatToken];
case 4: return [3 /*break*/, 6];
case 5:
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetChatToken, {
RequestId: this.requestId,
ChatId: this.chatToken.chatId
});
_a.label = 6;
case 6: return [2 /*return*/, this.chatToken];
}

@@ -289,2 +521,9 @@ });

};
OmnichannelChatSDK.prototype.getDataMaskingRules = function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this.dataMaskingRules];
});
});
};
OmnichannelChatSDK.prototype.sendMessage = function (message) {

@@ -301,3 +540,3 @@ return __awaiter(this, void 0, void 0, function () {

match = void 0;
while (match = regex.exec(content)) {
while (match = regex.exec(content)) { // eslint-disable-line no-cond-assign
replaceStr = match[0].replace(/./g, maskingCharacter);

@@ -333,13 +572,44 @@ content = content.replace(match[0], replaceStr);

};
OmnichannelChatSDK.prototype.onNewMessage = function (onNewMessageCallback) {
OmnichannelChatSDK.prototype.onNewMessage = function (onNewMessageCallback, optionalParams) {
var _a;
(_a = this.conversation) === null || _a === void 0 ? void 0 : _a.registerOnNewMessage(function (message) {
var messageType = message.messageType;
// Filter out customer messages
if (utilities_1.isCustomerMessage(message)) {
return;
}
if (messageType !== MessageType_1.default.Typing) {
onNewMessageCallback(message);
}
if (optionalParams === void 0) { optionalParams = {}; }
return __awaiter(this, void 0, void 0, function () {
var postedMessages, messages, _i, _b, message, clientmessageid;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
postedMessages = new Set();
if (!optionalParams.rehydrate) return [3 /*break*/, 2];
this.debug && console.log('[OmnichannelChatSDK][onNewMessage] rehydrate');
return [4 /*yield*/, this.getMessages()];
case 1:
messages = _c.sent();
for (_i = 0, _b = messages.reverse(); _i < _b.length; _i++) {
message = _b[_i];
clientmessageid = message.clientmessageid;
if (postedMessages.has(clientmessageid)) {
continue;
}
postedMessages.add(clientmessageid);
onNewMessageCallback(message);
}
_c.label = 2;
case 2:
(_a = this.conversation) === null || _a === void 0 ? void 0 : _a.registerOnNewMessage(function (message) {
var clientmessageid = message.clientmessageid, messageType = message.messageType;
// Filter out customer messages
if (utilities_1.isCustomerMessage(message)) {
return;
}
// Skip duplicates
if (postedMessages.has(clientmessageid)) {
return;
}
if (messageType !== MessageType_1.default.Typing) {
onNewMessageCallback(message);
}
});
return [2 /*return*/];
}
});
});

@@ -349,3 +619,3 @@ };

return __awaiter(this, void 0, void 0, function () {
var typingPayload, members, botMembers, error_6;
var typingPayload, members, botMembers, error_7;
return __generator(this, function (_a) {

@@ -370,5 +640,5 @@ switch (_a.label) {

case 5:
error_6 = _a.sent();
error_7 = _a.sent();
console.error("OmnichannelChatSDK/sendTypingEvent/error");
return [2 /*return*/, error_6];
return [2 /*return*/, error_7];
case 6: return [2 /*return*/];

@@ -401,3 +671,9 @@ }

return __generator(this, function (_b) {
(_a = this.conversation) === null || _a === void 0 ? void 0 : _a.registerOnThreadUpdate(onAgentEndSessionCallback);
(_a = this.conversation) === null || _a === void 0 ? void 0 : _a.registerOnThreadUpdate(function (message) {
var members = message.members;
// Agent ending conversation would have 1 member left in the chat thread
if (members.length === 1) {
onAgentEndSessionCallback(message);
}
});
return [2 /*return*/];

@@ -409,8 +685,16 @@ });

return __awaiter(this, void 0, void 0, function () {
var fileMetadata, messageToSend, error_7;
var fileMetadata, messageToSend, error_8;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.conversation.sendFileData(fileInfo, FileSharingProtocolType_1.default.AmsBasedFileSharing)];
case 0:
if (!(platform_1.default.isReactNative() || platform_1.default.isNode())) return [3 /*break*/, 2];
return [4 /*yield*/, this.conversation.sendFileData(fileInfo, FileSharingProtocolType_1.default.AmsBasedFileSharing)];
case 1:
fileMetadata = _a.sent();
return [3 /*break*/, 4];
case 2: return [4 /*yield*/, this.conversation.uploadFile(fileInfo, FileSharingProtocolType_1.default.AmsBasedFileSharing)];
case 3:
fileMetadata = _a.sent();
_a.label = 4;
case 4:
messageToSend = {

@@ -430,14 +714,14 @@ content: "",

};
_a.label = 2;
case 2:
_a.trys.push([2, 4, , 5]);
_a.label = 5;
case 5:
_a.trys.push([5, 7, , 8]);
return [4 /*yield*/, this.conversation.sendFileMessage(fileMetadata, messageToSend)];
case 3:
case 6:
_a.sent();
return [2 /*return*/, messageToSend];
case 4:
error_7 = _a.sent();
console.error("OmnichannelChatSDK/uploadFileAttachment/error: " + error_7);
return [2 /*return*/, error_7];
case 5: return [2 /*return*/];
case 7:
error_8 = _a.sent();
console.error("OmnichannelChatSDK/uploadFileAttachment/error: " + error_8);
return [2 /*return*/, error_8];
case 8: return [2 /*return*/];
}

@@ -487,3 +771,2 @@ });

return __awaiter(this, void 0, void 0, function () {
var scriptElement;
var _this = this;

@@ -497,31 +780,135 @@ return __generator(this, function (_a) {

}
scriptElement = document.createElement('script');
scriptElement.setAttribute('src', libraries_1.default.getIC3AdapterCDNUrl());
document.head.appendChild(scriptElement);
return [2 /*return*/, new Promise(function (resolve, reject) {
scriptElement.addEventListener('load', function () {
_this.debug && console.debug('IC3Adapter loaded!');
var adapterConfig = {
chatToken: _this.chatToken,
userDisplayName: 'Customer',
userId: 'teamsvisitor',
sdkURL: libraries_1.default.getIC3ClientCDNUrl()
};
var adapter = new window.Microsoft.BotFramework.WebChat.IC3Adapter(adapterConfig);
resolve(adapter);
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
var ic3AdapterCDNUrl;
var _this = this;
var _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
ic3AdapterCDNUrl = this.resolveChatAdapterUrl(protocol);
(_a = this.telemetry) === null || _a === void 0 ? void 0 : _a.setCDNPackages({
IC3Adapter: ic3AdapterCDNUrl
});
this.scenarioMarker.startScenario(TelemetryEvent_1.default.CreateIC3Adapter);
return [4 /*yield*/, WebUtils_1.loadScript(ic3AdapterCDNUrl, function () {
/* istanbul ignore next */
_this.debug && console.debug('IC3Adapter loaded!');
var adapterConfig = {
chatToken: _this.chatToken,
userDisplayName: 'Customer',
userId: 'teamsvisitor',
sdkURL: _this.resolveIC3ClientUrl(),
sdk: _this.IC3Client
};
var adapter = new window.Microsoft.BotFramework.WebChat.IC3Adapter(adapterConfig);
_this.scenarioMarker.completeScenario(TelemetryEvent_1.default.CreateIC3Adapter);
resolve(adapter);
}, function () {
_this.scenarioMarker.failScenario(TelemetryEvent_1.default.CreateIC3Adapter);
reject('Failed to load IC3Adapter');
})];
case 1:
_b.sent();
return [2 /*return*/];
}
});
scriptElement.addEventListener('error', function () {
reject("Failed to load IC3Adapter");
});
})];
}); })];
});
});
};
/* istanbul ignore next */
OmnichannelChatSDK.prototype.setDebug = function (flag) {
this.debug = flag;
OmnichannelChatSDK.prototype.getVoiceVideoCalling = function (params) {
if (params === void 0) { params = {}; }
return __awaiter(this, void 0, void 0, function () {
var chatConfig, liveWSAndLiveChatEngJoin, msdyn_widgetsnippet, widgetSnippetSourceRegex, result;
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (platform_1.default.isNode() || platform_1.default.isReactNative()) {
return [2 /*return*/, Promise.reject('VoiceVideoCalling is only supported on browser')];
}
if (this.callingOption.toString() === CallingOptionsOptionSetNumber_1.default.NoCalling.toString()) {
return [2 /*return*/, Promise.reject('Voice and video call is not enabled')];
}
return [4 /*yield*/, this.getChatConfig()];
case 1:
chatConfig = _a.sent();
liveWSAndLiveChatEngJoin = chatConfig.LiveWSAndLiveChatEngJoin;
msdyn_widgetsnippet = liveWSAndLiveChatEngJoin.msdyn_widgetsnippet;
widgetSnippetSourceRegex = new RegExp("src=\"(https:\\/\\/[\\w-.]+)[\\w-.\\/]+\"");
result = msdyn_widgetsnippet.match(widgetSnippetSourceRegex);
if (result && result.length) {
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
var spoolSDKCDNUrl, LiveChatWidgetLibCDNUrl;
var _this = this;
var _a, _b;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
spoolSDKCDNUrl = result[1] + "/livechatwidget/WebChatControl/lib/spool-sdk/sdk.bundle.js";
(_a = this.telemetry) === null || _a === void 0 ? void 0 : _a.setCDNPackages({
SpoolSDK: spoolSDKCDNUrl
});
this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetVoiceVideoCalling);
return [4 /*yield*/, WebUtils_1.loadScript(spoolSDKCDNUrl, function () {
/* istanbul ignore next */
_this.debug && console.debug(spoolSDKCDNUrl + " loaded!");
}, function () {
var exceptionDetails = {
response: "SpoolSDKLoadFailed"
};
_this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetVoiceVideoCalling, {
ExceptionDetails: JSON.stringify(exceptionDetails)
});
reject('Failed to load SpoolSDK');
})];
case 1:
_c.sent();
LiveChatWidgetLibCDNUrl = result[1] + "/livechatwidget/WebChatControl/lib/LiveChatWidgetLibs.min.js";
(_b = this.telemetry) === null || _b === void 0 ? void 0 : _b.setCDNPackages({
VoiceVideoCalling: LiveChatWidgetLibCDNUrl
});
return [4 /*yield*/, WebUtils_1.loadScript(LiveChatWidgetLibCDNUrl, function () { return __awaiter(_this, void 0, void 0, function () {
var VoiceVideoCalling;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
this.debug && console.debug(LiveChatWidgetLibCDNUrl + " loaded!");
return [4 /*yield*/, createVoiceVideoCalling_1.default(params)];
case 1:
VoiceVideoCalling = _a.sent();
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetVoiceVideoCalling);
VoiceVideoCalling.useScenarioMarker(this.scenarioMarker);
resolve(VoiceVideoCalling);
return [2 /*return*/];
}
});
}); }, function () { return __awaiter(_this, void 0, void 0, function () {
var exceptionDetails;
return __generator(this, function (_a) {
exceptionDetails = {
response: "VoiceVideoCallingLoadFailed"
};
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetVoiceVideoCalling, {
ExceptionDetails: JSON.stringify(exceptionDetails)
});
reject('Failed to load VoiceVideoCalling');
return [2 /*return*/];
});
}); })];
case 2:
_c.sent();
return [2 /*return*/];
}
});
}); })];
}
return [2 /*return*/];
}
});
});
};
OmnichannelChatSDK.prototype.getIC3Client = function () {
return __awaiter(this, void 0, void 0, function () {
var IC3Client, scriptElement;
var IC3Client;
var _this = this;

@@ -533,2 +920,3 @@ return __generator(this, function (_a) {

this.debug && console.debug('IC3Core');
this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetIC3Client);
// Use FramelessBridge from IC3Core

@@ -543,29 +931,62 @@ this.IC3SDKProvider = omnichannel_ic3core_1.SDKProvider;

IC3Client.setDebug(this.debug);
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetIC3Client);
return [2 /*return*/, IC3Client];
case 2:
/* istanbul ignore next */
this.debug && console.debug('IC3Client');
scriptElement = document.createElement('script');
scriptElement.setAttribute('src', libraries_1.default.getIC3ClientCDNUrl());
document.head.appendChild(scriptElement);
return [2 /*return*/, new Promise(function (resolve) {
window.addEventListener("ic3:sdk:load", function () { return __awaiter(_this, void 0, void 0, function () {
var ic3sdk, IC3SDKProvider, IC3Client;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
ic3sdk = window.Microsoft.CRM.Omnichannel.IC3Client.SDK;
IC3SDKProvider = ic3sdk.SDKProvider;
this.IC3SDKProvider = IC3SDKProvider;
return [4 /*yield*/, IC3SDKProvider.getSDK({
hostType: HostType_1.default.IFrame,
protocolType: ProtocoleType_1.default.IC3V1SDK
})];
case 1:
IC3Client = _a.sent();
resolve(IC3Client);
return [2 /*return*/];
}
});
}); });
})];
// Use IC3Client if browser is detected
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
var ic3ClientCDNUrl;
var _this = this;
var _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
ic3ClientCDNUrl = this.resolveIC3ClientUrl();
(_a = this.telemetry) === null || _a === void 0 ? void 0 : _a.setCDNPackages({
IC3Client: ic3ClientCDNUrl
});
this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetIC3Client);
window.addEventListener("ic3:sdk:load", function () { return __awaiter(_this, void 0, void 0, function () {
var ic3sdk, IC3SDKProvider, IC3Client;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
// Use FramedBridge from IC3Client
/* istanbul ignore next */
this.debug && console.debug('ic3:sdk:load');
ic3sdk = window.Microsoft.CRM.Omnichannel.IC3Client.SDK;
IC3SDKProvider = ic3sdk.SDKProvider;
this.IC3SDKProvider = IC3SDKProvider;
return [4 /*yield*/, IC3SDKProvider.getSDK({
hostType: HostType_1.default.IFrame,
protocolType: ProtocoleType_1.default.IC3V1SDK,
logger: this.ic3ClientLogger
})];
case 1:
IC3Client = _a.sent();
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetIC3Client);
resolve(IC3Client);
return [2 /*return*/];
}
});
}); });
return [4 /*yield*/, WebUtils_1.loadScript(ic3ClientCDNUrl, function () {
/* istanbul ignore next */
_this.debug && console.debug('IC3Client loaded!');
}, function () {
var exceptionDetails = {
response: "IC3ClientLoadFailed"
};
_this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetIC3Client, {
ExceptionDetails: JSON.stringify(exceptionDetails)
});
reject('Failed to load IC3Client');
})];
case 1:
_b.sent();
return [2 /*return*/];
}
});
}); })];
}

@@ -577,3 +998,3 @@ });

return __awaiter(this, void 0, void 0, function () {
var liveChatConfig, dataMaskingConfig, authSettings, liveWSAndLiveChatEngJoin, setting, preChatSurvey, msdyn_prechatenabled, isPreChatEnabled, token, error_8;
var liveChatConfig, dataMaskingConfig, authSettings, liveWSAndLiveChatEngJoin, setting, preChatSurvey, msdyn_prechatenabled, msdyn_callingoptions, isPreChatEnabled, token, error_9;
return __generator(this, function (_a) {

@@ -594,3 +1015,3 @@ switch (_a.label) {

}
preChatSurvey = liveWSAndLiveChatEngJoin.PreChatSurvey, msdyn_prechatenabled = liveWSAndLiveChatEngJoin.msdyn_prechatenabled;
preChatSurvey = liveWSAndLiveChatEngJoin.PreChatSurvey, msdyn_prechatenabled = liveWSAndLiveChatEngJoin.msdyn_prechatenabled, msdyn_callingoptions = liveWSAndLiveChatEngJoin.msdyn_callingoptions;
isPreChatEnabled = msdyn_prechatenabled === true || msdyn_prechatenabled == "true";

@@ -618,10 +1039,12 @@ if (isPreChatEnabled && preChatSurvey && preChatSurvey.trim().length > 0) {

if (this.preChatSurvey) {
/* istanbul ignore next */
this.debug && console.log('Prechat Survey!');
}
this.callingOption = msdyn_callingoptions;
this.liveChatConfig = liveChatConfig;
return [2 /*return*/, this.liveChatConfig];
case 5:
error_8 = _a.sent();
console.error("OmnichannelChatSDK/getChatConfig/error " + error_8);
return [2 /*return*/, error_8];
error_9 = _a.sent();
console.error("OmnichannelChatSDK/getChatConfig/error " + error_9);
return [2 /*return*/, error_9];
case 6: return [2 /*return*/];

@@ -632,2 +1055,23 @@ }

};
OmnichannelChatSDK.prototype.resolveIC3ClientUrl = function () {
if (this.chatSDKConfig.ic3Config && 'ic3ClientCDNUrl' in this.chatSDKConfig.ic3Config) {
return this.chatSDKConfig.ic3Config.ic3ClientCDNUrl;
}
if (this.chatSDKConfig.ic3Config && 'ic3ClientVersion' in this.chatSDKConfig.ic3Config) {
return libraries_1.default.getIC3ClientCDNUrl(this.chatSDKConfig.ic3Config.ic3ClientVersion);
}
return libraries_1.default.getIC3ClientCDNUrl();
};
OmnichannelChatSDK.prototype.resolveChatAdapterUrl = function (protocol) {
if (protocol !== ChatAdapterProtocols_1.default.IC3) {
throw new Error("ChatAdapter for protocol " + protocol + " currently not supported");
}
if (this.chatSDKConfig.chatAdapterConfig && 'webChatIC3AdapterCDNUrl' in this.chatSDKConfig.chatAdapterConfig) {
return this.chatSDKConfig.chatAdapterConfig.webChatIC3AdapterCDNUrl;
}
if (this.chatSDKConfig.chatAdapterConfig && 'webChatIC3AdapterVersion' in this.chatSDKConfig.chatAdapterConfig) {
return libraries_1.default.getIC3AdapterCDNUrl(this.chatSDKConfig.chatAdapterConfig.webChatIC3AdapterVersion);
}
return libraries_1.default.getIC3AdapterCDNUrl();
};
return OmnichannelChatSDK;

@@ -634,0 +1078,0 @@ }());

@@ -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 @@ };

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

export declare const isSystemMessage: (message: any) => any;
export declare const isCustomerMessage: (message: any) => any;
export declare const isSystemMessage: (message: any) => boolean;
export declare const isCustomerMessage: (message: any) => boolean;
"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.197fbdd",
"version": "0.1.1-main.19bda01",
"description": "Microsoft Omnichannel Chat SDK",
"files": [
"lib/**/*"
],
"main": "lib/index.js",
"types": "lib/index.d.ts",
"scripts": {
"build:tsc": "tsc",
"test": "jest"
"build:tsc": "tsc && cp -r src/external/aria lib/external/",
"test": "jest",
"lint": "eslint src --ext .ts"
},

@@ -29,10 +33,13 @@ "author": "Microsoft Corporation",

"@types/jest": "^26.0.10",
"jest": "^26.4.2",
"ts-jest": "^26.3.0",
"@typescript-eslint/eslint-plugin": "^4.9.1",
"@typescript-eslint/parser": "^4.9.1",
"eslint": "^7.15.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 not supported yet

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

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