@webex/contact-center 3.12.0-webex-services-ready.4 → 3.13.0-next.1
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/.sdd/manifest.json +24 -13
- package/ai-docs/ARCHITECTURE.md +1 -1
- package/ai-docs/CONTRACTS.md +21 -3
- package/ai-docs/SECURITY.md +1 -1
- package/ai-docs/SERVICE_STATE.md +4 -0
- package/ai-docs/contact-center-spec.md +53 -6
- package/ai-docs/features/consult-transfer-list-policy/spec/feature-spec.md +362 -0
- package/ai-docs/features/contact-owner-change-refactor.md +78 -0
- package/dist/cc.js +816 -26
- package/dist/cc.js.map +1 -1
- package/dist/config.js +7 -0
- package/dist/config.js.map +1 -1
- package/dist/constants.js +29 -2
- package/dist/constants.js.map +1 -1
- package/dist/index.js +66 -12
- package/dist/index.js.map +1 -1
- package/dist/metrics/MetricsManager.js +16 -0
- package/dist/metrics/MetricsManager.js.map +1 -1
- package/dist/metrics/behavioral-events.js +110 -0
- package/dist/metrics/behavioral-events.js.map +1 -1
- package/dist/metrics/constants.js +33 -0
- package/dist/metrics/constants.js.map +1 -1
- package/dist/services/AddressBook.js +18 -15
- package/dist/services/AddressBook.js.map +1 -1
- package/dist/services/AnswerCallOnWebexService.js +202 -0
- package/dist/services/AnswerCallOnWebexService.js.map +1 -0
- package/dist/services/ApiAiAssistant.js +221 -11
- package/dist/services/ApiAiAssistant.js.map +1 -1
- package/dist/services/EntryPoint.js +46 -68
- package/dist/services/EntryPoint.js.map +1 -1
- package/dist/services/Queue.js +27 -22
- package/dist/services/Queue.js.map +1 -1
- package/dist/services/WebCallingService.js +287 -37
- package/dist/services/WebCallingService.js.map +1 -1
- package/dist/services/WebexCrossClientService.js +225 -0
- package/dist/services/WebexCrossClientService.js.map +1 -0
- package/dist/services/WxAppTelephonyMercurySync.js +111 -0
- package/dist/services/WxAppTelephonyMercurySync.js.map +1 -0
- package/dist/services/config/Util.js +46 -46
- package/dist/services/config/Util.js.map +1 -1
- package/dist/services/config/constants.js +34 -77
- package/dist/services/config/constants.js.map +1 -1
- package/dist/services/config/index.js +100 -226
- package/dist/services/config/index.js.map +1 -1
- package/dist/services/config/types.js +55 -35
- package/dist/services/config/types.js.map +1 -1
- package/dist/services/constants.js +11 -1
- package/dist/services/constants.js.map +1 -1
- package/dist/services/core/Err.js.map +1 -1
- package/dist/services/core/Utils.js +25 -1
- package/dist/services/core/Utils.js.map +1 -1
- package/dist/services/core/WebexRequest.js +6 -2
- package/dist/services/core/WebexRequest.js.map +1 -1
- package/dist/services/core/aqm-reqs.js +17 -11
- package/dist/services/core/aqm-reqs.js.map +1 -1
- package/dist/services/core/constants.js +9 -1
- package/dist/services/core/constants.js.map +1 -1
- package/dist/services/core/types.js.map +1 -1
- package/dist/services/core/websocket/WebSocketManager.js +17 -1
- package/dist/services/core/websocket/WebSocketManager.js.map +1 -1
- package/dist/services/task/Task.js +275 -8
- package/dist/services/task/Task.js.map +1 -1
- package/dist/services/task/TaskFactory.js +11 -6
- package/dist/services/task/TaskFactory.js.map +1 -1
- package/dist/services/task/TaskManager.js +590 -42
- package/dist/services/task/TaskManager.js.map +1 -1
- package/dist/services/task/TaskUtils.js +11 -1
- package/dist/services/task/TaskUtils.js.map +1 -1
- package/dist/services/task/WebexCallingUtils.js +70 -0
- package/dist/services/task/WebexCallingUtils.js.map +1 -0
- package/dist/services/task/constants.js +14 -2
- package/dist/services/task/constants.js.map +1 -1
- package/dist/services/task/contact.js +29 -0
- package/dist/services/task/contact.js.map +1 -1
- package/dist/services/task/digital/Digital.js +4 -3
- package/dist/services/task/digital/Digital.js.map +1 -1
- package/dist/services/task/state-machine/TaskStateMachine.js +162 -53
- package/dist/services/task/state-machine/TaskStateMachine.js.map +1 -1
- package/dist/services/task/state-machine/actions.js +6 -1
- package/dist/services/task/state-machine/actions.js.map +1 -1
- package/dist/services/task/state-machine/guards.js +7 -10
- package/dist/services/task/state-machine/guards.js.map +1 -1
- package/dist/services/task/state-machine/types.js.map +1 -1
- package/dist/services/task/state-machine/uiControlsComputer.js +118 -18
- package/dist/services/task/state-machine/uiControlsComputer.js.map +1 -1
- package/dist/services/task/types.js +47 -1
- package/dist/services/task/types.js.map +1 -1
- package/dist/services/task/voice/Voice.js +477 -17
- package/dist/services/task/voice/Voice.js.map +1 -1
- package/dist/services/task/voice/WebRTC.js +6 -3
- package/dist/services/task/voice/WebRTC.js.map +1 -1
- package/dist/services/task/voice/wxAppOfferObservability.js +145 -0
- package/dist/services/task/voice/wxAppOfferObservability.js.map +1 -0
- package/dist/services/task/voice/wxAppVoiceMethods.js +395 -0
- package/dist/services/task/voice/wxAppVoiceMethods.js.map +1 -0
- package/dist/services/wxAppDiagnosticLogging.js +159 -0
- package/dist/services/wxAppDiagnosticLogging.js.map +1 -0
- package/dist/services/wxAppTelephonyUtils.js +19 -0
- package/dist/services/wxAppTelephonyUtils.js.map +1 -0
- package/dist/types/cc.d.ts +127 -9
- package/dist/types/config.d.ts +7 -0
- package/dist/types/constants.d.ts +23 -0
- package/dist/types/index.d.ts +38 -17
- package/dist/types/metrics/MetricsManager.d.ts +6 -0
- package/dist/types/metrics/constants.d.ts +31 -0
- package/dist/types/services/AddressBook.d.ts +2 -1
- package/dist/types/services/AnswerCallOnWebexService.d.ts +38 -0
- package/dist/types/services/ApiAiAssistant.d.ts +48 -4
- package/dist/types/services/EntryPoint.d.ts +7 -5
- package/dist/types/services/Queue.d.ts +5 -3
- package/dist/types/services/WebexCrossClientService.d.ts +32 -0
- package/dist/types/services/WxAppTelephonyMercurySync.d.ts +28 -0
- package/dist/types/services/config/Util.d.ts +4 -8
- package/dist/types/services/config/constants.d.ts +28 -76
- package/dist/types/services/config/index.d.ts +16 -64
- package/dist/types/services/config/types.d.ts +150 -173
- package/dist/types/services/constants.d.ts +9 -0
- package/dist/types/services/core/Err.d.ts +2 -0
- package/dist/types/services/core/Utils.d.ts +10 -0
- package/dist/types/services/core/WebexRequest.d.ts +1 -0
- package/dist/types/services/core/constants.d.ts +7 -0
- package/dist/types/services/core/types.d.ts +2 -0
- package/dist/types/services/task/Task.d.ts +34 -5
- package/dist/types/services/task/TaskFactory.d.ts +4 -2
- package/dist/types/services/task/TaskUtils.d.ts +6 -0
- package/dist/types/services/task/WebexCallingUtils.d.ts +11 -0
- package/dist/types/services/task/constants.d.ts +12 -0
- package/dist/types/services/task/contact.d.ts +4 -0
- package/dist/types/services/task/digital/Digital.d.ts +4 -3
- package/dist/types/services/task/state-machine/TaskStateMachine.d.ts +304 -56
- package/dist/types/services/task/state-machine/guards.d.ts +6 -5
- package/dist/types/services/task/state-machine/types.d.ts +9 -1
- package/dist/types/services/task/types.d.ts +192 -5
- package/dist/types/services/task/voice/Voice.d.ts +68 -11
- package/dist/types/services/task/voice/WebRTC.d.ts +5 -4
- package/dist/types/services/task/voice/wxAppOfferObservability.d.ts +39 -0
- package/dist/types/services/task/voice/wxAppVoiceMethods.d.ts +68 -0
- package/dist/types/services/wxAppDiagnosticLogging.d.ts +63 -0
- package/dist/types/services/wxAppTelephonyUtils.d.ts +5 -0
- package/dist/types/types.d.ts +125 -13
- package/dist/types/utils/PageCache.d.ts +20 -3
- package/dist/types.js +90 -8
- package/dist/types.js.map +1 -1
- package/dist/utils/PageCache.js +19 -5
- package/dist/utils/PageCache.js.map +1 -1
- package/dist/webex.js +9 -1
- package/dist/webex.js.map +1 -1
- package/package.json +10 -9
- package/src/cc.ts +1047 -48
- package/src/config.ts +7 -0
- package/src/constants.ts +36 -0
- package/src/index.ts +49 -11
- package/src/metrics/MetricsManager.ts +16 -0
- package/src/metrics/ai-docs/metrics-spec.md +138 -21
- package/src/metrics/behavioral-events.ts +112 -0
- package/src/metrics/constants.ts +36 -0
- package/src/services/AddressBook.ts +17 -6
- package/src/services/AnswerCallOnWebexService.ts +239 -0
- package/src/services/ApiAiAssistant.ts +297 -13
- package/src/services/EntryPoint.ts +59 -60
- package/src/services/Queue.ts +29 -12
- package/src/services/WebCallingService.ts +362 -40
- package/src/services/WebexCrossClientService.ts +298 -0
- package/src/services/WxAppTelephonyMercurySync.ts +142 -0
- package/src/services/agent/ai-docs/AGENTS.md +1 -1
- package/src/services/agent/ai-docs/agent-spec.md +1 -0
- package/src/services/ai-docs/AGENTS.md +11 -11
- package/src/services/ai-docs/services-spec.md +25 -5
- package/src/services/config/Util.ts +52 -82
- package/src/services/config/ai-docs/AGENTS.md +35 -40
- package/src/services/config/ai-docs/ARCHITECTURE.md +90 -103
- package/src/services/config/ai-docs/config-spec.md +132 -132
- package/src/services/config/constants.ts +39 -85
- package/src/services/config/index.ts +116 -277
- package/src/services/config/types.ts +145 -195
- package/src/services/constants.ts +10 -0
- package/src/services/core/Err.ts +1 -0
- package/src/services/core/Utils.ts +28 -0
- package/src/services/core/WebexRequest.ts +3 -1
- package/src/services/core/ai-docs/core-spec.md +25 -11
- package/src/services/core/aqm-reqs.ts +18 -12
- package/src/services/core/constants.ts +8 -0
- package/src/services/core/types.ts +33 -1
- package/src/services/core/websocket/WebSocketManager.ts +26 -2
- package/src/services/task/Task.ts +386 -12
- package/src/services/task/TaskFactory.ts +33 -6
- package/src/services/task/TaskManager.ts +857 -41
- package/src/services/task/TaskUtils.ts +13 -0
- package/src/services/task/WebexCallingUtils.ts +136 -0
- package/src/services/task/ai-docs/ARCHITECTURE.md +1 -0
- package/src/services/task/ai-docs/task-spec.md +190 -8
- package/src/services/task/constants.ts +13 -0
- package/src/services/task/contact.ts +30 -0
- package/src/services/task/digital/Digital.ts +11 -4
- package/src/services/task/state-machine/TaskStateMachine.ts +235 -81
- package/src/services/task/state-machine/actions.ts +5 -2
- package/src/services/task/state-machine/ai-docs/AGENTS.md +6 -4
- package/src/services/task/state-machine/ai-docs/ARCHITECTURE.md +35 -16
- package/src/services/task/state-machine/ai-docs/task-state-machine-spec.md +103 -33
- package/src/services/task/state-machine/guards.ts +7 -10
- package/src/services/task/state-machine/types.ts +16 -1
- package/src/services/task/state-machine/uiControlsComputer.ts +206 -32
- package/src/services/task/types.ts +269 -4
- package/src/services/task/voice/Voice.ts +625 -17
- package/src/services/task/voice/WebRTC.ts +11 -4
- package/src/services/task/voice/wxAppOfferObservability.ts +204 -0
- package/src/services/task/voice/wxAppVoiceMethods.ts +575 -0
- package/src/services/wxAppDiagnosticLogging.ts +286 -0
- package/src/services/wxAppTelephonyUtils.ts +14 -0
- package/src/types.ts +159 -13
- package/src/utils/AGENTS.md +21 -10
- package/src/utils/PageCache.ts +38 -5
- package/src/utils/ai-docs/utils-spec.md +21 -11
- package/src/webex.js +8 -0
- package/test/unit/fixtures/aiSummaryTestUtils.ts +40 -0
- package/test/unit/spec/cc.ts +3595 -120
- package/test/unit/spec/index.ts +891 -0
- package/test/unit/spec/metrics/MetricsManager.ts +25 -0
- package/test/unit/spec/metrics/behavioral-events.ts +60 -0
- package/test/unit/spec/services/AddressBook.ts +37 -6
- package/test/unit/spec/services/AnswerCallOnWebexService.ts +264 -0
- package/test/unit/spec/services/ApiAiAssistant.ts +269 -8
- package/test/unit/spec/services/EntryPoint.ts +87 -40
- package/test/unit/spec/services/Queue.ts +123 -12
- package/test/unit/spec/services/WebCallingService.ts +483 -54
- package/test/unit/spec/services/WebexCrossClientService.ts +509 -0
- package/test/unit/spec/services/WxAppTelephonyMercurySync.ts +136 -0
- package/test/unit/spec/services/config/Util.ts +501 -0
- package/test/unit/spec/services/config/index.ts +313 -543
- package/test/unit/spec/services/core/Utils.ts +22 -0
- package/test/unit/spec/services/core/WebexRequest.ts +8 -7
- package/test/unit/spec/services/core/aqm-reqs.ts +142 -1
- package/test/unit/spec/services/core/websocket/WebSocketManager.ts +64 -14
- package/test/unit/spec/services/task/Task.ts +2257 -11
- package/test/unit/spec/services/task/TaskFactory.ts +56 -2
- package/test/unit/spec/services/task/TaskManager.ts +5559 -1493
- package/test/unit/spec/services/task/TaskUtils.ts +72 -0
- package/test/unit/spec/services/task/WebexCallingUtils.ts +153 -0
- package/test/unit/spec/services/task/contact.ts +33 -0
- package/test/unit/spec/services/task/state-machine/TaskStateMachine.ts +1501 -92
- package/test/unit/spec/services/task/state-machine/guards.ts +210 -8
- package/test/unit/spec/services/task/state-machine/uiControlsComputer.ts +445 -7
- package/test/unit/spec/services/task/voice/Voice.ts +1710 -4
- package/test/unit/spec/services/task/voice/wxAppOfferObservability.ts +361 -0
- package/test/unit/spec/services/task/voice/wxAppVoiceMethods.ts +719 -0
- package/test/unit/spec/services/wxAppDiagnosticLogging.ts +179 -0
- package/test/unit/spec/wellnessSampleUtils.ts +288 -0
- package/typedoc.md +1 -1
- package/umd/contact-center.min.js +2 -2
- package/umd/contact-center.min.js.map +1 -1
|
@@ -2,7 +2,7 @@ import {v4 as uuidv4} from 'uuid';
|
|
|
2
2
|
import LoggerProxy from '../logger-proxy';
|
|
3
3
|
import MetricsManager from '../metrics/MetricsManager';
|
|
4
4
|
import {METRIC_EVENT_NAMES} from '../metrics/constants';
|
|
5
|
-
import {CC_FILE, METHODS} from '../constants';
|
|
5
|
+
import {AI_SUMMARY_ERROR_CODES, CC_FILE, METHODS} from '../constants';
|
|
6
6
|
import {
|
|
7
7
|
HTTP_METHODS,
|
|
8
8
|
WebexSDK,
|
|
@@ -12,8 +12,13 @@ import {
|
|
|
12
12
|
HistoricTranscriptsResponse,
|
|
13
13
|
RealTimeAssistanceParams,
|
|
14
14
|
RealTimeAssistanceUserActionParams,
|
|
15
|
+
RespondToWellnessBreakParams,
|
|
16
|
+
WellnessBreakUserAction,
|
|
17
|
+
WELLNESS_BREAK_USER_ACTIONS,
|
|
18
|
+
GenericError,
|
|
15
19
|
} from '../types';
|
|
16
20
|
import {getErrorDetails} from './core/Utils';
|
|
21
|
+
import type {PendingRtdRequest, RtdRequestOptions} from './core/types';
|
|
17
22
|
import {
|
|
18
23
|
AI_ASSISTANT_BASE_URL_TEMPLATE,
|
|
19
24
|
AI_ASSISTANT_ENV_MAP,
|
|
@@ -22,6 +27,12 @@ import {
|
|
|
22
27
|
} from './constants';
|
|
23
28
|
import {AIFeatureFlags} from './config/types';
|
|
24
29
|
|
|
30
|
+
type WellnessBreakContextProvider = () => {
|
|
31
|
+
isWellnessBreakEnabled: boolean;
|
|
32
|
+
agentId?: string;
|
|
33
|
+
agentSessionId?: string;
|
|
34
|
+
};
|
|
35
|
+
|
|
25
36
|
/**
|
|
26
37
|
* ApiAIAssistant provides AI Assistant APIs for transcript controls.
|
|
27
38
|
* @public
|
|
@@ -29,10 +40,26 @@ import {AIFeatureFlags} from './config/types';
|
|
|
29
40
|
export class ApiAIAssistant {
|
|
30
41
|
private webex: WebexSDK;
|
|
31
42
|
private metricsManager: MetricsManager;
|
|
32
|
-
|
|
43
|
+
/** @internal Current AI flags from the agent configuration. */
|
|
44
|
+
public aiFeature: AIFeatureFlags;
|
|
45
|
+
private pendingRtdRequests = new Map<string, PendingRtdRequest<unknown>>();
|
|
46
|
+
private readonly wellnessContextProvider?: WellnessBreakContextProvider;
|
|
47
|
+
|
|
48
|
+
private createWellnessError(reason: string): GenericError {
|
|
49
|
+
const error = new Error(reason) as GenericError;
|
|
50
|
+
error.details = {
|
|
51
|
+
type: 'SDK_VALIDATION_ERROR',
|
|
52
|
+
orgId: this.webex.credentials.getOrgId(),
|
|
53
|
+
trackingId: '',
|
|
54
|
+
data: {reason},
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
return error;
|
|
58
|
+
}
|
|
33
59
|
|
|
34
|
-
constructor(webex: WebexSDK) {
|
|
60
|
+
constructor(webex: WebexSDK, wellnessContextProvider?: WellnessBreakContextProvider) {
|
|
35
61
|
this.webex = webex;
|
|
62
|
+
this.wellnessContextProvider = wellnessContextProvider;
|
|
36
63
|
this.metricsManager = MetricsManager.getInstance({webex});
|
|
37
64
|
}
|
|
38
65
|
|
|
@@ -40,12 +67,152 @@ export class ApiAIAssistant {
|
|
|
40
67
|
this.aiFeature = aiFeature;
|
|
41
68
|
}
|
|
42
69
|
|
|
70
|
+
/**
|
|
71
|
+
* Validates a caller-supplied identifier (agentId/interactionId) before it is used to
|
|
72
|
+
* construct a request. Accepts a non-empty alphanumeric identifier that may contain
|
|
73
|
+
* hyphens or underscores.
|
|
74
|
+
* @param value - the identifier to validate
|
|
75
|
+
* @returns {boolean} true when the identifier is a non-empty, well-formed string
|
|
76
|
+
* @private
|
|
77
|
+
*/
|
|
78
|
+
private isValidTranscriptIdentifier(value: unknown): boolean {
|
|
79
|
+
return typeof value === 'string' && /^[A-Za-z0-9_-]{1,128}$/.test(value);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
private async sendWellnessBreakAction(
|
|
83
|
+
action: WellnessBreakUserAction,
|
|
84
|
+
method: string
|
|
85
|
+
): Promise<void> {
|
|
86
|
+
this.metricsManager.timeEvent([
|
|
87
|
+
METRIC_EVENT_NAMES.AI_ASSISTANT_WELLNESS_ACTION_ACCEPTED,
|
|
88
|
+
METRIC_EVENT_NAMES.AI_ASSISTANT_WELLNESS_ACTION_FAILED,
|
|
89
|
+
]);
|
|
90
|
+
|
|
91
|
+
try {
|
|
92
|
+
const context = this.wellnessContextProvider?.();
|
|
93
|
+
const agentId = context?.agentId?.trim();
|
|
94
|
+
const agentSessionId = context?.agentSessionId?.trim();
|
|
95
|
+
const orgId = this.webex.credentials.getOrgId()?.trim();
|
|
96
|
+
|
|
97
|
+
if (context?.isWellnessBreakEnabled !== true) {
|
|
98
|
+
throw this.createWellnessError('WELLNESS_BREAK_NOT_ENABLED');
|
|
99
|
+
}
|
|
100
|
+
if (!orgId) {
|
|
101
|
+
throw this.createWellnessError('WELLNESS_BREAK_ORG_ID_REQUIRED');
|
|
102
|
+
}
|
|
103
|
+
if (!agentId) {
|
|
104
|
+
throw this.createWellnessError('WELLNESS_BREAK_AGENT_ID_REQUIRED');
|
|
105
|
+
}
|
|
106
|
+
if (!agentSessionId) {
|
|
107
|
+
throw this.createWellnessError('WELLNESS_BREAK_AGENT_SESSION_REQUIRED');
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const baseUrl = this.getBaseUrl();
|
|
111
|
+
const response = (await this.webex.request({
|
|
112
|
+
uri: `${baseUrl}${AI_ASSISTANT_API_URLS.EVENT}`,
|
|
113
|
+
method: HTTP_METHODS.POST,
|
|
114
|
+
addAuthHeader: true,
|
|
115
|
+
body: {
|
|
116
|
+
agentId,
|
|
117
|
+
orgId,
|
|
118
|
+
eventType: AIAssistantEventType.CUSTOM_EVENT,
|
|
119
|
+
eventName: AIAssistantEventName.WELLNESS_BREAK_ACTION,
|
|
120
|
+
eventDetails: {
|
|
121
|
+
data: {
|
|
122
|
+
action,
|
|
123
|
+
agentSessionId,
|
|
124
|
+
actionTimeStamp: Date.now(),
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
})) as IHttpResponse;
|
|
129
|
+
|
|
130
|
+
if (response.statusCode !== 202) {
|
|
131
|
+
throw this.createWellnessError(
|
|
132
|
+
`WELLNESS_BREAK_ACTION_UNEXPECTED_STATUS_${response.statusCode}`
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
this.metricsManager.trackEvent(
|
|
137
|
+
METRIC_EVENT_NAMES.AI_ASSISTANT_WELLNESS_ACTION_ACCEPTED,
|
|
138
|
+
{action},
|
|
139
|
+
['operational']
|
|
140
|
+
);
|
|
141
|
+
LoggerProxy.log('Wellness action accepted by AI Assistant', {
|
|
142
|
+
module: CC_FILE,
|
|
143
|
+
method,
|
|
144
|
+
data: {action},
|
|
145
|
+
});
|
|
146
|
+
} catch (error) {
|
|
147
|
+
this.metricsManager.trackEvent(
|
|
148
|
+
METRIC_EVENT_NAMES.AI_ASSISTANT_WELLNESS_ACTION_FAILED,
|
|
149
|
+
{
|
|
150
|
+
action,
|
|
151
|
+
error: error instanceof Error ? error.message : String(error),
|
|
152
|
+
},
|
|
153
|
+
['operational']
|
|
154
|
+
);
|
|
155
|
+
const {error: detailedError} = getErrorDetails(error, method, CC_FILE);
|
|
156
|
+
throw detailedError;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Requests an Agent Wellness Break.
|
|
162
|
+
* The promise resolves when the HTTP request is accepted with status 202; the later
|
|
163
|
+
* approval or denial is delivered independently through a wellness notification.
|
|
164
|
+
* @returns A promise that resolves with no value after HTTP acceptance
|
|
165
|
+
* @throws Structured Contact Center error when disabled, stale, invalid, or delivery fails
|
|
166
|
+
* @example
|
|
167
|
+
* await webex.cc.apiAIAssistant.requestWellnessBreak();
|
|
168
|
+
* @public
|
|
169
|
+
*/
|
|
170
|
+
public async requestWellnessBreak(): Promise<void> {
|
|
171
|
+
return this.sendWellnessBreakAction(
|
|
172
|
+
WELLNESS_BREAK_USER_ACTIONS.REQUESTED,
|
|
173
|
+
METHODS.REQUEST_WELLNESS_BREAK
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Responds to a backend-provided Agent Wellness Break offer.
|
|
179
|
+
* The promise resolves when the HTTP request is accepted with status 202 and does not
|
|
180
|
+
* wait for a WebSocket completion event.
|
|
181
|
+
* @param params - ACCEPTED, REJECTED, or NO_RESPONSE
|
|
182
|
+
* @returns A promise that resolves with no value after HTTP acceptance
|
|
183
|
+
* @throws Structured Contact Center error when disabled, stale, invalid, or delivery fails
|
|
184
|
+
* @example
|
|
185
|
+
* await webex.cc.apiAIAssistant.respondToWellnessBreak({
|
|
186
|
+
* action: WELLNESS_BREAK_USER_ACTIONS.ACCEPTED,
|
|
187
|
+
* });
|
|
188
|
+
* @public
|
|
189
|
+
*/
|
|
190
|
+
public async respondToWellnessBreak(params: RespondToWellnessBreakParams): Promise<void> {
|
|
191
|
+
const {action} = params;
|
|
192
|
+
if (
|
|
193
|
+
![
|
|
194
|
+
WELLNESS_BREAK_USER_ACTIONS.ACCEPTED,
|
|
195
|
+
WELLNESS_BREAK_USER_ACTIONS.REJECTED,
|
|
196
|
+
WELLNESS_BREAK_USER_ACTIONS.NO_RESPONSE,
|
|
197
|
+
].includes(action)
|
|
198
|
+
) {
|
|
199
|
+
const {error} = getErrorDetails(
|
|
200
|
+
this.createWellnessError('WELLNESS_BREAK_ACTION_INVALID'),
|
|
201
|
+
METHODS.RESPOND_TO_WELLNESS_BREAK,
|
|
202
|
+
CC_FILE
|
|
203
|
+
);
|
|
204
|
+
throw error;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
return this.sendWellnessBreakAction(action, METHODS.RESPOND_TO_WELLNESS_BREAK);
|
|
208
|
+
}
|
|
209
|
+
|
|
43
210
|
private getBaseUrl(): string {
|
|
44
211
|
const wccApiGatewayUrl = this.webex.internal.services.get(WCC_API_GATEWAY) || '';
|
|
45
212
|
|
|
46
213
|
if (!wccApiGatewayUrl) {
|
|
47
214
|
const {error: detailedError} = getErrorDetails(
|
|
48
|
-
new Error(
|
|
215
|
+
new Error(AI_SUMMARY_ERROR_CODES.AI_ASSISTANT_BASE_URL_NOT_AVAILABLE),
|
|
49
216
|
METHODS.GET_BASE_URL,
|
|
50
217
|
CC_FILE
|
|
51
218
|
);
|
|
@@ -60,9 +227,10 @@ export class ApiAIAssistant {
|
|
|
60
227
|
}
|
|
61
228
|
|
|
62
229
|
const resolvedEnv = AI_ASSISTANT_ENV_MAP[hostname];
|
|
230
|
+
|
|
63
231
|
if (!resolvedEnv) {
|
|
64
232
|
const {error: detailedError} = getErrorDetails(
|
|
65
|
-
new Error(
|
|
233
|
+
new Error(AI_SUMMARY_ERROR_CODES.AI_ASSISTANT_BASE_URL_NOT_AVAILABLE),
|
|
66
234
|
METHODS.GET_BASE_URL,
|
|
67
235
|
CC_FILE
|
|
68
236
|
);
|
|
@@ -72,6 +240,105 @@ export class ApiAIAssistant {
|
|
|
72
240
|
return AI_ASSISTANT_BASE_URL_TEMPLATE.replace('%s', resolvedEnv);
|
|
73
241
|
}
|
|
74
242
|
|
|
243
|
+
private static getRtdRequestKey(rtdEventType: string, correlationId: string): string {
|
|
244
|
+
return JSON.stringify([rtdEventType, correlationId]);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
private removeRtdRequest<T>(
|
|
248
|
+
rtdEventType: string,
|
|
249
|
+
correlationId: string,
|
|
250
|
+
settle?: (request: PendingRtdRequest<T>) => void
|
|
251
|
+
): PendingRtdRequest<T> | undefined {
|
|
252
|
+
const key = ApiAIAssistant.getRtdRequestKey(rtdEventType, correlationId);
|
|
253
|
+
const request = this.pendingRtdRequests.get(key) as PendingRtdRequest<T> | undefined;
|
|
254
|
+
|
|
255
|
+
if (!request) {
|
|
256
|
+
return undefined;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
if (request.timeoutId) {
|
|
260
|
+
clearTimeout(request.timeoutId);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
settle?.(request);
|
|
264
|
+
this.pendingRtdRequests.delete(key);
|
|
265
|
+
|
|
266
|
+
return request;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/** Sends an AI event and waits for its matching RTD response. @internal */
|
|
270
|
+
public async requestAndWaitForRtd<T>(options: RtdRequestOptions): Promise<T> {
|
|
271
|
+
const key = ApiAIAssistant.getRtdRequestKey(options.rtdEventType, options.correlationId);
|
|
272
|
+
let resolveResult: (payload: T) => void = () => undefined;
|
|
273
|
+
let rejectResult: (error: Error) => void = () => undefined;
|
|
274
|
+
const result = new Promise<T>((resolve, reject) => {
|
|
275
|
+
resolveResult = resolve;
|
|
276
|
+
rejectResult = reject;
|
|
277
|
+
});
|
|
278
|
+
const previousRequest = this.pendingRtdRequests.get(key);
|
|
279
|
+
if (previousRequest?.timeoutId) {
|
|
280
|
+
clearTimeout(previousRequest.timeoutId);
|
|
281
|
+
}
|
|
282
|
+
const request: PendingRtdRequest<T> = {
|
|
283
|
+
correlationId: options.correlationId,
|
|
284
|
+
rtdEventType: options.rtdEventType,
|
|
285
|
+
resolve: resolveResult,
|
|
286
|
+
reject: rejectResult,
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
request.timeoutId = setTimeout(() => {
|
|
290
|
+
this.removeRtdRequest<T>(options.rtdEventType, options.correlationId, (currentRequest) => {
|
|
291
|
+
currentRequest.reject(options.createTimeoutError());
|
|
292
|
+
});
|
|
293
|
+
}, options.timeoutMs);
|
|
294
|
+
this.pendingRtdRequests.set(key, request as PendingRtdRequest<unknown>);
|
|
295
|
+
const publishTimestamp = options.publishTimestamp ?? Date.now();
|
|
296
|
+
const acknowledgement = Promise.resolve()
|
|
297
|
+
.then(() =>
|
|
298
|
+
this.sendEvent(
|
|
299
|
+
options.agentId,
|
|
300
|
+
options.interactionId,
|
|
301
|
+
options.eventType,
|
|
302
|
+
options.eventName,
|
|
303
|
+
options.eventMetaData,
|
|
304
|
+
undefined,
|
|
305
|
+
undefined,
|
|
306
|
+
publishTimestamp,
|
|
307
|
+
options.timeout
|
|
308
|
+
)
|
|
309
|
+
)
|
|
310
|
+
.catch((error) => {
|
|
311
|
+
this.removeRtdRequest(options.rtdEventType, options.correlationId);
|
|
312
|
+
throw error;
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
const [payload] = await Promise.all([result, acknowledgement]);
|
|
316
|
+
|
|
317
|
+
return payload;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/** Resolves a pending request from a parsed RTD event. @internal */
|
|
321
|
+
public resolveFromRtdEvent<T>(
|
|
322
|
+
rtdEventType: string,
|
|
323
|
+
correlationId: string,
|
|
324
|
+
payload: T
|
|
325
|
+
): 'resolved' | 'not-found' {
|
|
326
|
+
const request = this.removeRtdRequest<T>(rtdEventType, correlationId, (currentRequest) => {
|
|
327
|
+
currentRequest.resolve(payload);
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
return request ? 'resolved' : 'not-found';
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/** Clears pending RTD requests when the RTD lifecycle ends. @internal */
|
|
334
|
+
public clearAllRtdRequests(): void {
|
|
335
|
+
Array.from(this.pendingRtdRequests.values()).forEach((request) => {
|
|
336
|
+
this.removeRtdRequest(request.rtdEventType, request.correlationId, (currentRequest) => {
|
|
337
|
+
currentRequest.reject(new Error('RTD request cleared'));
|
|
338
|
+
});
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
|
|
75
342
|
/**
|
|
76
343
|
* Sends an event to the AI Assistant service.
|
|
77
344
|
* @param agentId - agent identifier
|
|
@@ -89,7 +356,9 @@ export class ApiAIAssistant {
|
|
|
89
356
|
eventName: AIAssistantEventName,
|
|
90
357
|
eventMetaData?: Record<string, unknown>,
|
|
91
358
|
languageCode?: string,
|
|
92
|
-
trackingId?: string
|
|
359
|
+
trackingId?: string,
|
|
360
|
+
publishTimestamp?: number,
|
|
361
|
+
timeout?: number
|
|
93
362
|
): Promise<Record<string, unknown>> {
|
|
94
363
|
LoggerProxy.info('Sending event', {
|
|
95
364
|
module: CC_FILE,
|
|
@@ -105,23 +374,26 @@ export class ApiAIAssistant {
|
|
|
105
374
|
try {
|
|
106
375
|
const baseUrl = this.getBaseUrl();
|
|
107
376
|
const orgId = this.webex.credentials.getOrgId();
|
|
377
|
+
const data = {
|
|
378
|
+
...eventMetaData,
|
|
379
|
+
interactionId,
|
|
380
|
+
actionTimeStamp: String(Date.now()),
|
|
381
|
+
languageCode,
|
|
382
|
+
trackingId,
|
|
383
|
+
};
|
|
108
384
|
const response = (await this.webex.request({
|
|
109
385
|
uri: `${baseUrl}${AI_ASSISTANT_API_URLS.EVENT}`,
|
|
110
386
|
method: HTTP_METHODS.POST,
|
|
111
387
|
addAuthHeader: true,
|
|
388
|
+
...(timeout !== undefined ? {timeout} : {}),
|
|
112
389
|
body: {
|
|
113
390
|
agentId,
|
|
114
391
|
orgId,
|
|
115
392
|
eventType,
|
|
116
393
|
eventName,
|
|
394
|
+
...(publishTimestamp !== undefined ? {publishTimestamp} : {}),
|
|
117
395
|
eventDetails: {
|
|
118
|
-
data
|
|
119
|
-
...eventMetaData,
|
|
120
|
-
interactionId,
|
|
121
|
-
actionTimeStamp: String(Date.now()),
|
|
122
|
-
languageCode,
|
|
123
|
-
trackingId,
|
|
124
|
-
},
|
|
396
|
+
data,
|
|
125
397
|
},
|
|
126
398
|
},
|
|
127
399
|
})) as IHttpResponse;
|
|
@@ -365,6 +637,18 @@ export class ApiAIAssistant {
|
|
|
365
637
|
throw detailedError;
|
|
366
638
|
}
|
|
367
639
|
|
|
640
|
+
if (
|
|
641
|
+
!this.isValidTranscriptIdentifier(agentId) ||
|
|
642
|
+
!this.isValidTranscriptIdentifier(interactionId)
|
|
643
|
+
) {
|
|
644
|
+
const {error: detailedError} = getErrorDetails(
|
|
645
|
+
new Error('INVALID_AGENT_ID_OR_INTERACTION_ID'),
|
|
646
|
+
METHODS.FETCH_HISTORIC_TRANSCRIPTS,
|
|
647
|
+
CC_FILE
|
|
648
|
+
);
|
|
649
|
+
throw detailedError;
|
|
650
|
+
}
|
|
651
|
+
|
|
368
652
|
try {
|
|
369
653
|
const baseUrl = this.getBaseUrl();
|
|
370
654
|
const orgId = this.webex.credentials.getOrgId();
|
|
@@ -2,12 +2,40 @@ import {HTTP_METHODS, WebexSDK} from '../types';
|
|
|
2
2
|
import type {EntryPointRecord, EntryPointListResponse, EntryPointSearchParams} from '../types';
|
|
3
3
|
import LoggerProxy from '../logger-proxy';
|
|
4
4
|
import WebexRequest from './core/WebexRequest';
|
|
5
|
-
import
|
|
5
|
+
import {PAGINATION_DEFAULTS} from '../utils/PageCache';
|
|
6
6
|
import MetricsManager from '../metrics/MetricsManager';
|
|
7
7
|
import {WCC_API_GATEWAY} from './constants';
|
|
8
8
|
import {endPointMap} from './config/constants';
|
|
9
9
|
import {METRIC_EVENT_NAMES} from '../metrics/constants';
|
|
10
10
|
|
|
11
|
+
const DEFAULT_ENTRY_POINT_ATTRIBUTES = 'id,dialledNumber,entryPointId,entryPointName';
|
|
12
|
+
const DEFAULT_ENTRY_POINT_SORT_FIELD = 'entryPointName';
|
|
13
|
+
|
|
14
|
+
type DialNumberEntryPointRecord = {
|
|
15
|
+
id: string;
|
|
16
|
+
dialledNumber?: string;
|
|
17
|
+
entryPointId: string;
|
|
18
|
+
entryPointName: string;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const mergeEntryPointAttributes = (attributes?: string): string => {
|
|
22
|
+
const mergedAttributes = new Set(DEFAULT_ENTRY_POINT_ATTRIBUTES.split(','));
|
|
23
|
+
|
|
24
|
+
attributes
|
|
25
|
+
?.split(',')
|
|
26
|
+
.map((attribute) => attribute.trim())
|
|
27
|
+
.filter(Boolean)
|
|
28
|
+
.forEach((attribute) => mergedAttributes.add(attribute));
|
|
29
|
+
|
|
30
|
+
return Array.from(mergedAttributes).join(',');
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const mapDialNumberEntryPoint = (item: DialNumberEntryPointRecord): EntryPointRecord => ({
|
|
34
|
+
id: item.entryPointId,
|
|
35
|
+
name: item.entryPointName,
|
|
36
|
+
...(item.dialledNumber ? {number: item.dialledNumber} : {}),
|
|
37
|
+
});
|
|
38
|
+
|
|
11
39
|
/**
|
|
12
40
|
* EntryPoint class for managing Webex Contact Center entry points.
|
|
13
41
|
* Provides functionality to fetch, search, and paginate through entry points.
|
|
@@ -35,7 +63,7 @@ import {METRIC_EVENT_NAMES} from '../metrics/constants';
|
|
|
35
63
|
* });
|
|
36
64
|
*
|
|
37
65
|
* // Search for specific entry points
|
|
38
|
-
* const searchResults = await entryPointAPI.
|
|
66
|
+
* const searchResults = await entryPointAPI.getEntryPoints({
|
|
39
67
|
* search: 'support',
|
|
40
68
|
* filter: 'type=="voice"'
|
|
41
69
|
* });
|
|
@@ -46,9 +74,6 @@ export class EntryPoint {
|
|
|
46
74
|
private webex: WebexSDK;
|
|
47
75
|
private metricsManager: MetricsManager;
|
|
48
76
|
|
|
49
|
-
// Page cache using the common utility
|
|
50
|
-
private pageCache: PageCache<EntryPointRecord>;
|
|
51
|
-
|
|
52
77
|
/**
|
|
53
78
|
* Creates an instance of EntryPoint
|
|
54
79
|
* @param {WebexSDK} webex - The Webex SDK instance
|
|
@@ -57,19 +82,21 @@ export class EntryPoint {
|
|
|
57
82
|
constructor(webex: WebexSDK) {
|
|
58
83
|
this.webex = webex;
|
|
59
84
|
this.webexRequest = WebexRequest.getInstance({webex});
|
|
60
|
-
this.pageCache = new PageCache<EntryPointRecord>('EntryPoint');
|
|
61
85
|
this.metricsManager = MetricsManager.getInstance({webex});
|
|
62
86
|
}
|
|
63
87
|
|
|
64
88
|
/**
|
|
65
|
-
* Fetches entry
|
|
66
|
-
*
|
|
89
|
+
* Fetches entry-point dial-number mappings for the organization with pagination support. By
|
|
90
|
+
* default, returns the agent's desktop-profile-filtered mappings in backend entry-point-name order.
|
|
91
|
+
* Search, filter, attribute, and sort parameters can customize the request while desktop-profile
|
|
92
|
+
* scoping and required mapping fields remain SDK-owned.
|
|
93
|
+
* @param {EntryPointSearchParams} [params] - Search, pagination, and compatible override parameters.
|
|
67
94
|
* @returns {Promise<EntryPointListResponse>} Promise resolving to paginated entry points
|
|
68
95
|
* @throws {Error} If the API call fails
|
|
69
96
|
* @public
|
|
70
97
|
* @example
|
|
71
98
|
* ```typescript
|
|
72
|
-
* // Get first page
|
|
99
|
+
* // Get the first page using the default entry-point policy
|
|
73
100
|
* const response = await entryPointAPI.getEntryPoints();
|
|
74
101
|
*
|
|
75
102
|
* // Get specific page with custom page size
|
|
@@ -89,12 +116,14 @@ export class EntryPoint {
|
|
|
89
116
|
search,
|
|
90
117
|
filter,
|
|
91
118
|
attributes,
|
|
92
|
-
sortBy,
|
|
119
|
+
sortBy = 'name',
|
|
93
120
|
sortOrder = 'asc',
|
|
94
121
|
} = params;
|
|
95
122
|
|
|
96
123
|
const orgId = this.webex.credentials.getOrgId();
|
|
97
|
-
const
|
|
124
|
+
const hasCustomSort = sortBy !== 'name' || sortOrder !== 'asc';
|
|
125
|
+
const isSearchRequest = !!(search || filter || attributes || hasCustomSort);
|
|
126
|
+
const effectiveSortBy = sortBy === 'name' ? DEFAULT_ENTRY_POINT_SORT_FIELD : sortBy;
|
|
98
127
|
|
|
99
128
|
LoggerProxy.info(
|
|
100
129
|
`Fetching entry points - orgId: ${orgId}, page: ${page}, pageSize: ${pageSize}, isSearchRequest: ${isSearchRequest}`,
|
|
@@ -104,51 +133,24 @@ export class EntryPoint {
|
|
|
104
133
|
}
|
|
105
134
|
);
|
|
106
135
|
|
|
107
|
-
// Check if we can use cache for simple pagination (no search/filter/attributes/sort)
|
|
108
|
-
if (this.pageCache.canUseCache({search, filter, attributes, sortBy})) {
|
|
109
|
-
const cacheKey = this.pageCache.buildCacheKey(orgId, page, pageSize);
|
|
110
|
-
const cachedPage = this.pageCache.getCachedPage(cacheKey);
|
|
111
|
-
|
|
112
|
-
if (cachedPage) {
|
|
113
|
-
const duration = Date.now() - startTime;
|
|
114
|
-
|
|
115
|
-
LoggerProxy.log(
|
|
116
|
-
`Returning page ${page} from cache - cacheHit: true, duration: ${duration}ms, recordCount: ${cachedPage.data.length}, pageSize: ${pageSize}`,
|
|
117
|
-
{
|
|
118
|
-
module: 'EntryPoint',
|
|
119
|
-
method: 'getEntryPoints',
|
|
120
|
-
}
|
|
121
|
-
);
|
|
122
|
-
|
|
123
|
-
return {
|
|
124
|
-
data: cachedPage.data,
|
|
125
|
-
meta: {
|
|
126
|
-
page,
|
|
127
|
-
pageSize,
|
|
128
|
-
totalPages: cachedPage.totalMeta?.totalPages,
|
|
129
|
-
totalRecords: cachedPage.totalMeta?.totalRecords,
|
|
130
|
-
},
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// Start timing only for actual API calls (not cache hits)
|
|
136
136
|
this.metricsManager.timeEvent(METRIC_EVENT_NAMES.ENTRYPOINT_FETCH_SUCCESS);
|
|
137
137
|
|
|
138
138
|
try {
|
|
139
|
-
// Build query parameters
|
|
140
139
|
const queryParams = new URLSearchParams({
|
|
141
140
|
page: page.toString(),
|
|
142
141
|
pageSize: pageSize.toString(),
|
|
143
|
-
|
|
142
|
+
attributes: mergeEntryPointAttributes(attributes),
|
|
144
143
|
});
|
|
145
144
|
|
|
146
145
|
if (search) queryParams.append('search', search);
|
|
147
146
|
if (filter) queryParams.append('filter', filter);
|
|
148
|
-
if (
|
|
149
|
-
|
|
147
|
+
if (effectiveSortBy) {
|
|
148
|
+
queryParams.append('sort', `${effectiveSortBy},${sortOrder.toUpperCase()}`);
|
|
149
|
+
}
|
|
150
|
+
queryParams.append('desktopProfileFilter', 'true');
|
|
151
|
+
queryParams.append('includeEntryPointName', 'true');
|
|
150
152
|
|
|
151
|
-
const resource = endPointMap.
|
|
153
|
+
const resource = endPointMap.entryPointDialNumberList(orgId, queryParams.toString());
|
|
152
154
|
|
|
153
155
|
LoggerProxy.log(
|
|
154
156
|
`Making API request to fetch entry points - resource: ${resource}, service: ${WCC_API_GATEWAY}`,
|
|
@@ -162,12 +164,21 @@ export class EntryPoint {
|
|
|
162
164
|
service: WCC_API_GATEWAY,
|
|
163
165
|
resource,
|
|
164
166
|
method: HTTP_METHODS.GET,
|
|
167
|
+
headers: {
|
|
168
|
+
'X-ORGANIZATION-ID': orgId,
|
|
169
|
+
'x-ignore-internal-data': 'false',
|
|
170
|
+
},
|
|
165
171
|
});
|
|
166
172
|
|
|
173
|
+
const responseBody: EntryPointListResponse = {
|
|
174
|
+
...response.body,
|
|
175
|
+
data: (response.body?.data ?? []).map(mapDialNumberEntryPoint),
|
|
176
|
+
};
|
|
177
|
+
|
|
167
178
|
const duration = Date.now() - startTime;
|
|
168
179
|
|
|
169
|
-
const recordCount =
|
|
170
|
-
const totalRecords =
|
|
180
|
+
const recordCount = responseBody.data.length;
|
|
181
|
+
const totalRecords = responseBody.meta?.totalRecords;
|
|
171
182
|
|
|
172
183
|
LoggerProxy.log(`Successfully retrieved ${recordCount} entry points`, {
|
|
173
184
|
module: 'EntryPoint',
|
|
@@ -199,19 +210,7 @@ export class EntryPoint {
|
|
|
199
210
|
);
|
|
200
211
|
}
|
|
201
212
|
|
|
202
|
-
|
|
203
|
-
if (this.pageCache.canUseCache({search, filter, attributes, sortBy}) && response.body?.data) {
|
|
204
|
-
const cacheKey = this.pageCache.buildCacheKey(orgId, page, pageSize);
|
|
205
|
-
this.pageCache.cachePage(cacheKey, response.body.data, response.body.meta);
|
|
206
|
-
|
|
207
|
-
LoggerProxy.log('Cached entry points data for future requests', {
|
|
208
|
-
module: 'EntryPoint',
|
|
209
|
-
method: 'getEntryPoints',
|
|
210
|
-
data: {cacheKey, recordCount},
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
return response.body;
|
|
213
|
+
return responseBody;
|
|
215
214
|
} catch (error) {
|
|
216
215
|
const errorData = {
|
|
217
216
|
orgId,
|
package/src/services/Queue.ts
CHANGED
|
@@ -70,14 +70,16 @@ export class Queue {
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
/**
|
|
73
|
-
* Fetches contact service queues for the organization
|
|
74
|
-
*
|
|
73
|
+
* Fetches contact service queues for the organization. By default, returns active inbound
|
|
74
|
+
* telephony queues in backend name-ascending order using the agent's desktop profile views.
|
|
75
|
+
* Existing filter, sort, and desktop-profile parameters override those defaults.
|
|
76
|
+
* @param {ContactServiceQueueSearchParams} [params] - Search, pagination, and override parameters
|
|
75
77
|
* @returns {Promise<ContactServiceQueuesResponse>} Promise resolving to contact service queues
|
|
76
78
|
* @throws {Error} If the API call fails
|
|
77
79
|
* @public
|
|
78
80
|
* @example
|
|
79
81
|
* ```typescript
|
|
80
|
-
* // Get
|
|
82
|
+
* // Get queues using the default list policy and pagination
|
|
81
83
|
* const response = await queueAPI.getQueues();
|
|
82
84
|
*
|
|
83
85
|
* // Get queues with specific pagination
|
|
@@ -101,17 +103,29 @@ export class Queue {
|
|
|
101
103
|
page = PAGINATION_DEFAULTS.PAGE,
|
|
102
104
|
pageSize = PAGINATION_DEFAULTS.PAGE_SIZE,
|
|
103
105
|
search,
|
|
104
|
-
filter,
|
|
106
|
+
filter = 'queueType==INBOUND;channelType==TELEPHONY;active==true',
|
|
105
107
|
attributes,
|
|
106
|
-
sortBy,
|
|
107
|
-
sortOrder,
|
|
108
|
-
desktopProfileFilter,
|
|
108
|
+
sortBy = 'name',
|
|
109
|
+
sortOrder = 'asc',
|
|
110
|
+
desktopProfileFilter = true,
|
|
109
111
|
provisioningView,
|
|
110
112
|
singleObjectResponse,
|
|
111
113
|
} = params;
|
|
114
|
+
const agentView = desktopProfileFilter;
|
|
115
|
+
const firstLevelView = desktopProfileFilter;
|
|
112
116
|
|
|
113
117
|
const orgId = this.webex.credentials.getOrgId();
|
|
114
|
-
const
|
|
118
|
+
const effectiveSortBy = sortBy ?? (sortOrder ? 'name' : undefined);
|
|
119
|
+
const isSearchRequest = !!(search || filter || attributes || effectiveSortBy);
|
|
120
|
+
const canUseCache = this.pageCache.canUseCache({
|
|
121
|
+
search,
|
|
122
|
+
filter,
|
|
123
|
+
attributes,
|
|
124
|
+
sortBy: effectiveSortBy,
|
|
125
|
+
desktopProfileFilter,
|
|
126
|
+
provisioningView,
|
|
127
|
+
singleObjectResponse,
|
|
128
|
+
});
|
|
115
129
|
|
|
116
130
|
LoggerProxy.info('Fetching contact service queues', {
|
|
117
131
|
module: 'Queue',
|
|
@@ -125,7 +139,7 @@ export class Queue {
|
|
|
125
139
|
});
|
|
126
140
|
|
|
127
141
|
// Check if we can use cache for simple pagination (no search/filter/attributes/sort)
|
|
128
|
-
if (
|
|
142
|
+
if (canUseCache) {
|
|
129
143
|
const cacheKey = this.pageCache.buildCacheKey(orgId, page, pageSize);
|
|
130
144
|
const cachedPage = this.pageCache.getCachedPage(cacheKey);
|
|
131
145
|
|
|
@@ -170,14 +184,17 @@ export class Queue {
|
|
|
170
184
|
if (filter) queryParams.append('filter', filter);
|
|
171
185
|
if (attributes) queryParams.append('attributes', attributes);
|
|
172
186
|
if (search) queryParams.append('search', search);
|
|
173
|
-
if (
|
|
174
|
-
|
|
187
|
+
if (effectiveSortBy)
|
|
188
|
+
queryParams.append('sort', `${effectiveSortBy},${(sortOrder ?? 'asc').toUpperCase()}`);
|
|
175
189
|
if (desktopProfileFilter !== undefined)
|
|
176
190
|
queryParams.append('desktopProfileFilter', desktopProfileFilter.toString());
|
|
177
191
|
if (provisioningView !== undefined)
|
|
178
192
|
queryParams.append('provisioningView', provisioningView.toString());
|
|
179
193
|
if (singleObjectResponse !== undefined)
|
|
180
194
|
queryParams.append('singleObjectResponse', singleObjectResponse.toString());
|
|
195
|
+
if (agentView !== undefined) queryParams.append('agentView', agentView.toString());
|
|
196
|
+
if (firstLevelView !== undefined)
|
|
197
|
+
queryParams.append('firstLevelView', firstLevelView.toString());
|
|
181
198
|
|
|
182
199
|
const resource = endPointMap.queueList(orgId, queryParams.toString());
|
|
183
200
|
|
|
@@ -232,7 +249,7 @@ export class Queue {
|
|
|
232
249
|
}
|
|
233
250
|
|
|
234
251
|
// Cache the page data for simple pagination (no search/filter/attributes/sort)
|
|
235
|
-
if (
|
|
252
|
+
if (canUseCache && response.body?.data) {
|
|
236
253
|
const cacheKey = this.pageCache.buildCacheKey(orgId, page, pageSize);
|
|
237
254
|
this.pageCache.cachePage(cacheKey, response.body.data, response.body.meta);
|
|
238
255
|
|