@koredev/agentai-web-sdk 1.3.0-rc → 1.3.2-rc

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,447 +1,6 @@
1
1
  "use strict";
2
2
  self["webpackHotUpdateaa_sdk"]("KoreAASDK",{
3
3
 
4
- /***/ "./src/components/aaWindow/aaWindow.ts":
5
- /*!*********************************************!*\
6
- !*** ./src/components/aaWindow/aaWindow.ts ***!
7
- \*********************************************/
8
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
9
-
10
- __webpack_require__.r(__webpack_exports__);
11
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
12
- /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
13
- /* harmony export */ });
14
- /* harmony import */ var _aaWindow_scss__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./_aaWindow.scss */ "./src/components/aaWindow/_aaWindow.scss");
15
- /* harmony import */ var _common_utils_EventEmiter__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../common/utils/EventEmiter */ "./src/components/common/utils/EventEmiter.ts");
16
- /* harmony import */ var _common_templatemanager_base_domManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../common/templatemanager/base/domManager */ "./src/components/common/templatemanager/base/domManager.tsx");
17
- /* harmony import */ var _common_templatemanager_base_aaContainer_aaContainer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../common/templatemanager/base/aaContainer/aaContainer */ "./src/components/common/templatemanager/base/aaContainer/aaContainer.tsx");
18
- /* harmony import */ var _common_services_web_socket_service__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../common/services/web-socket-service */ "./src/components/common/services/web-socket-service.ts");
19
- /* harmony import */ var _common_constants_events_cnst__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../common/constants/events.cnst */ "./src/components/common/constants/events.cnst.ts");
20
- /* harmony import */ var _common_services_rootService__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../common/services/rootService */ "./src/components/common/services/rootService.ts");
21
- /* harmony import */ var _common_templatemanager_base_eventManager__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../common/templatemanager/base/eventManager */ "./src/components/common/templatemanager/base/eventManager.tsx");
22
- /* harmony import */ var _common_utils_interceptor__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../common/utils/interceptor */ "./src/components/common/utils/interceptor.ts");
23
- var __extends = (undefined && undefined.__extends) || (function () {
24
- var extendStatics = function (d, b) {
25
- extendStatics = Object.setPrototypeOf ||
26
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
27
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
28
- return extendStatics(d, b);
29
- };
30
- return function (d, b) {
31
- if (typeof b !== "function" && b !== null)
32
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
33
- extendStatics(d, b);
34
- function __() { this.constructor = d; }
35
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
36
- };
37
- })();
38
-
39
-
40
-
41
-
42
-
43
-
44
-
45
-
46
-
47
- var AAWindow = /** @class */ (function (_super) {
48
- __extends(AAWindow, _super);
49
- function AAWindow() {
50
- var _this = _super.call(this) || this;
51
- _this.handleOverrideMode = function (toggleOverride, dialogId) {
52
- var _a;
53
- var connectionDetails = _this.rootService.connectionDetails;
54
- var overRideObj = {
55
- "agentId": "",
56
- "botId": connectionDetails.botId,
57
- "conversationId": connectionDetails.conversationId,
58
- "query": "",
59
- "enable_override_userinput": toggleOverride,
60
- 'experience': (_a = _this.rootService.connectionDetails) === null || _a === void 0 ? void 0 : _a.channel,
61
- "positionId": dialogId
62
- };
63
- _this.rootService.proactiveMode = !toggleOverride;
64
- _this.socketConnection.emitEvents(_common_constants_events_cnst__WEBPACK_IMPORTED_MODULE_5__.EVENTS.enable_override_userinput, overRideObj);
65
- _this.rootService.OverRideMode = toggleOverride;
66
- };
67
- return _this;
68
- }
69
- AAWindow.prototype.show = function (config) {
70
- var _a;
71
- this.config = config;
72
- this.applyBranding((_a = config.branding) === null || _a === void 0 ? void 0 : _a.colors);
73
- this.initShow(config);
74
- this.eventManager = new _common_templatemanager_base_eventManager__WEBPACK_IMPORTED_MODULE_7__["default"](this);
75
- };
76
- ;
77
- AAWindow.prototype.sendUserMessage = function (_data) {
78
- var _a, _b, _c, _d, _e, _f, _g;
79
- if (_data.message && ((_b = (_a = _data.author) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === 'user') {
80
- var conversationId = (_c = this.rootService.connectionDetails) === null || _c === void 0 ? void 0 : _c.conversationId;
81
- var botId = (_d = this.rootService.connectionDetails) === null || _d === void 0 ? void 0 : _d.botId;
82
- var data = {
83
- author: _data.author,
84
- type: (_f = (_e = _data.author) === null || _e === void 0 ? void 0 : _e.type) === null || _f === void 0 ? void 0 : _f.toUpperCase(),
85
- conversationId: conversationId,
86
- message: _data.message,
87
- botId: botId
88
- };
89
- this.emit(_common_constants_events_cnst__WEBPACK_IMPORTED_MODULE_5__.INTERNAL_EVENTS.USER_TRANSCRIPT_MSG, data);
90
- this.socketConnection.emitEvents(_common_constants_events_cnst__WEBPACK_IMPORTED_MODULE_5__.EVENTS.user_sent_message, data);
91
- if (this.rootService.proactiveMode) {
92
- var agent_assist_request = {
93
- author: _data.author,
94
- botId: botId,
95
- conversationId: conversationId,
96
- experience: (_g = this.rootService.connectionDetails) === null || _g === void 0 ? void 0 : _g.channel,
97
- query: _data.message,
98
- positionId: this.rootService.isAutomationOnGoing ? this.rootService.currentPositionId : null
99
- };
100
- if (_data === null || _data === void 0 ? void 0 : _data.customData) {
101
- agent_assist_request['customData'] = JSON.parse(JSON.stringify(_data === null || _data === void 0 ? void 0 : _data.customData));
102
- }
103
- if (_data === null || _data === void 0 ? void 0 : _data.secureCustomData) {
104
- agent_assist_request['secureCustomData'] = _data === null || _data === void 0 ? void 0 : _data.secureCustomData;
105
- }
106
- this.socketConnection.emitEvents(_common_constants_events_cnst__WEBPACK_IMPORTED_MODULE_5__.EVENTS.agent_assist_request, agent_assist_request);
107
- }
108
- }
109
- else {
110
- this.emit(_common_constants_events_cnst__WEBPACK_IMPORTED_MODULE_5__.SDK_EVENTS.ON_ERROR, {
111
- message: 'Missing required fields to send user message'
112
- });
113
- }
114
- };
115
- AAWindow.prototype.sendAgentMessage = function (_data) {
116
- var _a, _b, _c, _d, _e, _f;
117
- if (_data.message && ((_b = (_a = _data.author) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === 'agent') {
118
- var conversationId = (_c = this.rootService.connectionDetails) === null || _c === void 0 ? void 0 : _c.conversationId;
119
- var botId = (_d = this.rootService.connectionDetails) === null || _d === void 0 ? void 0 : _d.botId;
120
- var data = {
121
- author: _data.author,
122
- type: (_f = (_e = _data.author) === null || _e === void 0 ? void 0 : _e.type) === null || _f === void 0 ? void 0 : _f.toUpperCase(),
123
- conversationId: conversationId,
124
- message: _data.message,
125
- botId: botId
126
- };
127
- this.emit(_common_constants_events_cnst__WEBPACK_IMPORTED_MODULE_5__.INTERNAL_EVENTS.AGENT_TRANSCRIPT_MSG, data);
128
- if (_data === null || _data === void 0 ? void 0 : _data.customData) {
129
- data['customData'] = JSON.parse(JSON.stringify(_data === null || _data === void 0 ? void 0 : _data.customData));
130
- }
131
- if (_data === null || _data === void 0 ? void 0 : _data.secureCustomData) {
132
- data['secureCustomData'] = _data === null || _data === void 0 ? void 0 : _data.secureCustomData;
133
- }
134
- this.socketConnection.emitEvents(_common_constants_events_cnst__WEBPACK_IMPORTED_MODULE_5__.EVENTS.agent_sent_message, data);
135
- }
136
- else {
137
- this.emit(_common_constants_events_cnst__WEBPACK_IMPORTED_MODULE_5__.SDK_EVENTS.ON_ERROR, {
138
- message: 'Missing required fields to send agent message'
139
- });
140
- }
141
- };
142
- AAWindow.prototype.initShow = function (config) {
143
- var _this = this;
144
- this.renderLoader();
145
- this.socketConnection = new _common_services_web_socket_service__WEBPACK_IMPORTED_MODULE_4__["default"](this);
146
- this.rootService = new _common_services_rootService__WEBPACK_IMPORTED_MODULE_6__["default"]();
147
- this.rootService.connectionDetails = config.connectionDetails;
148
- this.JWTSetup(config)
149
- .then(function (data) {
150
- _this.rootService.grantResponseObj = data;
151
- config['JWT_RESP'] = data;
152
- _this.socketConnection.configOptions = config;
153
- var botId = config.connectionDetails.botId;
154
- _this.getAASettings(botId)
155
- .then(function (settings) {
156
- _this.rootService.aaSettings = (settings === null || settings === void 0 ? void 0 : settings.agentAssistSettings) || {};
157
- _this.socketConnection.socketConnection(config);
158
- var chatWindowHtml;
159
- chatWindowHtml = (0,_common_templatemanager_base_domManager__WEBPACK_IMPORTED_MODULE_2__.getHTML)(_common_templatemanager_base_aaContainer_aaContainer__WEBPACK_IMPORTED_MODULE_3__.AAContainer, {}, _this);
160
- _this.chatEle = chatWindowHtml;
161
- _this.render(chatWindowHtml);
162
- _this.bindEvents();
163
- });
164
- })
165
- .catch(function (err) {
166
- });
167
- };
168
- ;
169
- AAWindow.prototype.getAASettings = function (botId) {
170
- var channel = this.rootService.connectionDetails.channel;
171
- return (0,_common_utils_interceptor__WEBPACK_IMPORTED_MODULE_8__["default"])('get_aa_settings', {
172
- method: 'GET',
173
- headers: {
174
- 'Content-Type': 'application/json',
175
- },
176
- }, this, { botId: botId, channel: channel });
177
- };
178
- AAWindow.prototype.JWTSetup = function (options) {
179
- var _a = options.connectionDetails || {}, token = _a.token, botId = _a.botId;
180
- var payload = {
181
- "assertion": token,
182
- "botInfo": {
183
- taskBotId: botId,
184
- chatBot: 'Sample Bot'
185
- },
186
- "token": {}
187
- };
188
- return (0,_common_utils_interceptor__WEBPACK_IMPORTED_MODULE_8__["default"])('jwt_grant', {
189
- method: 'POST',
190
- body: JSON.stringify(payload),
191
- }, this);
192
- };
193
- AAWindow.prototype.render = function (chatWindowHtml) {
194
- this.clearContainer();
195
- var container = document.getElementsByClassName(this.config.container)[0];
196
- container.append(chatWindowHtml);
197
- };
198
- ;
199
- AAWindow.prototype.clearContainer = function () {
200
- var elements = document.getElementsByClassName(this.config.container);
201
- // Loop through each element and clear its children
202
- for (var i = 0; i < elements.length; i++) {
203
- while (elements[i].firstChild) {
204
- elements[i].removeChild(elements[i].firstChild);
205
- }
206
- }
207
- };
208
- AAWindow.prototype.renderLoader = function () {
209
- var loaderHtml = (0,_common_templatemanager_base_domManager__WEBPACK_IMPORTED_MODULE_2__.getHTML)(_common_templatemanager_base_aaContainer_aaContainer__WEBPACK_IMPORTED_MODULE_3__.AALoder, {}, this);
210
- var container = document.getElementsByClassName(this.config.container)[0];
211
- container.append(loaderHtml);
212
- };
213
- AAWindow.prototype.bindEvents = function () {
214
- var _this = this;
215
- this.on('ON_SOCKET_CONNECTION', function (config) {
216
- _this.commonEmitEvents(config);
217
- });
218
- };
219
- AAWindow.prototype.commonEmitEvents = function (config) {
220
- var _a, _b;
221
- var _c = config === null || config === void 0 ? void 0 : config.connectionDetails, botId = _c.botId, conversationId = _c.conversationId, autoBotId = _c.autoBotId, interactiveLanguage = _c.interactiveLanguage, userName = _c.userName, customData = _c.customData, token = _c.token, channel = _c.channel;
222
- var sendCustomData = '';
223
- var sendInteractiveLanguage = '';
224
- var sendAutoBotId = '';
225
- if (customData && ((_a = Object.keys(customData)) === null || _a === void 0 ? void 0 : _a.length) > 0 && ((_b = config === null || config === void 0 ? void 0 : config.connectionDetails) === null || _b === void 0 ? void 0 : _b.source) !== 'smartassist-color-scheme') {
226
- sendCustomData = customData;
227
- }
228
- ;
229
- if (interactiveLanguage !== null && typeof interactiveLanguage !== 'undefined' && interactiveLanguage !== "''") {
230
- sendInteractiveLanguage = interactiveLanguage; // Return the default value for null, undefined, or "''"
231
- }
232
- ;
233
- if (autoBotId && autoBotId !== 'undefined') {
234
- sendAutoBotId = autoBotId;
235
- }
236
- ;
237
- var welComeMsgReqParam = {
238
- "waitTime": 2000,
239
- "userName": userName,
240
- "id": conversationId,
241
- "isSendWelcomeMessage": true,
242
- "agentassistInfo": {},
243
- "botId": botId,
244
- "sendMenuRequest": true,
245
- "uId": "",
246
- "sId": "",
247
- "experience": channel,
248
- "jToken": token,
249
- "conversationId": conversationId,
250
- "autoBotId": sendAutoBotId,
251
- "language": sendInteractiveLanguage,
252
- "allQueryParams": config === null || config === void 0 ? void 0 : config.connectionDetials,
253
- "customData": sendCustomData,
254
- };
255
- this.welComeMsgReq(welComeMsgReqParam);
256
- this.handleOverrideMode(false, null);
257
- var menuReqParam = {
258
- "botId": botId,
259
- "conversationId": conversationId,
260
- "experience": channel,
261
- "autoBotId": sendAutoBotId,
262
- "language": sendInteractiveLanguage
263
- };
264
- this.menuReq(menuReqParam);
265
- };
266
- AAWindow.prototype.prepareAgentAssistRequestParams = function (data) {
267
- var _a, _b, _c, _d, _e, _f, _g, _h;
268
- var connectionDetails = (_b = (_a = this.socketConnection) === null || _a === void 0 ? void 0 : _a.configOptions) === null || _b === void 0 ? void 0 : _b.connectionDetails;
269
- var agent_assist_request = {
270
- 'conversationId': data.conversationId,
271
- 'query': data.value,
272
- 'botId': data.botId,
273
- 'agentId': '',
274
- 'experience': connectionDetails === null || connectionDetails === void 0 ? void 0 : connectionDetails.channel,
275
- 'positionId': data.positionId,
276
- 'intType': 'assist'
277
- };
278
- if (data.intentName) {
279
- agent_assist_request['intentName'] = data.value;
280
- }
281
- if (data.entities) {
282
- agent_assist_request['entities'] = data.entities;
283
- }
284
- else {
285
- agent_assist_request['entities'] = [];
286
- }
287
- if (data.childBotId) {
288
- agent_assist_request['childBotId'] = data.childBotId;
289
- }
290
- if (data.childBotName) {
291
- agent_assist_request['childBotName'] = data.childBotName;
292
- }
293
- if ((connectionDetails === null || connectionDetails === void 0 ? void 0 : connectionDetails.autoBotId) && (connectionDetails === null || connectionDetails === void 0 ? void 0 : connectionDetails.autoBotId) !== 'undefined') {
294
- agent_assist_request['autoBotId'] = connectionDetails.autoBotId;
295
- }
296
- else {
297
- agent_assist_request['autoBotId'] = '';
298
- }
299
- if (data.intentName && data.userInput) {
300
- agent_assist_request['query'] = data.userInput;
301
- }
302
- if (this.rootService.isAutomationOnGoing) {
303
- agent_assist_request['positionId'] = this.rootService.currentPositionId;
304
- }
305
- if (Array.isArray(data.traits) && ((_c = data === null || data === void 0 ? void 0 : data.traits) === null || _c === void 0 ? void 0 : _c.length)) {
306
- agent_assist_request['traits'] = data.traits;
307
- }
308
- if (data.taskRefId) {
309
- agent_assist_request['taskRefId'] = data.taskRefId;
310
- }
311
- if (data.dialogId) {
312
- agent_assist_request['dialogId'] = data.dialogId;
313
- }
314
- if (data.isDiscard) {
315
- agent_assist_request['terminateTask'] = data.isDiscard;
316
- }
317
- if (data === null || data === void 0 ? void 0 : data.attachments) {
318
- agent_assist_request['query'] = ((_e = (_d = data === null || data === void 0 ? void 0 : data.attachments[0]) === null || _d === void 0 ? void 0 : _d.url) === null || _e === void 0 ? void 0 : _e.fileUrl) || '';
319
- agent_assist_request['attachments'] = data === null || data === void 0 ? void 0 : data.attachments;
320
- }
321
- if (data === null || data === void 0 ? void 0 : data.author) {
322
- agent_assist_request['firstName'] = ((_f = data === null || data === void 0 ? void 0 : data.author) === null || _f === void 0 ? void 0 : _f.firstName) || '';
323
- agent_assist_request['lastName'] = ((_g = data === null || data === void 0 ? void 0 : data.author) === null || _g === void 0 ? void 0 : _g.lastName) || '';
324
- agent_assist_request['type'] = ((_h = data === null || data === void 0 ? void 0 : data.author) === null || _h === void 0 ? void 0 : _h.type) || '';
325
- }
326
- agent_assist_request = this.addSourceMsgIdToRequestParams(data, agent_assist_request);
327
- return agent_assist_request;
328
- };
329
- AAWindow.prototype.prepareAgentAssistAgentRequestParams = function (data) {
330
- var _a, _b, _c, _d, _e;
331
- var connectionDetails = (_b = (_a = this.socketConnection) === null || _a === void 0 ? void 0 : _a.configOptions) === null || _b === void 0 ? void 0 : _b.connectionDetails;
332
- var agent_assist_agent_request_params = {
333
- 'isSearch': data.isSearch,
334
- 'conversationId': data.conversationId,
335
- 'query': data.value,
336
- 'botId': data.botId,
337
- 'experience': connectionDetails === null || connectionDetails === void 0 ? void 0 : connectionDetails.channel,
338
- 'positionId': data === null || data === void 0 ? void 0 : data.positionId,
339
- 'childBotId': (data === null || data === void 0 ? void 0 : data.childBotId) || '',
340
- 'childBotName': (data === null || data === void 0 ? void 0 : data.childBotName) || '',
341
- 'intType': 'myBot'
342
- };
343
- if (data.intentName) {
344
- agent_assist_agent_request_params.intentName = data.intentName;
345
- }
346
- // if(data.childBotId) {
347
- // agent_assist_agent_request_params['childBotId'] = data.childBotId;
348
- // agent_assist_agent_request_params['childBotName'] = data.childBotName;
349
- // }
350
- if ((connectionDetails === null || connectionDetails === void 0 ? void 0 : connectionDetails.autoBotId) && (connectionDetails === null || connectionDetails === void 0 ? void 0 : connectionDetails.autoBotId) !== 'undefined') {
351
- agent_assist_agent_request_params['autoBotId'] = connectionDetails.autoBotId;
352
- }
353
- else {
354
- agent_assist_agent_request_params['autoBotId'] = '';
355
- }
356
- if (data.intentName && data.userInput) {
357
- agent_assist_agent_request_params['query'] = data.userInput;
358
- }
359
- // if (this.isMyBotAutomationOnGoing) {
360
- // agent_assist_agent_request_params['positionId'] = this.currentPositionIdOfMyBot;
361
- // }
362
- if (Array.isArray(data.traits) && ((_c = data === null || data === void 0 ? void 0 : data.traits) === null || _c === void 0 ? void 0 : _c.length)) {
363
- agent_assist_agent_request_params['traits'] = data.traits;
364
- }
365
- if (data.taskRefId) {
366
- agent_assist_agent_request_params['taskRefId'] = data.taskRefId;
367
- }
368
- if (data.dialogId) {
369
- agent_assist_agent_request_params['dialogId'] = data.dialogId;
370
- }
371
- if (data.isDiscard) {
372
- agent_assist_agent_request_params['terminateTask'] = data.isDiscard;
373
- }
374
- if (data === null || data === void 0 ? void 0 : data.attachments) {
375
- agent_assist_agent_request_params['query'] = ((_e = (_d = data === null || data === void 0 ? void 0 : data.attachments[0]) === null || _d === void 0 ? void 0 : _d.url) === null || _e === void 0 ? void 0 : _e.fileUrl) || '';
376
- agent_assist_agent_request_params['attachments'] = data === null || data === void 0 ? void 0 : data.attachments;
377
- }
378
- agent_assist_agent_request_params = this.addSourceMsgIdToRequestParams(data, agent_assist_agent_request_params);
379
- return agent_assist_agent_request_params;
380
- };
381
- AAWindow.prototype.addSourceMsgIdToRequestParams = function (data, requestParams) {
382
- if (data.sourceMsgId) {
383
- if (data.sourceMsgId == 'fromLibrary') {
384
- requestParams['fromLibrary'] = true;
385
- }
386
- else {
387
- requestParams['sourceMsgId'] = data.sourceMsgId;
388
- }
389
- }
390
- return requestParams;
391
- };
392
- AAWindow.prototype.welComeMsgReq = function (welComeMsgReqParam) {
393
- this.socketConnection.emitEvents(_common_constants_events_cnst__WEBPACK_IMPORTED_MODULE_5__.EVENTS.welcome_message_request, welComeMsgReqParam);
394
- };
395
- AAWindow.prototype.menuReq = function (menuReqParam) {
396
- this.socketConnection.emitEvents(_common_constants_events_cnst__WEBPACK_IMPORTED_MODULE_5__.EVENTS.agent_menu_request, menuReqParam);
397
- };
398
- //events to handle from client
399
- // selectAAFooterTab(data : any){
400
- // this.emit('selectTab', data , {});
401
- // }
402
- AAWindow.prototype.openAssistTab = function (footerTag, isActive) {
403
- this.emit('updateActiveTab', { activeTab: 'ast', isActive: isActive, footerTag: footerTag });
404
- };
405
- AAWindow.prototype.openTranscriptTab = function (footerTag, isActive) {
406
- this.emit('updateActiveTab', { activeTab: 'trnspt', isActive: isActive, footerTag: footerTag });
407
- };
408
- AAWindow.prototype.openSearchTab = function (footerTag, isActive) {
409
- this.emit('updateActiveTab', { activeTab: 'srch', isActive: isActive, footerTag: footerTag });
410
- };
411
- AAWindow.prototype.openMybotTab = function (footerTag, isActive) {
412
- this.emit('updateActiveTab', { activeTab: 'mB', isActive: isActive, footerTag: footerTag });
413
- };
414
- AAWindow.prototype.openPlaybookTab = function (footerTag, isActive) {
415
- this.emit('updateActiveTab', { activeTab: 'playbook', isActive: isActive, footerTag: footerTag });
416
- };
417
- AAWindow.prototype.endOfConversation = function () {
418
- this.emit(_common_constants_events_cnst__WEBPACK_IMPORTED_MODULE_5__.INTERNAL_EVENTS.END_OF_CONVERSATION);
419
- };
420
- AAWindow.prototype.applyBranding = function (colors) {
421
- var colorObj = {
422
- primay: '--AA-primary-color',
423
- secondary: '--AA-secondary-color',
424
- primaryText: '--AA-primary-text',
425
- secondaryText: '--AA-secondary-text',
426
- bodyBackground: '--AA-body-background',
427
- warningColor: '--AA-warning-color',
428
- };
429
- if (colorObj) {
430
- for (var key in colorObj) {
431
- if (Object.prototype.hasOwnProperty.call(colorObj, key)) {
432
- var element = colorObj[key];
433
- document.documentElement.style.setProperty(element, colors[key]);
434
- }
435
- }
436
- }
437
- };
438
- return AAWindow;
439
- }(_common_utils_EventEmiter__WEBPACK_IMPORTED_MODULE_1__.EventEmitter));
440
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (AAWindow);
441
-
442
-
443
- /***/ }),
444
-
445
4
  /***/ "./src/components/common/constants/events.cnst.ts":
446
5
  /*!********************************************************!*\
447
6
  !*** ./src/components/common/constants/events.cnst.ts ***!
@@ -528,6 +87,8 @@ var SDK_EVENTS;
528
87
  SDK_EVENTS["CONVERSATION_SUMMARY_TEMPLATE"] = "CONVERSATION_SUMMARY_TEMPLATE";
529
88
  SDK_EVENTS["SUMMARY_TEMPLATE_ASSIST"] = "SUMMARY_TEMPLATE_ASSIST";
530
89
  SDK_EVENTS["ON_ERROR"] = "ON_ERROR";
90
+ SDK_EVENTS["AGENT_SEND_MESSAGE"] = "AGENT_SEND_MESSAGE";
91
+ SDK_EVENTS["AGENT_COPY_MESSAGE"] = "AGENT_COPY_MESSAGE";
531
92
  })(SDK_EVENTS || (SDK_EVENTS = {}));
532
93
  var DATA_EVENTS;
533
94
  (function (DATA_EVENTS) {
@@ -545,292 +106,16 @@ var INTERNAL_EVENTS;
545
106
  INTERNAL_EVENTS["AGENT_TRANSCRIPT_MSG"] = "AGENT_TRANSCRIPT_MSG";
546
107
  INTERNAL_EVENTS["END_OF_CONVERSATION"] = "END_OF_CONVERSATION";
547
108
  INTERNAL_EVENTS["CONVERSATION_SUMMARY_IN_ASSIST"] = "CONVERSATION_SUMMARY_IN_ASSIST";
548
- INTERNAL_EVENTS["ON_ERROR"] = "ON_ERROR";
549
109
  })(INTERNAL_EVENTS || (INTERNAL_EVENTS = {}));
550
110
 
551
111
 
552
- /***/ }),
553
-
554
- /***/ "./src/components/common/templatemanager/tabs/transcript/transcript.tsx":
555
- /*!******************************************************************************!*\
556
- !*** ./src/components/common/templatemanager/tabs/transcript/transcript.tsx ***!
557
- \******************************************************************************/
558
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
559
-
560
- __webpack_require__.r(__webpack_exports__);
561
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
562
- /* harmony export */ Transcript: () => (/* binding */ Transcript)
563
- /* harmony export */ });
564
- /* harmony import */ var preact__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.module.js");
565
- /* harmony import */ var preact_hooks__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! preact/hooks */ "./node_modules/preact/hooks/dist/hooks.module.js");
566
- /* harmony import */ var _transcript_scss__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./transcript.scss */ "./src/components/common/templatemanager/tabs/transcript/transcript.scss");
567
- /* harmony import */ var _base_domManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../base/domManager */ "./src/components/common/templatemanager/base/domManager.tsx");
568
- /* harmony import */ var _constants_events_cnst__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../constants/events.cnst */ "./src/components/common/constants/events.cnst.ts");
569
- /* harmony import */ var _utils_interceptor__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../utils/interceptor */ "./src/components/common/utils/interceptor.ts");
570
- /* harmony import */ var _constants_projConsts__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../constants/projConsts */ "./src/components/common/constants/projConsts.ts");
571
- var __spreadArray = (undefined && undefined.__spreadArray) || function (to, from, pack) {
572
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
573
- if (ar || !(i in from)) {
574
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
575
- ar[i] = from[i];
576
- }
577
- }
578
- return to.concat(ar || Array.prototype.slice.call(from));
579
- };
580
-
581
-
582
-
583
-
584
-
585
-
586
-
587
- function Transcript(_a) {
588
- var hostInstance = _a.hostInstance;
589
- var _b = (0,preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useState)([]), messages = _b[0], setMessages = _b[1];
590
- var _c = (0,preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useState)([]), userAgentHistory = _c[0], setUserAgentHistory = _c[1];
591
- var _d = (0,preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useState)([]), userBotHistory = _d[0], setUserBotHistory = _d[1];
592
- var _e = (0,preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useState)(undefined), summary = _e[0], setSummary = _e[1];
593
- var _f = (0,preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useState)(null), agentJoinedBanner = _f[0], setAgentJoinedBanner = _f[1];
594
- var isInitialRender = (0,preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useRef)(true);
595
- var rootServiceInstance = hostInstance.rootService;
596
- var classMapConstansts = _constants_projConsts__WEBPACK_IMPORTED_MODULE_6__.ClassMapConstanst;
597
- // Socket and History API call methods
598
- (0,preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useEffect)(function () {
599
- listeningToSocketEvents();
600
- transcriptHistoryAPICall();
601
- }, []);
602
- // User and Agent transcript messages from Socket
603
- var listeningToSocketEvents = function () {
604
- var handleUserAgentMessage = function (agentResponse) { return handleTranscriptionResponse(agentResponse); };
605
- hostInstance.on('AGENT_TRANSCRIPT_MSG', handleUserAgentMessage);
606
- hostInstance.on('USER_TRANSCRIPT_MSG', handleUserAgentMessage);
607
- hostInstance.on('AGENT_TRANSCRIPT_RESPONSE', handleUserAgentMessage);
608
- hostInstance.on('USER_TRANSCRIPT_RESPONSE', handleUserAgentMessage);
609
- };
610
- // Transcript History API call
611
- var transcriptHistoryAPICall = function () {
612
- fetchTranscriptHistoryData().then(function (res) {
613
- if (res) {
614
- var userBotMessages = res.userBotMessages, summary_1 = res.summary, userAgentMessages = res.userAgentMessages;
615
- var processedUserBotMessages = processMessages(userBotMessages === null || userBotMessages === void 0 ? void 0 : userBotMessages.result);
616
- setUserBotHistory(processedUserBotMessages);
617
- if (summary_1 === null || summary_1 === void 0 ? void 0 : summary_1.message) {
618
- summaryBannerData(summary_1);
619
- }
620
- var processedUserAgentMessages = processMessages(userAgentMessages === null || userAgentMessages === void 0 ? void 0 : userAgentMessages.result);
621
- setUserAgentHistory(processedUserAgentMessages);
622
- }
623
- })
624
- .catch(function (error) {
625
- addAgentJoiningBanner();
626
- });
627
- };
628
- (0,preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useEffect)(function () {
629
- if (isInitialRender.current) {
630
- isInitialRender.current = false;
631
- return;
632
- }
633
- (userBotHistory || []).forEach(function (element) {
634
- var _a, _b;
635
- if ((_b = (_a = element === null || element === void 0 ? void 0 : element.components[0]) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.text) {
636
- handleUserBotHistoryResponse(element);
637
- }
638
- });
639
- if (summary === null || summary === void 0 ? void 0 : summary.msg) {
640
- var summaryBanner = (0,_base_domManager__WEBPACK_IMPORTED_MODULE_3__.getHTML)(SummaryEleBanner, summary, hostInstance);
641
- var transcriptEle = document.getElementsByClassName(classMapConstansts.TRANSCRIPT_BODY_WRAPPER)[0];
642
- hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_4__.SDK_EVENTS.BEFORE_VIEW_INIT, summaryBanner, { event: _constants_events_cnst__WEBPACK_IMPORTED_MODULE_4__.SDK_EVENTS.SUMMARY_TEMPLATE, summary: summary });
643
- transcriptEle.append(summaryBanner);
644
- }
645
- addAgentJoiningBanner();
646
- (userAgentHistory || []).forEach(function (element) {
647
- var _a, _b;
648
- if (((element === null || element === void 0 ? void 0 : element.msgType) === 'USER' || (element === null || element === void 0 ? void 0 : element.msgType) === 'AGENT') && ((_b = (_a = element === null || element === void 0 ? void 0 : element.components[0]) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.text)) {
649
- handleUserAgentHistoryResponse(element);
650
- }
651
- });
652
- }, [userBotHistory, userAgentHistory, summary]);
653
- var processMessages = function (messages) {
654
- if (!(messages === null || messages === void 0 ? void 0 : messages.length)) {
655
- return [];
656
- }
657
- return messages.map(function (item) {
658
- var _a, _b, _c;
659
- try {
660
- if (typeof ((_b = (_a = item === null || item === void 0 ? void 0 : item.components[0]) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.text) === 'string') {
661
- var parsedText = JSON.parse(item.components[0].data.text);
662
- if ((_c = parsedText === null || parsedText === void 0 ? void 0 : parsedText.payload) === null || _c === void 0 ? void 0 : _c.text) {
663
- item.components[0].data.text = parsedText.payload.text;
664
- }
665
- }
666
- }
667
- catch (_d) {
668
- // Handle JSON parsing error if needed
669
- }
670
- return item;
671
- });
672
- };
673
- var fetchTranscriptHistoryData = function () {
674
- var isSummaryRequired = true;
675
- var _a = rootServiceInstance.connectionDetails || {}, botId = _a.botId, conversationId = _a.conversationId, channel = _a.channel, sessionId = _a.sessionId;
676
- var params = {
677
- conversationId: conversationId,
678
- botId: botId,
679
- channel: channel,
680
- sessionId: sessionId || 0,
681
- isSummaryRequired: isSummaryRequired,
682
- };
683
- return (0,_utils_interceptor__WEBPACK_IMPORTED_MODULE_5__["default"])('get_history_trascript', {
684
- method: 'GET',
685
- headers: {
686
- 'Content-Type': 'application/json',
687
- },
688
- }, hostInstance, params);
689
- };
690
- // userBot Converstion Transcript History
691
- var handleUserBotHistoryResponse = function (response) {
692
- var _a, _b;
693
- var data = {
694
- timestamp: formatStandardTime(response.createdOn),
695
- msg: (_b = (_a = response.components[0]) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.text,
696
- from: response.msgType === 'BOT' ? 'bot' : 'user',
697
- type: response.msgType === 'BOT' ? 'bot' : 'user'
698
- };
699
- var trnsptBubble = (0,_base_domManager__WEBPACK_IMPORTED_MODULE_3__.getHTML)(TranscriptBubble, data, hostInstance);
700
- var transcriptEle = document.getElementsByClassName(classMapConstansts.TRANSCRIPT_BODY_WRAPPER)[0];
701
- hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_4__.SDK_EVENTS.BEFORE_VIEW_INIT, trnsptBubble, {
702
- event: response.msgType === 'BOT' ? _constants_events_cnst__WEBPACK_IMPORTED_MODULE_4__.SDK_EVENTS.BOT_TRANSCRIPT : _constants_events_cnst__WEBPACK_IMPORTED_MODULE_4__.SDK_EVENTS.USER_TRANSCRIPT,
703
- data: data
704
- });
705
- transcriptEle.append(trnsptBubble);
706
- };
707
- // userAgent Conversation Transcript History
708
- var handleUserAgentHistoryResponse = function (response) {
709
- var _a, _b;
710
- var data = {
711
- timestamp: formatStandardTime(response.createdOn),
712
- msg: (_b = (_a = response.components[0]) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.text,
713
- from: response.msgType === 'AGENT' ? 'agent' : 'user',
714
- type: response.msgType === 'AGENT' ? 'agent' : 'user'
715
- };
716
- var trnsptBubble = (0,_base_domManager__WEBPACK_IMPORTED_MODULE_3__.getHTML)(TranscriptBubble, data, hostInstance);
717
- var transcriptEle = document.getElementsByClassName(classMapConstansts.TRANSCRIPT_BODY_WRAPPER)[0];
718
- hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_4__.SDK_EVENTS.BEFORE_VIEW_INIT, trnsptBubble, {
719
- event: response.msgType === 'AGENT' ? _constants_events_cnst__WEBPACK_IMPORTED_MODULE_4__.SDK_EVENTS.AGENT_TRANSCRIPT : _constants_events_cnst__WEBPACK_IMPORTED_MODULE_4__.SDK_EVENTS.USER_TRANSCRIPT,
720
- data: data
721
- });
722
- transcriptEle.append(trnsptBubble);
723
- };
724
- // conversion of standard UTC timestamp
725
- var formatStandardTime = function (timeStamp) {
726
- var date = new Date(timeStamp);
727
- var hours = date.getUTCHours();
728
- var minutes = date.getUTCMinutes();
729
- var ampm = hours >= 12 ? 'pm' : 'am';
730
- hours = hours % 12;
731
- hours = hours ? hours : 12;
732
- minutes = minutes < 10 ? '0' + minutes : minutes;
733
- return "".concat(hours, ":").concat(minutes, " ").concat(ampm);
734
- };
735
- // Live conversation of user and Agent Transcripts
736
- var handleTranscriptionResponse = function (response) {
737
- var _a, _b, _c;
738
- var type = (_b = (_a = response === null || response === void 0 ? void 0 : response.author) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.toLowerCase();
739
- var data = {
740
- timestamp: formatAmpm(new Date()),
741
- msg: response === null || response === void 0 ? void 0 : response.message,
742
- from: type,
743
- type: type
744
- };
745
- setMessages(__spreadArray(__spreadArray([], messages, true), [data], false));
746
- var trnsptBubble = (0,_base_domManager__WEBPACK_IMPORTED_MODULE_3__.getHTML)(TranscriptBubble, data, hostInstance);
747
- var transcriptEle = document.getElementsByClassName(classMapConstansts.TRANSCRIPT_BODY_WRAPPER)[0];
748
- hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_4__.SDK_EVENTS.BEFORE_VIEW_INIT, trnsptBubble, {
749
- event: ((_c = response === null || response === void 0 ? void 0 : response.author) === null || _c === void 0 ? void 0 : _c.type) === 'AGENT' ? _constants_events_cnst__WEBPACK_IMPORTED_MODULE_4__.SDK_EVENTS.AGENT_TRANSCRIPT : _constants_events_cnst__WEBPACK_IMPORTED_MODULE_4__.SDK_EVENTS.USER_TRANSCRIPT,
750
- data: data
751
- });
752
- transcriptEle.append(trnsptBubble);
753
- };
754
- // Live converstion timestamp conversion
755
- var formatAmpm = function (date) {
756
- var hours = date.getHours();
757
- var minutes = date.getMinutes();
758
- var ampm = hours >= 12 ? 'pm' : 'am';
759
- hours = hours % 12;
760
- hours = hours ? hours : 12;
761
- minutes = minutes < 10 ? '0' + minutes : minutes;
762
- var strTime = hours + ':' + minutes + ' ' + ampm;
763
- return strTime;
764
- };
765
- // Banner for the Agent Joining
766
- var addAgentJoiningBanner = function () {
767
- var timeStr = formatAmpm(new Date());
768
- var data = { title: 'Agent joined the conversation', timeStamp: timeStr };
769
- setAgentJoinedBanner(agentJoinedBanner);
770
- var agentJoinBanner = (0,_base_domManager__WEBPACK_IMPORTED_MODULE_3__.getHTML)(AgentJoiningEleBanner, data, hostInstance);
771
- var transcriptEle = document.getElementsByClassName(classMapConstansts.TRANSCRIPT_BODY_WRAPPER)[0];
772
- hostInstance.emit(_constants_events_cnst__WEBPACK_IMPORTED_MODULE_4__.SDK_EVENTS.BEFORE_VIEW_INIT, agentJoinBanner, {
773
- event: _constants_events_cnst__WEBPACK_IMPORTED_MODULE_4__.SDK_EVENTS.AGENT_JOINED_TEMPLATE,
774
- data: data
775
- });
776
- transcriptEle.append(agentJoinBanner);
777
- };
778
- // Agent joining banner HTML
779
- var AgentJoiningEleBanner = function (props) {
780
- var msgData = props.msgData;
781
- return ((0,preact__WEBPACK_IMPORTED_MODULE_0__.h)("div", { className: "agent-joined-banner" },
782
- (0,preact__WEBPACK_IMPORTED_MODULE_0__.h)("div", { className: "line-border" }),
783
- (0,preact__WEBPACK_IMPORTED_MODULE_0__.h)("div", { className: "info-joined-details" },
784
- (0,preact__WEBPACK_IMPORTED_MODULE_0__.h)("h4", { className: "aa-text-sm" }, msgData.title)),
785
- (0,preact__WEBPACK_IMPORTED_MODULE_0__.h)("div", { className: "line-border" })));
786
- };
787
- var SummaryEleBanner = function (props) {
788
- var msgData = props.msgData;
789
- return ((0,preact__WEBPACK_IMPORTED_MODULE_0__.h)("div", { className: "summary-wrapper" },
790
- (0,preact__WEBPACK_IMPORTED_MODULE_0__.h)("div", { className: "summary-header" },
791
- (0,preact__WEBPACK_IMPORTED_MODULE_0__.h)("i", { className: "krIocnsFont-Aimark" }),
792
- (0,preact__WEBPACK_IMPORTED_MODULE_0__.h)("span", { className: "aa-text-md medium" }, msgData.title)),
793
- (0,preact__WEBPACK_IMPORTED_MODULE_0__.h)("p", { className: "aa-text-sm" }, msgData.msg)));
794
- };
795
- var summaryBannerData = function (response) {
796
- var data = {
797
- title: 'Conversation Summary',
798
- msg: response === null || response === void 0 ? void 0 : response.message
799
- };
800
- setSummary(data);
801
- };
802
- // Message Bubbles for user agent
803
- var TranscriptBubble = function (props) {
804
- var msgData = props.msgData;
805
- return ((0,preact__WEBPACK_IMPORTED_MODULE_0__.h)("div", { className: msgData.type === 'user' ? 'aa-bot-bubble-comp' : 'aa-agent-bubble-comp' },
806
- (0,preact__WEBPACK_IMPORTED_MODULE_0__.h)("div", { className: msgData.type === 'user' ? 'bot-bubble-content' : 'agent-bubble-content' },
807
- (0,preact__WEBPACK_IMPORTED_MODULE_0__.h)("div", { className: "top-info" },
808
- msgData.type !== 'bot' && ((0,preact__WEBPACK_IMPORTED_MODULE_0__.h)("div", { className: "you-text" }, msgData.type === 'agent' ? 'agent' : 'user')),
809
- msgData.type === 'bot' && ((0,preact__WEBPACK_IMPORTED_MODULE_0__.h)("div", { className: "you-text" }, msgData.type === 'bot' ? 'bot' : 'user')),
810
- (0,preact__WEBPACK_IMPORTED_MODULE_0__.h)("div", { className: "time-tamp" },
811
- (0,preact__WEBPACK_IMPORTED_MODULE_0__.h)("time", null, msgData.timestamp))),
812
- (0,preact__WEBPACK_IMPORTED_MODULE_0__.h)("div", { className: "bubble-msg" }, msgData.msg))));
813
- };
814
- //scroll to bottom during message incoming
815
- (0,preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useEffect)(function () {
816
- var transcriptEle = document.querySelector('.aa-transcript-body-wrapper');
817
- transcriptEle.scrollTop = transcriptEle.scrollHeight;
818
- }, [messages]);
819
- return ((0,preact__WEBPACK_IMPORTED_MODULE_0__.h)(preact__WEBPACK_IMPORTED_MODULE_0__.Fragment, null,
820
- (0,preact__WEBPACK_IMPORTED_MODULE_0__.h)("div", { className: "transcript-template-wrapper" },
821
- (0,preact__WEBPACK_IMPORTED_MODULE_0__.h)("div", { className: "transcript-template-data" },
822
- (0,preact__WEBPACK_IMPORTED_MODULE_0__.h)("h1", { className: "transcript-header aa-text-md semibold" }, "Transcript"),
823
- (0,preact__WEBPACK_IMPORTED_MODULE_0__.h)("div", { className: "transcript-body-wrapper aa-transcript-body-wrapper" })))));
824
- }
825
-
826
-
827
112
  /***/ })
828
113
 
829
114
  },
830
115
  /******/ function(__webpack_require__) { // webpackRuntimeModules
831
116
  /******/ /* webpack/runtime/getFullHash */
832
117
  /******/ (() => {
833
- /******/ __webpack_require__.h = () => ("832dd9020678864a3e53")
118
+ /******/ __webpack_require__.h = () => ("8354751bf145e76961bf")
834
119
  /******/ })();
835
120
  /******/
836
121
  /******/ }