@microsoft/omnichannel-chat-sdk
Advanced tools
Comparing version 0.2.1-main.f5ff432 to 0.3.0
@@ -5,6 +5,24 @@ # Changelog | ||
## [Unreleased] | ||
## [0.3.0] - 2021-09-03 | ||
### Added | ||
- Persistent Chat Support | ||
- Chat Reconnect Support | ||
- Operating Hours Documentation | ||
### Changed | ||
- Uptake [@microsoft/ocsdk@0.2.0](https://www.npmjs.com/package/@microsoft/ocsdk/v/0.2.0) | ||
- Add `getCallingToken` | ||
- Send `ChannelId-lcw` message tag | ||
- Uptake [IC3Client@2021.08.14.1](https://comms.omnichannelengagementhub.com/release/2021.08.14.1/Scripts/SDK/SDK.min.js) | ||
- Uptake [botframework-webchat-adapter-ic3@0.1.0-master.2dba07b](https://www.npmjs.com/package/botframework-webchat-adapter-ic3/v/0.1.0-master.2dba07b) | ||
- Uptake [jest@27.1.0](https://www.npmjs.com/package/jest/v/27.1.0) | ||
- Update [@types/jest@27.0.1](https://www.npmjs.com/package/@types/jest/v/27.0.1) | ||
- Uptake [ts-jest@27.0.5](https://www.npmjs.com/package/ts-jest/v/27.0.5) | ||
### Fixed | ||
- `msdyn_enablechatreconnect` not being parsed properly | ||
- Fix unable to start multiple conversations with same instance due to chat client being disposed | ||
- Pass logger to adapter | ||
## [0.2.0] - 2021-04-30 | ||
@@ -11,0 +29,0 @@ ### Added |
@@ -1,4 +0,4 @@ | ||
declare const ic3ClientVersion = "2021.03.02.1"; | ||
declare const webChatIC3AdapterVersion = "0.1.0-master.92b1505"; | ||
declare const ic3ClientVersion = "2021.08.14.1"; | ||
declare const webChatIC3AdapterVersion = "0.1.0-master.2dba07b"; | ||
declare const ariaTelemetryKey = "c7655518acf1403f93ff6b9f77942f0a-d01a02fd-6b50-4de3-a566-62eda11f93bc-7083"; | ||
export { ic3ClientVersion, webChatIC3AdapterVersion, ariaTelemetryKey }; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ariaTelemetryKey = exports.webChatIC3AdapterVersion = exports.ic3ClientVersion = void 0; | ||
var ic3ClientVersion = '2021.03.02.1'; | ||
var ic3ClientVersion = '2021.08.14.1'; | ||
exports.ic3ClientVersion = ic3ClientVersion; | ||
var webChatIC3AdapterVersion = '0.1.0-master.92b1505'; | ||
var webChatIC3AdapterVersion = '0.1.0-master.2dba07b'; | ||
exports.webChatIC3AdapterVersion = webChatIC3AdapterVersion; | ||
@@ -8,0 +8,0 @@ var ariaTelemetryKey = 'c7655518acf1403f93ff6b9f77942f0a-d01a02fd-6b50-4de3-a566-62eda11f93bc-7083'; |
@@ -15,2 +15,5 @@ import ChatAdapterConfig from "./ChatAdapterConfig"; | ||
} | ||
interface ChatReconnectConfig { | ||
disable: boolean; | ||
} | ||
interface IChatSDKConfig { | ||
@@ -20,2 +23,3 @@ dataMasking?: IDataMaskingSDKConfig; | ||
persistentChat?: PersistentChatConfig; | ||
chatReconnect?: ChatReconnectConfig; | ||
getAuthToken?: () => Promise<string | null>; | ||
@@ -25,3 +29,3 @@ ic3Config?: IC3Config; | ||
} | ||
export { IDataMaskingSDKConfig }; | ||
export { IDataMaskingSDKConfig, PersistentChatConfig }; | ||
export default IChatSDKConfig; |
@@ -12,2 +12,3 @@ import InitContext from "@microsoft/ocsdk/lib/Model/InitContext"; | ||
initContext?: InitContext; | ||
reconnectId?: string; | ||
} |
@@ -14,4 +14,6 @@ import IChatConfig from "./core/IChatConfig"; | ||
import IStartChatOptionalParams from "./core/IStartChatOptionalParams"; | ||
import LiveWorkItemDetails from "./core/LiveWorkItemDetails"; | ||
import OnNewMessageOptionalParams from "./core/OnNewMessageOptionalParams"; | ||
import LiveWorkItemDetails from "./core/LiveWorkItemDetails"; | ||
import ChatReconnectOptionalParams from "./core/ChatReconnectOptionalParams"; | ||
import ChatReconnectContext from "./core/ChatReconnectContext"; | ||
declare class OmnichannelChatSDK { | ||
@@ -40,6 +42,9 @@ private debug; | ||
private isPersistentChat; | ||
private isChatReconnect; | ||
private reconnectId; | ||
private refreshTokenTimer; | ||
constructor(omnichannelConfig: IOmnichannelConfig, chatSDKConfig?: IChatSDKConfig); | ||
setDebug(flag: boolean): void; | ||
initialize(): Promise<IChatConfig>; | ||
getChatReconnectContext(optionalParams?: ChatReconnectOptionalParams): Promise<ChatReconnectContext>; | ||
startChat(optionalParams?: IStartChatOptionalParams): Promise<void>; | ||
@@ -74,3 +79,4 @@ endChat(): Promise<void>; | ||
private resolveChatAdapterUrl; | ||
private updateChatToken; | ||
} | ||
export default OmnichannelChatSDK; |
@@ -25,3 +25,5 @@ declare enum TelemetryEvent { | ||
StopCall = "StopCall", | ||
OnCallDisconnected = "OnCallDisconnected" | ||
OnCallDisconnected = "OnCallDisconnected", | ||
UpdateChatToken = "UpdateChatToken", | ||
GetChatReconnectContext = "GetChatReconnectContext" | ||
} | ||
@@ -28,0 +30,0 @@ export declare const startEvent: (event: TelemetryEvent) => string; |
@@ -30,2 +30,4 @@ "use strict"; | ||
TelemetryEvent["OnCallDisconnected"] = "OnCallDisconnected"; | ||
TelemetryEvent["UpdateChatToken"] = "UpdateChatToken"; | ||
TelemetryEvent["GetChatReconnectContext"] = "GetChatReconnectContext"; | ||
})(TelemetryEvent || (TelemetryEvent = {})); | ||
@@ -32,0 +34,0 @@ exports.startEvent = function (event) { |
@@ -17,2 +17,5 @@ "use strict"; | ||
tokenUpdateTime: 21600000 | ||
}, | ||
chatReconnect: { | ||
disable: true, | ||
} | ||
@@ -33,2 +36,7 @@ }; | ||
}; | ||
var validatePersistentChatConfig = function (persistentChatConfig) { | ||
if (typeof persistentChatConfig.tokenUpdateTime !== "number" || !persistentChatConfig.tokenUpdateTime) { | ||
persistentChatConfig.tokenUpdateTime = defaultChatSDKConfig.persistentChat.tokenUpdateTime; // eslint-disable-line @typescript-eslint/no-non-null-assertion | ||
} | ||
}; | ||
var validateSDKConfig = function (chatSDKConfig) { | ||
@@ -38,4 +46,7 @@ if (chatSDKConfig.dataMasking) { | ||
} | ||
if (chatSDKConfig.persistentChat) { | ||
validatePersistentChatConfig(chatSDKConfig.persistentChat); | ||
} | ||
}; | ||
exports.default = validateSDKConfig; | ||
//# sourceMappingURL=SDKConfigValidators.js.map |
{ | ||
"name": "@microsoft/omnichannel-chat-sdk", | ||
"version": "0.2.1-main.f5ff432", | ||
"version": "0.3.0", | ||
"description": "Microsoft Omnichannel Chat SDK", | ||
@@ -32,9 +32,9 @@ "files": [ | ||
"devDependencies": { | ||
"@types/jest": "^26.0.10", | ||
"@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" | ||
"@types/jest": "^27.0.1", | ||
"@typescript-eslint/eslint-plugin": "^4.30.0", | ||
"@typescript-eslint/parser": "^4.30.0", | ||
"eslint": "^7.32.0", | ||
"jest": "^27.1.0", | ||
"ts-jest": "^27.0.5", | ||
"typescript": "^3.9.10" | ||
}, | ||
@@ -41,0 +41,0 @@ "dependencies": { |
143
README.md
@@ -19,2 +19,3 @@ # Omnichannel Chat SDK | ||
- [Telemetry](#telemetry) | ||
- [Troubleshooting Guide](docs/TROUBLESHOOTING_GUIDE.md) | ||
@@ -50,2 +51,5 @@ ## Live Chat Widget vs. Chat SDK | ||
| Proactive Chat | β | BYOI **\*** | | ||
| Persistent Chat | β | β | | ||
| Chat Reconnect | β | β | | ||
| Operating Hours | β | β | | ||
@@ -71,2 +75,3 @@ **\*** BYOI: Bring Your Own Implementation | ||
| OmnichannelChatSDK.getCurrentLiveChatContext() | Get current live chat context information to reconnect to the same chat | | | ||
| OmnichannelChatSDK.getChatReconnectContext() | Get current reconnectable chat context information to reconnect to a previous existing chat session | | | ||
| OmnichannelChatSDK.getConversationDetails() | Get details of the current conversation such as its state & when the agent joined the conversation | | | ||
@@ -119,2 +124,11 @@ | OmnichannelChatSDK.getChatToken() | Get chat token | | | ||
### Get Current Chat Reconnect Context | ||
```ts | ||
const optionalParams = { | ||
reconnectId: '', // reconnect Id | ||
}; | ||
const chatReconnectContext = await chatSDK.getChatReconnectContext(optionalParams); | ||
``` | ||
### Get Conversation Details | ||
@@ -358,2 +372,121 @@ ```ts | ||
### Persistent Chat | ||
```ts | ||
const chatSDKConfig = { | ||
persistentChat: { | ||
disable: false, | ||
tokenUpdateTime: 21600000 | ||
}, | ||
getAuthToken: async () => { | ||
const response = await fetch("http://contosohelp.com/token"); | ||
if (response.ok) { | ||
return await response.text(); | ||
} | ||
else { | ||
return null | ||
} | ||
} | ||
} | ||
const chatSDK = new OmnichannelChatSDK.OmnichannelChatSDK(omnichannelConfig, chatSDKConfig); | ||
await chatSDK.initialize(); | ||
// from this point, this acts like a persistent chat | ||
``` | ||
### Chat Reconnect with Authenticated User | ||
```ts | ||
const chatSDKConfig = { | ||
chatReconnect: { | ||
disable: false, | ||
}, | ||
getAuthToken: async () => { | ||
const response = await fetch("http://contosohelp.com/token"); | ||
if (response.ok) { | ||
return await response.text(); | ||
} | ||
else { | ||
return null | ||
} | ||
} | ||
} | ||
const chatSDK = new OmnichannelChatSDK.OmnichannelChatSDK(omnichannelConfig, chatSDKConfig); | ||
await chatSDK.initialize(); | ||
... | ||
const chatReconnectContext = await chatSDK.getChatReconnectContext(); | ||
if (chatReconnectContext.reconnectId) { | ||
// Add UX with options to reconnect to previous existing chat or start new chat | ||
} | ||
// Reconnect chat option | ||
const optionalParams = {}; | ||
optionalParams.reconnectId = chatReconnectContext.reconnectId; | ||
chatSDK.startChat(optionalParams); | ||
// Start new chat option | ||
chatSDK.startChat(); | ||
``` | ||
### Chat Reconnect with Unauthenticated User | ||
```ts | ||
const chatSDKConfig = { | ||
chatReconnect: { | ||
disable: false, | ||
}, | ||
} | ||
const chatSDK = new OmnichannelChatSDK.OmnichannelChatSDK(omnichannelConfig, chatSDKConfig); | ||
await chatSDK.initialize(); | ||
.... | ||
const optionalParams: any = {}; | ||
// Retrieve reconnect id from the URL | ||
const urlParams = new URLSearchParams(window.location.search); | ||
const reconnectId = urlParams.get('oc.reconnectid'); | ||
const params = { | ||
reconnectId | ||
}; | ||
// Validate reconnect id | ||
const chatReconnectContext = await chatSDK.getChatReconnectContext(params); | ||
// If the reconnect id is invalid or expired, redirect URL if there is any URL set in the configuration | ||
if (chatReconnectContext.redirectURL) { | ||
window.location.replace(chatReconnectContext.redirectURL); | ||
} | ||
// Valid reconnect id, reconnect to previous chat | ||
if (chatReconnectContext.reconnectId) { | ||
await chatSDK.startChat({ | ||
reconnectId: chatReconnectContext.reconnectId | ||
}); | ||
} else { // Reconnect id from URL is not valid, start new chat session | ||
await chatSDK.startChat(); | ||
} | ||
``` | ||
### Operating Hours | ||
```ts | ||
const chatConfig = await chatSDK.getLiveChatConfig(); | ||
const {LiveWSAndLiveChatEngJoin: liveWSAndLiveChatEngJoin} = liveChatConfig; | ||
const {OutOfOperatingHours: outOfOperatingHours} = liveWSAndLiveChatEngJoin; | ||
if (outOfOperatingHours === "True") { | ||
// Handles UX on Out of Operating Hours | ||
} else { | ||
await chatSDK.startChat(); | ||
// Renders Custom Chat Widget | ||
} | ||
``` | ||
### Use [BotFramework-WebChat](https://github.com/microsoft/BotFramework-WebChat) | ||
@@ -378,3 +511,3 @@ | ||
// Subscribes to incoming message (OPTION 1) | ||
// Subscribes to incoming message | ||
chatSDK.onNewMessage((message) => { | ||
@@ -385,10 +518,2 @@ console.log(`[NewMessage] ${message.content}`); // IC3 protocol message data | ||
// Subscribes to incoming message (OPTION 2) | ||
(chatAdapter as any).activity$.subscribe((activity: any) => { | ||
if (activity.type === "message") { | ||
console.log("[Message activity]"); | ||
console.log(activity); // DirectLine protocol activity data | ||
} | ||
}); | ||
... | ||
@@ -395,0 +520,0 @@ |
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
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
748840
198
9162
686