@app-connect/core 1.7.37 → 1.7.38
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.
- package/README.md +17 -16
- package/dist/connector/developerPortal.d.ts +6 -0
- package/{connector → dist/connector}/developerPortal.js +29 -12
- package/dist/connector/mock.d.ts +1 -0
- package/{connector → dist/connector}/mock.js +33 -17
- package/dist/connector/proxy/engine.d.ts +10 -0
- package/dist/connector/proxy/engine.js +222 -0
- package/dist/connector/proxy/index.d.ts +5 -0
- package/dist/connector/proxy/index.js +511 -0
- package/dist/connector/registry.d.ts +1 -0
- package/dist/connector/registry.js +243 -0
- package/dist/handlers/admin.d.ts +1 -0
- package/{handlers → dist/handlers}/admin.js +137 -78
- package/dist/handlers/appointment.d.ts +9 -0
- package/{handlers → dist/handlers}/appointment.js +58 -29
- package/dist/handlers/auth.d.ts +9 -0
- package/{handlers → dist/handlers}/auth.js +68 -40
- package/dist/handlers/calldown.d.ts +10 -0
- package/dist/handlers/calldown.js +134 -0
- package/dist/handlers/contact.d.ts +1 -0
- package/{handlers → dist/handlers}/contact.js +61 -39
- package/dist/handlers/disposition.d.ts +1 -0
- package/{handlers → dist/handlers}/disposition.js +20 -10
- package/dist/handlers/log.d.ts +1 -0
- package/{handlers → dist/handlers}/log.js +91 -124
- package/dist/handlers/managedAuth.d.ts +1 -0
- package/{handlers → dist/handlers}/managedAuth.js +134 -61
- package/dist/handlers/managedOAuth.d.ts +13 -0
- package/{handlers → dist/handlers}/managedOAuth.js +102 -30
- package/dist/handlers/plugin.d.ts +1 -0
- package/{handlers → dist/handlers}/plugin.js +59 -27
- package/dist/handlers/user.d.ts +1 -0
- package/{handlers → dist/handlers}/user.js +45 -27
- package/dist/index.d.ts +1 -0
- package/{index.js → dist/index.js} +538 -449
- package/dist/jest.config.d.ts +1 -0
- package/dist/jest.config.js +65 -0
- package/dist/lib/analytics.d.ts +4 -0
- package/{lib → dist/lib}/analytics.js +8 -6
- package/dist/lib/authSession.d.ts +5 -0
- package/{lib → dist/lib}/authSession.js +15 -43
- package/dist/lib/cacheCleanup.d.ts +4 -0
- package/{lib → dist/lib}/cacheCleanup.js +5 -17
- package/dist/lib/callLogComposer.d.ts +109 -0
- package/{lib → dist/lib}/callLogComposer.js +157 -197
- package/dist/lib/callLogLookup.d.ts +6 -0
- package/{lib → dist/lib}/callLogLookup.js +12 -34
- package/dist/lib/constants.d.ts +6 -0
- package/dist/lib/constants.js +9 -0
- package/dist/lib/debugTracer.d.ts +17 -0
- package/{lib → dist/lib}/debugTracer.js +7 -83
- package/dist/lib/encode.d.ts +3 -0
- package/dist/lib/encode.js +50 -0
- package/dist/lib/errorHandler.d.ts +7 -0
- package/dist/lib/errorHandler.js +161 -0
- package/dist/lib/generalErrorMessage.d.ts +7 -0
- package/{lib → dist/lib}/generalErrorMessage.js +6 -6
- package/dist/lib/jwt.d.ts +4 -0
- package/dist/lib/jwt.js +18 -0
- package/dist/lib/logger.d.ts +24 -0
- package/dist/lib/logger.js +126 -0
- package/dist/lib/migrateCallLogsSchema.d.ts +32 -0
- package/{lib → dist/lib}/migrateCallLogsSchema.js +75 -160
- package/dist/lib/oauth.d.ts +4 -0
- package/{lib → dist/lib}/oauth.js +157 -160
- package/dist/lib/ringcentral.d.ts +24 -0
- package/dist/lib/ringcentral.js +226 -0
- package/dist/lib/s3ErrorLogReport.d.ts +4 -0
- package/{lib → dist/lib}/s3ErrorLogReport.js +11 -23
- package/dist/lib/sharedSMSComposer.d.ts +7 -0
- package/{lib → dist/lib}/sharedSMSComposer.js +21 -107
- package/dist/lib/util.d.ts +7 -0
- package/{lib → dist/lib}/util.js +9 -20
- package/dist/mcp/lib/oauthError.d.ts +1 -0
- package/dist/mcp/lib/oauthError.js +25 -0
- package/dist/mcp/lib/validator.d.ts +1 -0
- package/{mcp → dist/mcp}/lib/validator.js +16 -20
- package/dist/mcp/lib/widgetSessionToken.d.ts +1 -0
- package/dist/mcp/lib/widgetSessionToken.js +46 -0
- package/dist/mcp/mcpHandler.d.ts +8 -0
- package/{mcp → dist/mcp}/mcpHandler.js +98 -88
- package/dist/mcp/tools/cancelAppointment.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/cancelAppointment.js +7 -16
- package/dist/mcp/tools/checkAuthStatus.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/checkAuthStatus.js +21 -14
- package/dist/mcp/tools/confirmAppointment.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/confirmAppointment.js +7 -16
- package/dist/mcp/tools/createAppointment.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/createAppointment.js +7 -19
- package/dist/mcp/tools/createCallLog.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/createCallLog.js +18 -29
- package/dist/mcp/tools/createContact.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/createContact.js +8 -20
- package/dist/mcp/tools/createMessageLog.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/createMessageLog.js +14 -26
- package/dist/mcp/tools/doAuth.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/doAuth.js +17 -13
- package/dist/mcp/tools/findContactByName.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/findContactByName.js +9 -15
- package/dist/mcp/tools/findContactByPhone.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/findContactByPhone.js +8 -15
- package/dist/mcp/tools/getCallLog.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/getCallLog.js +12 -21
- package/dist/mcp/tools/getGoogleFilePicker.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/getGoogleFilePicker.js +9 -18
- package/dist/mcp/tools/getHelp.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/getHelp.js +5 -6
- package/dist/mcp/tools/getPublicConnectors.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/getPublicConnectors.js +19 -18
- package/dist/mcp/tools/getSessionInfo.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/getSessionInfo.js +10 -16
- package/dist/mcp/tools/index.d.ts +8 -0
- package/dist/mcp/tools/index.js +50 -0
- package/dist/mcp/tools/listAppointments.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/listAppointments.js +7 -19
- package/dist/mcp/tools/logout.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/logout.js +16 -14
- package/dist/mcp/tools/rcGetCallLogs.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/rcGetCallLogs.js +10 -8
- package/dist/mcp/tools/updateAppointment.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/updateAppointment.js +17 -22
- package/dist/mcp/tools/updateCallLog.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/updateCallLog.js +16 -26
- package/dist/models/accountDataModel.d.ts +3 -0
- package/dist/models/accountDataModel.js +39 -0
- package/dist/models/adminConfigModel.d.ts +2 -0
- package/dist/models/adminConfigModel.js +39 -0
- package/dist/models/cacheModel.d.ts +2 -0
- package/{models → dist/models}/cacheModel.js +7 -3
- package/dist/models/callDownListModel.d.ts +2 -0
- package/{models → dist/models}/callDownListModel.js +8 -4
- package/dist/models/callLogModel.d.ts +2 -0
- package/dist/models/callLogModel.js +43 -0
- package/dist/models/dynamo/connectorSchema.d.ts +2 -0
- package/dist/models/dynamo/connectorSchema.js +141 -0
- package/dist/models/dynamo/lockSchema.d.ts +2 -0
- package/{models → dist/models}/dynamo/lockSchema.js +5 -7
- package/dist/models/dynamo/noteCacheSchema.d.ts +2 -0
- package/{models → dist/models}/dynamo/noteCacheSchema.js +4 -6
- package/dist/models/llmSessionModel.d.ts +2 -0
- package/dist/models/llmSessionModel.js +21 -0
- package/dist/models/messageLogModel.d.ts +2 -0
- package/{models → dist/models}/messageLogModel.js +8 -4
- package/dist/models/sequelize.d.ts +2 -0
- package/dist/models/sequelize.js +68 -0
- package/dist/models/userModel.d.ts +2 -0
- package/dist/models/userModel.js +49 -0
- package/dist/package.json +100 -0
- package/dist/releaseNotes.json +1222 -0
- package/dist/tsconfig.json +14 -0
- package/dist/types/admin.d.ts +141 -0
- package/dist/types/analytics.d.ts +14 -0
- package/dist/types/appointment.d.ts +50 -0
- package/dist/types/auth.d.ts +137 -0
- package/dist/types/authSession.d.ts +35 -0
- package/dist/types/cacheCleanup.d.ts +12 -0
- package/dist/types/calldown.d.ts +54 -0
- package/dist/types/common.d.ts +46 -0
- package/dist/types/connector.d.ts +165 -0
- package/dist/types/contact.d.ts +125 -0
- package/dist/types/errorHandler.d.ts +60 -0
- package/dist/types/index.d.ts +76 -0
- package/dist/types/json.d.ts +9 -0
- package/dist/types/jwt.d.ts +8 -0
- package/dist/types/logging.d.ts +224 -0
- package/dist/types/managedAuth.d.ts +114 -0
- package/dist/types/managedOAuth.d.ts +59 -0
- package/dist/types/manifest.d.ts +120 -0
- package/dist/types/migration.d.ts +15 -0
- package/dist/types/plugin.d.ts +74 -0
- package/dist/types/ringcentral.d.ts +61 -0
- package/dist/types/s3ErrorLogReport.d.ts +16 -0
- package/dist/types/sharedSMSComposer.d.ts +105 -0
- package/dist/types/user.d.ts +46 -0
- package/dist/types/util.d.ts +7 -0
- package/package.json +34 -6
- package/releaseNotes.json +8 -0
- package/.env.test +0 -5
- package/connector/proxy/engine.js +0 -165
- package/connector/proxy/index.js +0 -500
- package/connector/registry.js +0 -252
- package/docs/README.md +0 -50
- package/docs/architecture.md +0 -94
- package/docs/connectors.md +0 -116
- package/docs/handlers.md +0 -128
- package/docs/libraries.md +0 -98
- package/docs/models.md +0 -146
- package/docs/routes.md +0 -119
- package/docs/tests.md +0 -73
- package/handlers/calldown.js +0 -99
- package/jest.config.js +0 -57
- package/lib/constants.js +0 -9
- package/lib/encode.js +0 -30
- package/lib/errorHandler.js +0 -218
- package/lib/jwt.js +0 -18
- package/lib/logger.js +0 -190
- package/lib/ringcentral.js +0 -267
- package/mcp/README.md +0 -420
- package/mcp/tools/index.js +0 -51
- package/mcp/ui/App/App.tsx +0 -358
- package/mcp/ui/App/components/AuthInfoForm.tsx +0 -113
- package/mcp/ui/App/components/AuthSuccess.tsx +0 -22
- package/mcp/ui/App/components/ConnectorList.tsx +0 -82
- package/mcp/ui/App/components/DebugPanel.tsx +0 -43
- package/mcp/ui/App/components/OAuthConnect.tsx +0 -270
- package/mcp/ui/App/lib/callTool.ts +0 -130
- package/mcp/ui/App/lib/debugLog.ts +0 -41
- package/mcp/ui/App/lib/developerPortal.ts +0 -111
- package/mcp/ui/App/main.css +0 -6
- package/mcp/ui/App/root.tsx +0 -13
- package/mcp/ui/dist/index.html +0 -53
- package/mcp/ui/vite.config.ts +0 -16
- package/models/accountDataModel.js +0 -34
- package/models/adminConfigModel.js +0 -35
- package/models/callLogModel.js +0 -39
- package/models/dynamo/connectorSchema.js +0 -146
- package/models/llmSessionModel.js +0 -17
- package/models/sequelize.js +0 -17
- package/models/userModel.js +0 -45
- package/test/connector/developerPortal.test.js +0 -166
- package/test/connector/mock.test.js +0 -131
- package/test/connector/proxy/engine.test.js +0 -211
- package/test/connector/proxy/index.test.js +0 -525
- package/test/connector/proxy/sample.json +0 -162
- package/test/connector/registry.test.js +0 -416
- package/test/handlers/admin.test.js +0 -960
- package/test/handlers/appointment.test.js +0 -260
- package/test/handlers/auth.test.js +0 -1096
- package/test/handlers/calldown.test.js +0 -310
- package/test/handlers/contact.test.js +0 -1014
- package/test/handlers/disposition.test.js +0 -396
- package/test/handlers/log.test.js +0 -1847
- package/test/handlers/managedAuth.test.js +0 -458
- package/test/handlers/managedOAuth.test.js +0 -262
- package/test/handlers/plugin.test.js +0 -429
- package/test/handlers/user.test.js +0 -381
- package/test/index.test.js +0 -301
- package/test/lib/analytics.test.js +0 -146
- package/test/lib/authSession.test.js +0 -173
- package/test/lib/cacheCleanup.test.js +0 -127
- package/test/lib/callLogComposer.test.js +0 -1231
- package/test/lib/debugTracer.test.js +0 -328
- package/test/lib/encode.test.js +0 -59
- package/test/lib/errorHandler.test.js +0 -246
- package/test/lib/generalErrorMessage.test.js +0 -82
- package/test/lib/jwt.test.js +0 -176
- package/test/lib/logger.test.js +0 -206
- package/test/lib/oauth.test.js +0 -359
- package/test/lib/ringcentral.test.js +0 -467
- package/test/lib/s3ErrorLogReport.test.js +0 -187
- package/test/lib/sharedSMSComposer.test.js +0 -1084
- package/test/lib/util.test.js +0 -329
- package/test/mcp/mcpHandler.test.js +0 -73
- package/test/mcp/mcpHandlerMore.test.js +0 -384
- package/test/mcp/tools/appointmentTools.test.js +0 -362
- package/test/mcp/tools/checkAuthStatus.test.js +0 -83
- package/test/mcp/tools/createCallLog.test.js +0 -436
- package/test/mcp/tools/createContact.test.js +0 -58
- package/test/mcp/tools/createMessageLog.test.js +0 -595
- package/test/mcp/tools/doAuth.test.js +0 -113
- package/test/mcp/tools/findContactByName.test.js +0 -275
- package/test/mcp/tools/findContactByPhone.test.js +0 -296
- package/test/mcp/tools/getCallLog.test.js +0 -298
- package/test/mcp/tools/getGoogleFilePicker.test.js +0 -281
- package/test/mcp/tools/getPublicConnectors.test.js +0 -107
- package/test/mcp/tools/getSessionInfo.test.js +0 -127
- package/test/mcp/tools/logout.test.js +0 -233
- package/test/mcp/tools/rcGetCallLogs.test.js +0 -56
- package/test/mcp/tools/updateCallLog.test.js +0 -360
- package/test/models/accountDataModel.test.js +0 -98
- package/test/models/callDownListModel.test.js +0 -125
- package/test/models/dynamo/connectorSchema.test.js +0 -189
- package/test/models/dynamo/lockSchema.test.js +0 -37
- package/test/models/dynamo/noteCacheSchema.test.js +0 -45
- package/test/models/llmSessionModel.test.js +0 -91
- package/test/models/models.test.js +0 -660
- package/test/routes/calldownRoutes.test.js +0 -224
- package/test/routes/coreRouterBroadRoutes.test.js +0 -855
- package/test/routes/dispositionRoutes.test.js +0 -192
- package/test/routes/managedAuthRoutes.test.js +0 -386
- package/test/routes/pluginRoutes.test.js +0 -262
- package/test/setup.js +0 -178
- /package/{mcp → dist/mcp}/ui/index.html +0 -0
- /package/{mcp → dist/mcp}/ui/package-lock.json +0 -0
- /package/{mcp → dist/mcp}/ui/package.json +0 -0
- /package/{mcp → dist/mcp}/ui/tsconfig.json +0 -0
|
@@ -1,56 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.composeCallLog = composeCallLog;
|
|
4
|
+
exports.upsertCallAgentNote = upsertCallAgentNote;
|
|
5
|
+
exports.upsertCallSessionId = upsertCallSessionId;
|
|
6
|
+
exports.upsertRingCentralUserName = upsertRingCentralUserName;
|
|
7
|
+
exports.upsertRingCentralNumberAndExtension = upsertRingCentralNumberAndExtension;
|
|
8
|
+
exports.upsertCallSubject = upsertCallSubject;
|
|
9
|
+
exports.upsertContactPhoneNumber = upsertContactPhoneNumber;
|
|
10
|
+
exports.upsertCallDateTime = upsertCallDateTime;
|
|
11
|
+
exports.upsertCallDuration = upsertCallDuration;
|
|
12
|
+
exports.upsertCallResult = upsertCallResult;
|
|
13
|
+
exports.upsertCallRecording = upsertCallRecording;
|
|
14
|
+
exports.upsertAiNote = upsertAiNote;
|
|
15
|
+
exports.upsertTranscript = upsertTranscript;
|
|
16
|
+
exports.upsertLegs = upsertLegs;
|
|
17
|
+
exports.upsertRingSenseTranscript = upsertRingSenseTranscript;
|
|
18
|
+
exports.upsertRingSenseSummary = upsertRingSenseSummary;
|
|
19
|
+
exports.upsertRingSenseAIScore = upsertRingSenseAIScore;
|
|
20
|
+
exports.upsertRingSenseBulletedSummary = upsertRingSenseBulletedSummary;
|
|
21
|
+
exports.upsertRingSenseLink = upsertRingSenseLink;
|
|
1
22
|
const moment = require('moment-timezone');
|
|
2
23
|
const { secondsToHoursMinutesSeconds } = require('./util');
|
|
3
24
|
const connectorRegistry = require('../connector/registry');
|
|
4
25
|
const { LOG_DETAILS_FORMAT_TYPE } = require('./constants');
|
|
5
|
-
|
|
6
26
|
/**
|
|
7
27
|
* Centralized call log composition module
|
|
8
28
|
* Supports both plain text and HTML formats used across different CRM connectors
|
|
9
29
|
*/
|
|
10
|
-
|
|
11
30
|
/**
|
|
12
31
|
* Compose call log details based on user settings and format type
|
|
13
|
-
* @param {
|
|
14
|
-
* @
|
|
15
|
-
* @param {string} params.existingBody - Existing log body (for updates)
|
|
16
|
-
* @param {Object} params.callLog - Call log information
|
|
17
|
-
* @param {Object} params.contactInfo - Contact information
|
|
18
|
-
* @param {Object} params.user - User information
|
|
19
|
-
* @param {string} params.note - User note
|
|
20
|
-
* @param {string} params.aiNote - AI generated note
|
|
21
|
-
* @param {string} params.transcript - Call transcript
|
|
22
|
-
* @param {string} params.recordingLink - Recording link
|
|
23
|
-
* @param {string} params.subject - Call subject
|
|
24
|
-
* @param {Date} params.startTime - Call start time
|
|
25
|
-
* @param {number} params.duration - Call duration in seconds
|
|
26
|
-
* @param {string} params.result - Call result
|
|
27
|
-
* @returns {Promise<string>} Composed log body
|
|
32
|
+
* @param {ComposeCallLogParams} params - Composition parameters
|
|
33
|
+
* @returns {string} Composed log body
|
|
28
34
|
*/
|
|
29
35
|
function composeCallLog(params) {
|
|
30
|
-
const {
|
|
31
|
-
logFormat = LOG_DETAILS_FORMAT_TYPE.PLAIN_TEXT,
|
|
32
|
-
existingBody = '',
|
|
33
|
-
callLog,
|
|
34
|
-
contactInfo,
|
|
35
|
-
user,
|
|
36
|
-
note,
|
|
37
|
-
aiNote,
|
|
38
|
-
transcript,
|
|
39
|
-
recordingLink,
|
|
40
|
-
subject,
|
|
41
|
-
startTime,
|
|
42
|
-
duration,
|
|
43
|
-
result,
|
|
44
|
-
ringSenseTranscript,
|
|
45
|
-
ringSenseSummary,
|
|
46
|
-
ringSenseAIScore,
|
|
47
|
-
ringSenseBulletedSummary,
|
|
48
|
-
ringSenseLink
|
|
49
|
-
} = params;
|
|
50
|
-
|
|
36
|
+
const { logFormat = LOG_DETAILS_FORMAT_TYPE.PLAIN_TEXT, existingBody = '', callLog, contactInfo, user, note, aiNote, transcript, recordingLink, subject, startTime, duration, result, ringSenseTranscript, ringSenseSummary, ringSenseAIScore, ringSenseBulletedSummary, ringSenseLink } = params;
|
|
51
37
|
let body = existingBody;
|
|
52
38
|
const userSettings = user.userSettings || {};
|
|
53
39
|
// Determine timezone handling
|
|
40
|
+
/** @type {any} */
|
|
54
41
|
let resolvedStartTime = startTime || callLog?.startTime;
|
|
55
42
|
let timezoneOffset = user.timezoneOffset;
|
|
56
43
|
if (resolvedStartTime) {
|
|
@@ -60,18 +47,15 @@ function composeCallLog(params) {
|
|
|
60
47
|
if (note && (userSettings?.addCallLogNote?.value ?? true)) {
|
|
61
48
|
body = upsertCallAgentNote({ body, note, logFormat });
|
|
62
49
|
}
|
|
63
|
-
|
|
64
50
|
if (callLog?.sessionId && (userSettings?.addCallSessionId?.value ?? false)) {
|
|
65
51
|
body = upsertCallSessionId({ body, id: callLog.sessionId, logFormat });
|
|
66
52
|
}
|
|
67
|
-
|
|
68
53
|
if (userSettings?.addRingCentralUserName?.value) {
|
|
69
54
|
const ringcentralUsername = (callLog.direction === 'Inbound' ? callLog?.to?.name : callLog?.from?.name) ?? null;
|
|
70
55
|
if (ringcentralUsername) {
|
|
71
56
|
body = upsertRingCentralUserName({ body, userName: ringcentralUsername, logFormat });
|
|
72
57
|
}
|
|
73
58
|
}
|
|
74
|
-
|
|
75
59
|
if (userSettings?.addRingCentralNumber?.value ?? false) {
|
|
76
60
|
const ringcentralNumber = callLog.direction === 'Inbound' ? callLog?.to?.phoneNumber : callLog?.from?.phoneNumber;
|
|
77
61
|
if (ringcentralNumber) {
|
|
@@ -79,11 +63,9 @@ function composeCallLog(params) {
|
|
|
79
63
|
body = upsertRingCentralNumberAndExtension({ body, number: ringcentralNumber, extension: ringcentralExtensionNumber ?? '', logFormat });
|
|
80
64
|
}
|
|
81
65
|
}
|
|
82
|
-
|
|
83
66
|
if (subject && (userSettings?.addCallLogSubject?.value ?? true)) {
|
|
84
67
|
body = upsertCallSubject({ body, subject, logFormat });
|
|
85
68
|
}
|
|
86
|
-
|
|
87
69
|
if (contactInfo?.phoneNumber && (userSettings?.addCallLogContactNumber?.value ?? false)) {
|
|
88
70
|
body = upsertContactPhoneNumber({
|
|
89
71
|
body,
|
|
@@ -92,7 +74,6 @@ function composeCallLog(params) {
|
|
|
92
74
|
logFormat
|
|
93
75
|
});
|
|
94
76
|
}
|
|
95
|
-
|
|
96
77
|
if (resolvedStartTime && (userSettings?.addCallLogDateTime?.value ?? true)) {
|
|
97
78
|
body = upsertCallDateTime({
|
|
98
79
|
body,
|
|
@@ -102,61 +83,47 @@ function composeCallLog(params) {
|
|
|
102
83
|
logFormat
|
|
103
84
|
});
|
|
104
85
|
}
|
|
105
|
-
|
|
106
86
|
if (typeof duration !== 'undefined' && (userSettings?.addCallLogDuration?.value ?? true)) {
|
|
107
87
|
body = upsertCallDuration({ body, duration, logFormat });
|
|
108
88
|
}
|
|
109
|
-
|
|
110
89
|
if (result && (userSettings?.addCallLogResult?.value ?? true)) {
|
|
111
90
|
body = upsertCallResult({ body, result, logFormat });
|
|
112
91
|
}
|
|
113
|
-
|
|
114
92
|
if (recordingLink && (userSettings?.addCallLogRecording?.value ?? true)) {
|
|
115
93
|
body = upsertCallRecording({ body, recordingLink, logFormat });
|
|
116
94
|
}
|
|
117
|
-
|
|
118
95
|
if (aiNote && (userSettings?.addCallLogAiNote?.value ?? true)) {
|
|
119
96
|
body = upsertAiNote({ body, aiNote, logFormat });
|
|
120
97
|
}
|
|
121
|
-
|
|
122
98
|
if (transcript && (userSettings?.addCallLogTranscript?.value ?? true)) {
|
|
123
99
|
body = upsertTranscript({ body, transcript, logFormat });
|
|
124
100
|
}
|
|
125
|
-
|
|
126
101
|
if (ringSenseTranscript && (userSettings?.addCallLogRingSenseRecordingTranscript?.value ?? true)) {
|
|
127
102
|
body = upsertRingSenseTranscript({ body, transcript: ringSenseTranscript, logFormat });
|
|
128
103
|
}
|
|
129
|
-
|
|
130
104
|
if (ringSenseSummary && (userSettings?.addCallLogRingSenseRecordingSummary?.value ?? true)) {
|
|
131
105
|
body = upsertRingSenseSummary({ body, summary: ringSenseSummary, logFormat });
|
|
132
106
|
}
|
|
133
|
-
|
|
134
107
|
if (ringSenseAIScore && (userSettings?.addCallLogRingSenseRecordingAIScore?.value ?? true)) {
|
|
135
108
|
body = upsertRingSenseAIScore({ body, score: ringSenseAIScore, logFormat });
|
|
136
109
|
}
|
|
137
|
-
|
|
138
110
|
if (ringSenseBulletedSummary && (userSettings?.addCallLogRingSenseRecordingBulletedSummary?.value ?? true)) {
|
|
139
111
|
body = upsertRingSenseBulletedSummary({ body, summary: ringSenseBulletedSummary, logFormat });
|
|
140
112
|
}
|
|
141
|
-
|
|
142
113
|
if (ringSenseLink && (userSettings?.addCallLogRingSenseRecordingLink?.value ?? true)) {
|
|
143
114
|
body = upsertRingSenseLink({ body, link: ringSenseLink, logFormat });
|
|
144
115
|
}
|
|
145
|
-
|
|
146
116
|
if (callLog?.legs && (userSettings?.addCallLogLegs?.value ?? true)) {
|
|
147
117
|
body = upsertLegs({ body, legs: callLog.legs, logFormat });
|
|
148
118
|
}
|
|
149
|
-
|
|
150
119
|
return body;
|
|
151
120
|
}
|
|
152
|
-
|
|
153
121
|
/**
|
|
154
122
|
* Upsert functions for different log components
|
|
155
123
|
*/
|
|
156
|
-
|
|
157
124
|
function upsertCallAgentNote({ body, note, logFormat }) {
|
|
158
|
-
if (!note)
|
|
159
|
-
|
|
125
|
+
if (!note)
|
|
126
|
+
return body;
|
|
160
127
|
let noteRegex = null;
|
|
161
128
|
switch (logFormat) {
|
|
162
129
|
case LOG_DETAILS_FORMAT_TYPE.HTML:
|
|
@@ -185,10 +152,9 @@ function upsertCallAgentNote({ body, note, logFormat }) {
|
|
|
185
152
|
return `- Note: ${note}\n` + body;
|
|
186
153
|
}
|
|
187
154
|
}
|
|
188
|
-
|
|
189
155
|
function upsertCallSessionId({ body, id, logFormat }) {
|
|
190
|
-
if (!id)
|
|
191
|
-
|
|
156
|
+
if (!id)
|
|
157
|
+
return body;
|
|
192
158
|
let idRegex = null;
|
|
193
159
|
switch (logFormat) {
|
|
194
160
|
case LOG_DETAILS_FORMAT_TYPE.HTML:
|
|
@@ -214,10 +180,9 @@ function upsertCallSessionId({ body, id, logFormat }) {
|
|
|
214
180
|
return body + `- Session Id: ${id}\n`;
|
|
215
181
|
}
|
|
216
182
|
}
|
|
217
|
-
|
|
218
183
|
function upsertRingCentralUserName({ body, userName, logFormat }) {
|
|
219
|
-
if (!userName)
|
|
220
|
-
|
|
184
|
+
if (!userName)
|
|
185
|
+
return body;
|
|
221
186
|
let userNameRegex = null;
|
|
222
187
|
let match = null;
|
|
223
188
|
switch (logFormat) {
|
|
@@ -230,7 +195,8 @@ function upsertRingCentralUserName({ body, userName, logFormat }) {
|
|
|
230
195
|
return body.replace(userNameRegex, `<li><b>RingCentral user name</b>: ${userName}</li>`);
|
|
231
196
|
}
|
|
232
197
|
return body;
|
|
233
|
-
}
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
234
200
|
return body + `<li><b>RingCentral user name</b>: ${userName}</li>`;
|
|
235
201
|
}
|
|
236
202
|
case LOG_DETAILS_FORMAT_TYPE.MARKDOWN:
|
|
@@ -242,7 +208,8 @@ function upsertRingCentralUserName({ body, userName, logFormat }) {
|
|
|
242
208
|
return body.replace(userNameRegex, `**RingCentral user name**: ${userName}\n`);
|
|
243
209
|
}
|
|
244
210
|
return body;
|
|
245
|
-
}
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
246
213
|
return body + `**RingCentral user name**: ${userName}\n`;
|
|
247
214
|
}
|
|
248
215
|
case LOG_DETAILS_FORMAT_TYPE.PLAIN_TEXT:
|
|
@@ -254,15 +221,15 @@ function upsertRingCentralUserName({ body, userName, logFormat }) {
|
|
|
254
221
|
return body.replace(userNameRegex, `- RingCentral user name: ${userName}\n`);
|
|
255
222
|
}
|
|
256
223
|
return body;
|
|
257
|
-
}
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
258
226
|
return body + `- RingCentral user name: ${userName}\n`;
|
|
259
227
|
}
|
|
260
228
|
}
|
|
261
229
|
}
|
|
262
|
-
|
|
263
230
|
function upsertRingCentralNumberAndExtension({ body, number, extension, logFormat }) {
|
|
264
|
-
if (!number && !extension)
|
|
265
|
-
|
|
231
|
+
if (!number && !extension)
|
|
232
|
+
return body;
|
|
266
233
|
let numberAndExtensionRegex = null;
|
|
267
234
|
switch (logFormat) {
|
|
268
235
|
case LOG_DETAILS_FORMAT_TYPE.HTML:
|
|
@@ -285,10 +252,9 @@ function upsertRingCentralNumberAndExtension({ body, number, extension, logForma
|
|
|
285
252
|
return body + `- RingCentral number and extension: ${number} ${extension}\n`;
|
|
286
253
|
}
|
|
287
254
|
}
|
|
288
|
-
|
|
289
255
|
function upsertCallSubject({ body, subject, logFormat }) {
|
|
290
|
-
if (!subject)
|
|
291
|
-
|
|
256
|
+
if (!subject)
|
|
257
|
+
return body;
|
|
292
258
|
let subjectRegex = null;
|
|
293
259
|
switch (logFormat) {
|
|
294
260
|
case LOG_DETAILS_FORMAT_TYPE.HTML:
|
|
@@ -314,13 +280,11 @@ function upsertCallSubject({ body, subject, logFormat }) {
|
|
|
314
280
|
return body + `- Summary: ${subject}\n`;
|
|
315
281
|
}
|
|
316
282
|
}
|
|
317
|
-
|
|
318
283
|
function upsertContactPhoneNumber({ body, phoneNumber, direction, logFormat }) {
|
|
319
|
-
if (!phoneNumber)
|
|
320
|
-
|
|
284
|
+
if (!phoneNumber)
|
|
285
|
+
return body;
|
|
321
286
|
const label = direction === 'Outbound' ? 'Recipient' : 'Caller';
|
|
322
287
|
let result = body;
|
|
323
|
-
|
|
324
288
|
let phoneNumberRegex = null;
|
|
325
289
|
switch (logFormat) {
|
|
326
290
|
case LOG_DETAILS_FORMAT_TYPE.HTML:
|
|
@@ -328,7 +292,8 @@ function upsertContactPhoneNumber({ body, phoneNumber, direction, logFormat }) {
|
|
|
328
292
|
phoneNumberRegex = new RegExp(`(?:<li>)?<b>${label} phone number</b>:\\s*([^<\\n]+)(?:</li>|(?=<|$))`, 'i');
|
|
329
293
|
if (phoneNumberRegex.test(result)) {
|
|
330
294
|
result = result.replace(phoneNumberRegex, `<li><b>${label} phone number</b>: ${phoneNumber}</li>`);
|
|
331
|
-
}
|
|
295
|
+
}
|
|
296
|
+
else {
|
|
332
297
|
result += `<li><b>${label} phone number</b>: ${phoneNumber}</li>`;
|
|
333
298
|
}
|
|
334
299
|
break;
|
|
@@ -337,7 +302,8 @@ function upsertContactPhoneNumber({ body, phoneNumber, direction, logFormat }) {
|
|
|
337
302
|
phoneNumberRegex = /\*\*Contact Number\*\*: [^\n]*\n*/;
|
|
338
303
|
if (phoneNumberRegex.test(result)) {
|
|
339
304
|
result = result.replace(phoneNumberRegex, `**Contact Number**: ${phoneNumber}\n`);
|
|
340
|
-
}
|
|
305
|
+
}
|
|
306
|
+
else {
|
|
341
307
|
result += `**Contact Number**: ${phoneNumber}\n`;
|
|
342
308
|
}
|
|
343
309
|
break;
|
|
@@ -346,17 +312,17 @@ function upsertContactPhoneNumber({ body, phoneNumber, direction, logFormat }) {
|
|
|
346
312
|
phoneNumberRegex = /- Contact Number: ([^\n-]+)(?=\n-|\n|$)/;
|
|
347
313
|
if (phoneNumberRegex.test(result)) {
|
|
348
314
|
result = result.replace(phoneNumberRegex, `- Contact Number: ${phoneNumber}\n`);
|
|
349
|
-
}
|
|
315
|
+
}
|
|
316
|
+
else {
|
|
350
317
|
result += `- Contact Number: ${phoneNumber}\n`;
|
|
351
318
|
}
|
|
352
319
|
break;
|
|
353
320
|
}
|
|
354
321
|
return result;
|
|
355
322
|
}
|
|
356
|
-
|
|
357
323
|
function upsertCallDateTime({ body, startTime, timezoneOffset, logFormat, logDateFormat }) {
|
|
358
|
-
if (!startTime)
|
|
359
|
-
|
|
324
|
+
if (!startTime)
|
|
325
|
+
return body;
|
|
360
326
|
// Simple approach: convert to moment and apply timezone offset
|
|
361
327
|
let momentTime = moment(startTime);
|
|
362
328
|
if (timezoneOffset) {
|
|
@@ -364,14 +330,14 @@ function upsertCallDateTime({ body, startTime, timezoneOffset, logFormat, logDat
|
|
|
364
330
|
if (typeof timezoneOffset === 'string' && timezoneOffset.includes(':')) {
|
|
365
331
|
// String logFormat like '+05:30' or '-05:00'
|
|
366
332
|
momentTime = momentTime.utcOffset(timezoneOffset);
|
|
367
|
-
}
|
|
333
|
+
}
|
|
334
|
+
else {
|
|
368
335
|
// Numeric logFormat (minutes or hours)
|
|
369
336
|
momentTime = momentTime.utcOffset(Number(timezoneOffset));
|
|
370
337
|
}
|
|
371
338
|
}
|
|
372
339
|
const formattedDateTime = momentTime.format(logDateFormat || 'YYYY-MM-DD hh:mm:ss A');
|
|
373
340
|
let result = body;
|
|
374
|
-
|
|
375
341
|
let dateTimeRegex = null;
|
|
376
342
|
switch (logFormat) {
|
|
377
343
|
case LOG_DETAILS_FORMAT_TYPE.HTML:
|
|
@@ -379,7 +345,8 @@ function upsertCallDateTime({ body, startTime, timezoneOffset, logFormat, logDat
|
|
|
379
345
|
dateTimeRegex = /(?:<li>)?<b>Date\/time<\/b>:\s*([^<\n]+)(?:<\/li>|(?=<|$))/i;
|
|
380
346
|
if (dateTimeRegex.test(result)) {
|
|
381
347
|
result = result.replace(dateTimeRegex, `<li><b>Date/time</b>: ${formattedDateTime}</li>`);
|
|
382
|
-
}
|
|
348
|
+
}
|
|
349
|
+
else {
|
|
383
350
|
result += `<li><b>Date/time</b>: ${formattedDateTime}</li>`;
|
|
384
351
|
}
|
|
385
352
|
break;
|
|
@@ -388,7 +355,8 @@ function upsertCallDateTime({ body, startTime, timezoneOffset, logFormat, logDat
|
|
|
388
355
|
dateTimeRegex = /\*\*Date\/Time\*\*: [^\n]*\n*/;
|
|
389
356
|
if (dateTimeRegex.test(result)) {
|
|
390
357
|
result = result.replace(dateTimeRegex, `**Date/Time**: ${formattedDateTime}\n`);
|
|
391
|
-
}
|
|
358
|
+
}
|
|
359
|
+
else {
|
|
392
360
|
result += `**Date/Time**: ${formattedDateTime}\n`;
|
|
393
361
|
}
|
|
394
362
|
break;
|
|
@@ -397,17 +365,17 @@ function upsertCallDateTime({ body, startTime, timezoneOffset, logFormat, logDat
|
|
|
397
365
|
dateTimeRegex = /^(- Date\/Time:).*$/m;
|
|
398
366
|
if (dateTimeRegex.test(result)) {
|
|
399
367
|
result = result.replace(dateTimeRegex, `- Date/Time: ${formattedDateTime}`);
|
|
400
|
-
}
|
|
368
|
+
}
|
|
369
|
+
else {
|
|
401
370
|
result += `- Date/Time: ${formattedDateTime}\n`;
|
|
402
371
|
}
|
|
403
372
|
break;
|
|
404
373
|
}
|
|
405
374
|
return result;
|
|
406
375
|
}
|
|
407
|
-
|
|
408
376
|
function upsertCallDuration({ body, duration, logFormat }) {
|
|
409
|
-
if (typeof duration === 'undefined')
|
|
410
|
-
|
|
377
|
+
if (typeof duration === 'undefined')
|
|
378
|
+
return body;
|
|
411
379
|
const formattedDuration = secondsToHoursMinutesSeconds(duration);
|
|
412
380
|
let result = body;
|
|
413
381
|
let durationRegex = null;
|
|
@@ -417,7 +385,8 @@ function upsertCallDuration({ body, duration, logFormat }) {
|
|
|
417
385
|
durationRegex = /(?:<li>)?<b>Duration<\/b>:\s*([^<\n]+)(?:<\/li>|(?=<|$))/i;
|
|
418
386
|
if (durationRegex.test(result)) {
|
|
419
387
|
result = result.replace(durationRegex, `<li><b>Duration</b>: ${formattedDuration}</li>`);
|
|
420
|
-
}
|
|
388
|
+
}
|
|
389
|
+
else {
|
|
421
390
|
result += `<li><b>Duration</b>: ${formattedDuration}</li>`;
|
|
422
391
|
}
|
|
423
392
|
break;
|
|
@@ -426,7 +395,8 @@ function upsertCallDuration({ body, duration, logFormat }) {
|
|
|
426
395
|
durationRegex = /\*\*Duration\*\*: [^\n]*\n*/;
|
|
427
396
|
if (durationRegex.test(result)) {
|
|
428
397
|
result = result.replace(durationRegex, `**Duration**: ${formattedDuration}\n`);
|
|
429
|
-
}
|
|
398
|
+
}
|
|
399
|
+
else {
|
|
430
400
|
result += `**Duration**: ${formattedDuration}\n`;
|
|
431
401
|
}
|
|
432
402
|
break;
|
|
@@ -435,19 +405,18 @@ function upsertCallDuration({ body, duration, logFormat }) {
|
|
|
435
405
|
durationRegex = /- Duration: ([^\n-]+)(?=\n-|\n|$)/;
|
|
436
406
|
if (durationRegex.test(result)) {
|
|
437
407
|
result = result.replace(durationRegex, `- Duration: ${formattedDuration}`);
|
|
438
|
-
}
|
|
408
|
+
}
|
|
409
|
+
else {
|
|
439
410
|
result += `- Duration: ${formattedDuration}\n`;
|
|
440
411
|
}
|
|
441
412
|
break;
|
|
442
413
|
}
|
|
443
414
|
return result;
|
|
444
415
|
}
|
|
445
|
-
|
|
446
416
|
function upsertCallResult({ body, result, logFormat }) {
|
|
447
|
-
if (!result)
|
|
448
|
-
|
|
417
|
+
if (!result)
|
|
418
|
+
return body;
|
|
449
419
|
let bodyResult = body;
|
|
450
|
-
|
|
451
420
|
let resultRegex = null;
|
|
452
421
|
switch (logFormat) {
|
|
453
422
|
case LOG_DETAILS_FORMAT_TYPE.HTML:
|
|
@@ -455,7 +424,8 @@ function upsertCallResult({ body, result, logFormat }) {
|
|
|
455
424
|
resultRegex = /(?:<li>)?<b>Result<\/b>:\s*([^<\n]+)(?:<\/li>|(?=<|$))/i;
|
|
456
425
|
if (resultRegex.test(bodyResult)) {
|
|
457
426
|
bodyResult = bodyResult.replace(resultRegex, `<li><b>Result</b>: ${result}</li>`);
|
|
458
|
-
}
|
|
427
|
+
}
|
|
428
|
+
else {
|
|
459
429
|
bodyResult += `<li><b>Result</b>: ${result}</li>`;
|
|
460
430
|
}
|
|
461
431
|
break;
|
|
@@ -464,7 +434,8 @@ function upsertCallResult({ body, result, logFormat }) {
|
|
|
464
434
|
resultRegex = /\*\*Result\*\*: [^\n]*\n*/;
|
|
465
435
|
if (resultRegex.test(bodyResult)) {
|
|
466
436
|
bodyResult = bodyResult.replace(resultRegex, `**Result**: ${result}\n`);
|
|
467
|
-
}
|
|
437
|
+
}
|
|
438
|
+
else {
|
|
468
439
|
bodyResult += `**Result**: ${result}\n`;
|
|
469
440
|
}
|
|
470
441
|
break;
|
|
@@ -473,20 +444,19 @@ function upsertCallResult({ body, result, logFormat }) {
|
|
|
473
444
|
resultRegex = /- Result: ([^\n-]+)(?=\n-|\n|$)/;
|
|
474
445
|
if (resultRegex.test(bodyResult)) {
|
|
475
446
|
bodyResult = bodyResult.replace(resultRegex, `- Result: ${result}`);
|
|
476
|
-
}
|
|
447
|
+
}
|
|
448
|
+
else {
|
|
477
449
|
bodyResult += `- Result: ${result}\n`;
|
|
478
450
|
}
|
|
479
451
|
break;
|
|
480
452
|
}
|
|
481
453
|
return bodyResult;
|
|
482
454
|
}
|
|
483
|
-
|
|
484
455
|
function upsertCallRecording({ body, recordingLink, logFormat }) {
|
|
485
|
-
if (!recordingLink)
|
|
486
|
-
|
|
456
|
+
if (!recordingLink)
|
|
457
|
+
return body;
|
|
487
458
|
let result = body;
|
|
488
459
|
let recordingLinkRegex = null;
|
|
489
|
-
|
|
490
460
|
switch (logFormat) {
|
|
491
461
|
case LOG_DETAILS_FORMAT_TYPE.HTML:
|
|
492
462
|
// More flexible regex that handles both <li> wrapped and unwrapped content, and existing <a> anchors
|
|
@@ -494,19 +464,23 @@ function upsertCallRecording({ body, recordingLink, logFormat }) {
|
|
|
494
464
|
if (recordingLinkRegex.test(result)) {
|
|
495
465
|
if (recordingLink.startsWith('http')) {
|
|
496
466
|
result = result.replace(recordingLinkRegex, `<li><b>Call recording link</b>: <a target="_blank" href="${recordingLink}">open</a></li>`);
|
|
497
|
-
}
|
|
467
|
+
}
|
|
468
|
+
else {
|
|
498
469
|
result = result.replace(recordingLinkRegex, `<li><b>Call recording link</b>: (pending...)</li>`);
|
|
499
470
|
}
|
|
500
|
-
}
|
|
471
|
+
}
|
|
472
|
+
else {
|
|
501
473
|
let text = '';
|
|
502
474
|
if (recordingLink.startsWith('http')) {
|
|
503
475
|
text = `<li><b>Call recording link</b>: <a target="_blank" href="${recordingLink}">open</a></li>`;
|
|
504
|
-
}
|
|
476
|
+
}
|
|
477
|
+
else {
|
|
505
478
|
text = '<li><b>Call recording link</b>: (pending...)</li>';
|
|
506
479
|
}
|
|
507
480
|
if (result.indexOf('</ul>') === -1) {
|
|
508
481
|
result += text;
|
|
509
|
-
}
|
|
482
|
+
}
|
|
483
|
+
else {
|
|
510
484
|
result = result.replace('</ul>', `${text}</ul>`);
|
|
511
485
|
}
|
|
512
486
|
}
|
|
@@ -516,7 +490,8 @@ function upsertCallRecording({ body, recordingLink, logFormat }) {
|
|
|
516
490
|
recordingLinkRegex = /\*\*Call recording link\*\*: [^\n]*\n*/;
|
|
517
491
|
if (recordingLinkRegex.test(result)) {
|
|
518
492
|
result = result.replace(recordingLinkRegex, `**Call recording link**: ${recordingLink}\n`);
|
|
519
|
-
}
|
|
493
|
+
}
|
|
494
|
+
else {
|
|
520
495
|
result += `**Call recording link**: ${recordingLink}\n`;
|
|
521
496
|
}
|
|
522
497
|
break;
|
|
@@ -525,7 +500,8 @@ function upsertCallRecording({ body, recordingLink, logFormat }) {
|
|
|
525
500
|
recordingLinkRegex = /- Call recording link: [^\n]*\n*/;
|
|
526
501
|
if (recordingLinkRegex.test(result)) {
|
|
527
502
|
result = result.replace(recordingLinkRegex, `- Call recording link: ${recordingLink}\n`);
|
|
528
|
-
}
|
|
503
|
+
}
|
|
504
|
+
else {
|
|
529
505
|
if (result && !result.endsWith('\n')) {
|
|
530
506
|
result += '\n';
|
|
531
507
|
}
|
|
@@ -535,21 +511,20 @@ function upsertCallRecording({ body, recordingLink, logFormat }) {
|
|
|
535
511
|
}
|
|
536
512
|
return result;
|
|
537
513
|
}
|
|
538
|
-
|
|
539
514
|
function upsertAiNote({ body, aiNote, logFormat }) {
|
|
540
|
-
if (!aiNote)
|
|
541
|
-
|
|
515
|
+
if (!aiNote)
|
|
516
|
+
return body;
|
|
542
517
|
const clearedAiNote = aiNote.replace(/\n+$/, '');
|
|
543
518
|
let result = body;
|
|
544
519
|
let aiNoteRegex = null;
|
|
545
|
-
|
|
546
520
|
switch (logFormat) {
|
|
547
521
|
case LOG_DETAILS_FORMAT_TYPE.HTML:
|
|
548
522
|
const formattedAiNote = clearedAiNote.replace(/(?:\r\n|\r|\n)/g, '<br>');
|
|
549
523
|
aiNoteRegex = /<div><b>AI Note<\/b><br>(.+?)<\/div>/;
|
|
550
524
|
if (aiNoteRegex.test(result)) {
|
|
551
525
|
result = result.replace(aiNoteRegex, `<div><b>AI Note</b><br>${formattedAiNote}</div>`);
|
|
552
|
-
}
|
|
526
|
+
}
|
|
527
|
+
else {
|
|
553
528
|
result += `<div><b>AI Note</b><br>${formattedAiNote}</div><br>`;
|
|
554
529
|
}
|
|
555
530
|
break;
|
|
@@ -558,7 +533,8 @@ function upsertAiNote({ body, aiNote, logFormat }) {
|
|
|
558
533
|
aiNoteRegex = /### AI Note\n([\s\S]*?)(?=\n### |\n$|$)/;
|
|
559
534
|
if (aiNoteRegex.test(result)) {
|
|
560
535
|
result = result.replace(aiNoteRegex, `### AI Note\n${clearedAiNote}\n`);
|
|
561
|
-
}
|
|
536
|
+
}
|
|
537
|
+
else {
|
|
562
538
|
result += `### AI Note\n${clearedAiNote}\n`;
|
|
563
539
|
}
|
|
564
540
|
break;
|
|
@@ -566,27 +542,27 @@ function upsertAiNote({ body, aiNote, logFormat }) {
|
|
|
566
542
|
aiNoteRegex = /- AI Note:([\s\S]*?)--- END/;
|
|
567
543
|
if (aiNoteRegex.test(result)) {
|
|
568
544
|
result = result.replace(aiNoteRegex, `- AI Note:\n${clearedAiNote}\n--- END`);
|
|
569
|
-
}
|
|
545
|
+
}
|
|
546
|
+
else {
|
|
570
547
|
result += `\n- AI Note:\n${clearedAiNote}\n--- END\n`;
|
|
571
548
|
}
|
|
572
549
|
break;
|
|
573
550
|
}
|
|
574
551
|
return result;
|
|
575
552
|
}
|
|
576
|
-
|
|
577
553
|
function upsertTranscript({ body, transcript, logFormat }) {
|
|
578
|
-
if (!transcript)
|
|
579
|
-
|
|
554
|
+
if (!transcript)
|
|
555
|
+
return body;
|
|
580
556
|
let result = body;
|
|
581
557
|
let transcriptRegex = null;
|
|
582
|
-
|
|
583
558
|
switch (logFormat) {
|
|
584
559
|
case LOG_DETAILS_FORMAT_TYPE.HTML:
|
|
585
560
|
const formattedTranscript = transcript.replace(/(?:\r\n|\r|\n)/g, '<br>');
|
|
586
561
|
transcriptRegex = /<div><b>Transcript<\/b><br>(.+?)<\/div>/;
|
|
587
562
|
if (transcriptRegex.test(result)) {
|
|
588
563
|
result = result.replace(transcriptRegex, `<div><b>Transcript</b><br>${formattedTranscript}</div>`);
|
|
589
|
-
}
|
|
564
|
+
}
|
|
565
|
+
else {
|
|
590
566
|
result += `<div><b>Transcript</b><br>${formattedTranscript}</div><br>`;
|
|
591
567
|
}
|
|
592
568
|
break;
|
|
@@ -595,7 +571,8 @@ function upsertTranscript({ body, transcript, logFormat }) {
|
|
|
595
571
|
transcriptRegex = /### Transcript\n([\s\S]*?)(?=\n### |\n$|$)/;
|
|
596
572
|
if (transcriptRegex.test(result)) {
|
|
597
573
|
result = result.replace(transcriptRegex, `### Transcript\n${transcript}\n`);
|
|
598
|
-
}
|
|
574
|
+
}
|
|
575
|
+
else {
|
|
599
576
|
result += `### Transcript\n${transcript}\n`;
|
|
600
577
|
}
|
|
601
578
|
break;
|
|
@@ -603,14 +580,14 @@ function upsertTranscript({ body, transcript, logFormat }) {
|
|
|
603
580
|
transcriptRegex = /- Transcript:([\s\S]*?)--- END/;
|
|
604
581
|
if (transcriptRegex.test(result)) {
|
|
605
582
|
result = result.replace(transcriptRegex, `- Transcript:\n${transcript}\n--- END`);
|
|
606
|
-
}
|
|
583
|
+
}
|
|
584
|
+
else {
|
|
607
585
|
result += `\n- Transcript:\n${transcript}\n--- END\n`;
|
|
608
586
|
}
|
|
609
587
|
break;
|
|
610
588
|
}
|
|
611
589
|
return result;
|
|
612
590
|
}
|
|
613
|
-
|
|
614
591
|
function getLegPartyInfo(info) {
|
|
615
592
|
let phoneNumber = info.phoneNumber;
|
|
616
593
|
let extensionNumber = info.extensionNumber;
|
|
@@ -632,13 +609,13 @@ function getLegPartyInfo(info) {
|
|
|
632
609
|
}
|
|
633
610
|
return numberInfo;
|
|
634
611
|
}
|
|
635
|
-
|
|
636
612
|
function getLegsJourney(legs) {
|
|
637
613
|
return legs.map((leg, index) => {
|
|
638
614
|
if (index === 0) {
|
|
639
615
|
if (leg.direction === 'Outbound') {
|
|
640
616
|
return `Made call from ${getLegPartyInfo(leg.from)}`;
|
|
641
|
-
}
|
|
617
|
+
}
|
|
618
|
+
else {
|
|
642
619
|
return `Received call at ${getLegPartyInfo(leg.to)}`;
|
|
643
620
|
}
|
|
644
621
|
}
|
|
@@ -648,26 +625,26 @@ function getLegsJourney(legs) {
|
|
|
648
625
|
party = leg.to;
|
|
649
626
|
}
|
|
650
627
|
return `Transferred to ${getLegPartyInfo(party)}, duration: ${leg.duration} second${leg.duration > 1 ? 's' : ''}`;
|
|
651
|
-
}
|
|
628
|
+
}
|
|
629
|
+
else {
|
|
652
630
|
return `Transferred to ${getLegPartyInfo(leg.to)}, duration: ${leg.duration} second${leg.duration > 1 ? 's' : ''}`;
|
|
653
631
|
}
|
|
654
632
|
}).join('\n');
|
|
655
633
|
}
|
|
656
|
-
|
|
657
634
|
function upsertLegs({ body, legs, logFormat }) {
|
|
658
|
-
if (!legs || legs.length === 0)
|
|
659
|
-
|
|
635
|
+
if (!legs || legs.length === 0)
|
|
636
|
+
return body;
|
|
660
637
|
let result = body;
|
|
661
638
|
let legsJourney = getLegsJourney(legs);
|
|
662
639
|
let legsRegex = null;
|
|
663
|
-
|
|
664
640
|
switch (logFormat) {
|
|
665
641
|
case LOG_DETAILS_FORMAT_TYPE.HTML:
|
|
666
642
|
legsJourney = legsJourney.replace(/(?:\r\n|\r|\n)/g, '<br>');
|
|
667
643
|
legsRegex = /<div><b>Call journey<\/b><br>(.+?)<\/div>/;
|
|
668
644
|
if (legsRegex.test(result)) {
|
|
669
645
|
result = result.replace(legsRegex, `<div><b>Call journey</b><br>${legsJourney}</div>`);
|
|
670
|
-
}
|
|
646
|
+
}
|
|
647
|
+
else {
|
|
671
648
|
result += `<div><b>Call journey</b><br>${legsJourney}</div>`;
|
|
672
649
|
}
|
|
673
650
|
break;
|
|
@@ -675,7 +652,8 @@ function upsertLegs({ body, legs, logFormat }) {
|
|
|
675
652
|
legsRegex = /### Call journey\n([\s\S]*?)(?=\n### |\n$|$)/;
|
|
676
653
|
if (legsRegex.test(result)) {
|
|
677
654
|
result = result.replace(legsRegex, `### Call journey\n${legsJourney}\n`);
|
|
678
|
-
}
|
|
655
|
+
}
|
|
656
|
+
else {
|
|
679
657
|
result += `### Call journey\n${legsJourney}\n`;
|
|
680
658
|
}
|
|
681
659
|
break;
|
|
@@ -683,29 +661,28 @@ function upsertLegs({ body, legs, logFormat }) {
|
|
|
683
661
|
legsRegex = /- Call journey:([\s\S]*?)--- JOURNEY END/;
|
|
684
662
|
if (legsRegex.test(result)) {
|
|
685
663
|
result = result.replace(legsRegex, `- Call journey:\n${legsJourney}\n--- JOURNEY END`);
|
|
686
|
-
}
|
|
664
|
+
}
|
|
665
|
+
else {
|
|
687
666
|
result += `- Call journey:\n${legsJourney}\n--- JOURNEY END\n`;
|
|
688
667
|
}
|
|
689
668
|
break;
|
|
690
669
|
}
|
|
691
|
-
|
|
692
670
|
return result;
|
|
693
671
|
}
|
|
694
|
-
|
|
695
672
|
function upsertRingSenseTranscript({ body, transcript, logFormat }) {
|
|
696
|
-
if (!transcript)
|
|
697
|
-
|
|
673
|
+
if (!transcript)
|
|
674
|
+
return body;
|
|
698
675
|
let result = body;
|
|
699
676
|
const clearedTranscript = transcript.replace(/\n+$/, '');
|
|
700
677
|
let transcriptRegex = null;
|
|
701
|
-
|
|
702
678
|
switch (logFormat) {
|
|
703
679
|
case LOG_DETAILS_FORMAT_TYPE.HTML:
|
|
704
680
|
const formattedTranscript = clearedTranscript.replace(/(?:\r\n|\r|\n)/g, '<br>');
|
|
705
681
|
transcriptRegex = /<div><b>ACE transcript<\/b><br>(.+?)<\/div>/;
|
|
706
682
|
if (transcriptRegex.test(result)) {
|
|
707
683
|
result = result.replace(transcriptRegex, `<div><b>ACE transcript</b><br>${formattedTranscript}</div>`);
|
|
708
|
-
}
|
|
684
|
+
}
|
|
685
|
+
else {
|
|
709
686
|
result += `<div><b>ACE transcript</b><br>${formattedTranscript}</div>`;
|
|
710
687
|
}
|
|
711
688
|
break;
|
|
@@ -713,7 +690,8 @@ function upsertRingSenseTranscript({ body, transcript, logFormat }) {
|
|
|
713
690
|
transcriptRegex = /### ACE transcript\n([\s\S]*?)(?=\n### |\n$|$)/;
|
|
714
691
|
if (transcriptRegex.test(result)) {
|
|
715
692
|
result = result.replace(transcriptRegex, `### ACE transcript\n${clearedTranscript}\n`);
|
|
716
|
-
}
|
|
693
|
+
}
|
|
694
|
+
else {
|
|
717
695
|
result += `### ACE transcript\n${clearedTranscript}\n`;
|
|
718
696
|
}
|
|
719
697
|
break;
|
|
@@ -721,29 +699,29 @@ function upsertRingSenseTranscript({ body, transcript, logFormat }) {
|
|
|
721
699
|
transcriptRegex = /- ACE transcript:([\s\S]*?)--- END/;
|
|
722
700
|
if (transcriptRegex.test(result)) {
|
|
723
701
|
result = result.replace(transcriptRegex, `- ACE transcript:\n${clearedTranscript}\n--- END`);
|
|
724
|
-
}
|
|
702
|
+
}
|
|
703
|
+
else {
|
|
725
704
|
result += `\n- ACE transcript:\n${clearedTranscript}\n--- END\n`;
|
|
726
705
|
}
|
|
727
706
|
break;
|
|
728
707
|
}
|
|
729
708
|
return result;
|
|
730
709
|
}
|
|
731
|
-
|
|
732
710
|
function upsertRingSenseSummary({ body, summary, logFormat }) {
|
|
733
|
-
if (!summary)
|
|
734
|
-
|
|
711
|
+
if (!summary)
|
|
712
|
+
return body;
|
|
735
713
|
let result = body;
|
|
736
714
|
// remove new line in last line of summary
|
|
737
715
|
const clearedSummary = summary.replace(/\n+$/, '');
|
|
738
716
|
let summaryRegex = null;
|
|
739
|
-
|
|
740
717
|
switch (logFormat) {
|
|
741
718
|
case LOG_DETAILS_FORMAT_TYPE.HTML:
|
|
742
719
|
summaryRegex = /<div><b>ACE summary<\/b><br>(.+?)<\/div>/;
|
|
743
720
|
const formattedSummary = clearedSummary.replace(/(?:\r\n|\r|\n)/g, '<br>');
|
|
744
721
|
if (summaryRegex.test(result)) {
|
|
745
722
|
result = result.replace(summaryRegex, `<div><b>ACE summary</b><br>${formattedSummary}</div>`);
|
|
746
|
-
}
|
|
723
|
+
}
|
|
724
|
+
else {
|
|
747
725
|
result += `<div><b>ACE summary</b><br>${formattedSummary}</div>`;
|
|
748
726
|
}
|
|
749
727
|
break;
|
|
@@ -751,7 +729,8 @@ function upsertRingSenseSummary({ body, summary, logFormat }) {
|
|
|
751
729
|
summaryRegex = /### ACE summary\n([\s\S]*?)(?=\n### |\n$|$)/;
|
|
752
730
|
if (summaryRegex.test(result)) {
|
|
753
731
|
result = result.replace(summaryRegex, `### ACE summary\n${summary}\n`);
|
|
754
|
-
}
|
|
732
|
+
}
|
|
733
|
+
else {
|
|
755
734
|
result += `### ACE summary\n${summary}\n`;
|
|
756
735
|
}
|
|
757
736
|
break;
|
|
@@ -759,26 +738,26 @@ function upsertRingSenseSummary({ body, summary, logFormat }) {
|
|
|
759
738
|
summaryRegex = /- ACE summary:([\s\S]*?)--- END/;
|
|
760
739
|
if (summaryRegex.test(result)) {
|
|
761
740
|
result = result.replace(summaryRegex, `- ACE summary:\n${summary}\n--- END`);
|
|
762
|
-
}
|
|
741
|
+
}
|
|
742
|
+
else {
|
|
763
743
|
result += `\n- ACE summary:\n${summary}\n--- END\n`;
|
|
764
744
|
}
|
|
765
745
|
break;
|
|
766
746
|
}
|
|
767
747
|
return result;
|
|
768
748
|
}
|
|
769
|
-
|
|
770
749
|
function upsertRingSenseAIScore({ body, score, logFormat }) {
|
|
771
|
-
if (!score)
|
|
772
|
-
|
|
750
|
+
if (!score)
|
|
751
|
+
return body;
|
|
773
752
|
let result = body;
|
|
774
753
|
let scoreRegex = null;
|
|
775
|
-
|
|
776
754
|
switch (logFormat) {
|
|
777
755
|
case LOG_DETAILS_FORMAT_TYPE.HTML:
|
|
778
756
|
scoreRegex = /(?:<li>)?<b>Call score<\/b>:\s*([^<\n]+)(?:<\/li>|(?=<|$))/i;
|
|
779
757
|
if (scoreRegex.test(result)) {
|
|
780
758
|
result = result.replace(scoreRegex, `<li><b>Call score</b>: ${score}</li>`);
|
|
781
|
-
}
|
|
759
|
+
}
|
|
760
|
+
else {
|
|
782
761
|
result += `<li><b>Call score</b>: ${score}</li>`;
|
|
783
762
|
}
|
|
784
763
|
break;
|
|
@@ -786,7 +765,8 @@ function upsertRingSenseAIScore({ body, score, logFormat }) {
|
|
|
786
765
|
scoreRegex = /\*\*Call score\*\*: [^\n]*\n*/;
|
|
787
766
|
if (scoreRegex.test(result)) {
|
|
788
767
|
result = result.replace(scoreRegex, `**Call score**: ${score}\n`);
|
|
789
|
-
}
|
|
768
|
+
}
|
|
769
|
+
else {
|
|
790
770
|
result += `**Call score**: ${score}\n`;
|
|
791
771
|
}
|
|
792
772
|
break;
|
|
@@ -794,28 +774,28 @@ function upsertRingSenseAIScore({ body, score, logFormat }) {
|
|
|
794
774
|
scoreRegex = /- Call score:\s*([^<\n]+)(?=\n|$)/i;
|
|
795
775
|
if (scoreRegex.test(result)) {
|
|
796
776
|
result = result.replace(scoreRegex, `- Call score: ${score}`);
|
|
797
|
-
}
|
|
777
|
+
}
|
|
778
|
+
else {
|
|
798
779
|
result += `- Call score: ${score}\n`;
|
|
799
780
|
}
|
|
800
781
|
break;
|
|
801
782
|
}
|
|
802
783
|
return result;
|
|
803
784
|
}
|
|
804
|
-
|
|
805
785
|
function upsertRingSenseBulletedSummary({ body, summary, logFormat }) {
|
|
806
|
-
if (!summary)
|
|
807
|
-
|
|
786
|
+
if (!summary)
|
|
787
|
+
return body;
|
|
808
788
|
let result = body;
|
|
809
789
|
const clearedSummary = summary.replace(/\n+$/, '');
|
|
810
790
|
let summaryRegex = null;
|
|
811
|
-
|
|
812
791
|
switch (logFormat) {
|
|
813
792
|
case LOG_DETAILS_FORMAT_TYPE.HTML:
|
|
814
793
|
summaryRegex = /<div><b>ACE bulleted summary<\/b><br>(.+?)<\/div>/;
|
|
815
794
|
const formattedSummary = clearedSummary.replace(/(?:\r\n|\r|\n)/g, '<br>');
|
|
816
795
|
if (summaryRegex.test(result)) {
|
|
817
796
|
result = result.replace(summaryRegex, `<div><b>ACE bulleted summary</b><br>${formattedSummary}</div>`);
|
|
818
|
-
}
|
|
797
|
+
}
|
|
798
|
+
else {
|
|
819
799
|
result += `<div><b>ACE bulleted summary</b><br>${formattedSummary}</div>`;
|
|
820
800
|
}
|
|
821
801
|
break;
|
|
@@ -823,7 +803,8 @@ function upsertRingSenseBulletedSummary({ body, summary, logFormat }) {
|
|
|
823
803
|
summaryRegex = /### ACE bulleted summary\n([\s\S]*?)(?=\n### |\n$|$)/;
|
|
824
804
|
if (summaryRegex.test(result)) {
|
|
825
805
|
result = result.replace(summaryRegex, `### ACE bulleted summary\n${summary}\n`);
|
|
826
|
-
}
|
|
806
|
+
}
|
|
807
|
+
else {
|
|
827
808
|
result += `### ACE bulleted summary\n${summary}\n`;
|
|
828
809
|
}
|
|
829
810
|
break;
|
|
@@ -831,26 +812,26 @@ function upsertRingSenseBulletedSummary({ body, summary, logFormat }) {
|
|
|
831
812
|
summaryRegex = /- ACE bulleted summary:\s*([^<\n]+)(?=\n|$)/i;
|
|
832
813
|
if (summaryRegex.test(result)) {
|
|
833
814
|
result = result.replace(summaryRegex, `- ACE bulleted summary:\n${summary}\n--- END`);
|
|
834
|
-
}
|
|
815
|
+
}
|
|
816
|
+
else {
|
|
835
817
|
result += `\n- ACE bulleted summary:\n${summary}\n--- END\n`;
|
|
836
818
|
}
|
|
837
819
|
break;
|
|
838
820
|
}
|
|
839
821
|
return result;
|
|
840
822
|
}
|
|
841
|
-
|
|
842
823
|
function upsertRingSenseLink({ body, link, logFormat }) {
|
|
843
|
-
if (!link)
|
|
844
|
-
|
|
824
|
+
if (!link)
|
|
825
|
+
return body;
|
|
845
826
|
let result = body;
|
|
846
827
|
let linkRegex = null;
|
|
847
|
-
|
|
848
828
|
switch (logFormat) {
|
|
849
829
|
case LOG_DETAILS_FORMAT_TYPE.HTML:
|
|
850
830
|
linkRegex = /(?:<li>)?<b>ACE recording link<\/b>:\s*(?:<a[^>]*>[^<]*<\/a>|[^<]+)(?:<\/li>|(?=<|$))/i;
|
|
851
831
|
if (linkRegex.test(result)) {
|
|
852
832
|
result = result.replace(linkRegex, `<li><b>ACE recording link</b>: <a target="_blank" href="${link}">open</a></li>`);
|
|
853
|
-
}
|
|
833
|
+
}
|
|
834
|
+
else {
|
|
854
835
|
result += `<li><b>ACE recording link</b>: <a target="_blank" href="${link}">open</a></li>`;
|
|
855
836
|
}
|
|
856
837
|
break;
|
|
@@ -858,7 +839,8 @@ function upsertRingSenseLink({ body, link, logFormat }) {
|
|
|
858
839
|
linkRegex = /\*\*ACE recording link\*\*:\s*([^<\n]+)(?=\n|$)/i;
|
|
859
840
|
if (linkRegex.test(result)) {
|
|
860
841
|
result = result.replace(linkRegex, `**ACE recording link**: ${link}\n`);
|
|
861
|
-
}
|
|
842
|
+
}
|
|
843
|
+
else {
|
|
862
844
|
result += `**ACE recording link**: ${link}\n`;
|
|
863
845
|
}
|
|
864
846
|
break;
|
|
@@ -866,33 +848,11 @@ function upsertRingSenseLink({ body, link, logFormat }) {
|
|
|
866
848
|
linkRegex = /- ACE recording link:\s*([^<\n]+)(?=\n|$)/i;
|
|
867
849
|
if (linkRegex.test(result)) {
|
|
868
850
|
result = result.replace(linkRegex, `- ACE recording link: ${link}`);
|
|
869
|
-
}
|
|
851
|
+
}
|
|
852
|
+
else {
|
|
870
853
|
result += `- ACE recording link: ${link}\n`;
|
|
871
854
|
}
|
|
872
855
|
break;
|
|
873
856
|
}
|
|
874
857
|
return result;
|
|
875
858
|
}
|
|
876
|
-
|
|
877
|
-
module.exports = {
|
|
878
|
-
composeCallLog,
|
|
879
|
-
// Export individual upsert functions for backward compatibility
|
|
880
|
-
upsertCallAgentNote,
|
|
881
|
-
upsertCallSessionId,
|
|
882
|
-
upsertRingCentralUserName,
|
|
883
|
-
upsertRingCentralNumberAndExtension,
|
|
884
|
-
upsertCallSubject,
|
|
885
|
-
upsertContactPhoneNumber,
|
|
886
|
-
upsertCallDateTime,
|
|
887
|
-
upsertCallDuration,
|
|
888
|
-
upsertCallResult,
|
|
889
|
-
upsertCallRecording,
|
|
890
|
-
upsertAiNote,
|
|
891
|
-
upsertTranscript,
|
|
892
|
-
upsertLegs,
|
|
893
|
-
upsertRingSenseTranscript,
|
|
894
|
-
upsertRingSenseSummary,
|
|
895
|
-
upsertRingSenseAIScore,
|
|
896
|
-
upsertRingSenseBulletedSummary,
|
|
897
|
-
upsertRingSenseLink,
|
|
898
|
-
};
|