@webex/contact-center 3.12.0-next.73 → 3.12.0-next.75
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/AGENTS.md +438 -0
- package/ai-docs/README.md +131 -0
- package/ai-docs/RULES.md +455 -0
- package/ai-docs/patterns/event-driven-patterns.md +485 -0
- package/ai-docs/patterns/testing-patterns.md +480 -0
- package/ai-docs/patterns/typescript-patterns.md +365 -0
- package/ai-docs/templates/README.md +102 -0
- package/ai-docs/templates/documentation/create-agents-md.md +240 -0
- package/ai-docs/templates/documentation/create-architecture-md.md +295 -0
- package/ai-docs/templates/existing-service/bug-fix.md +254 -0
- package/ai-docs/templates/existing-service/feature-enhancement.md +450 -0
- package/ai-docs/templates/new-method/00-master.md +80 -0
- package/ai-docs/templates/new-method/01-requirements.md +232 -0
- package/ai-docs/templates/new-method/02-implementation.md +295 -0
- package/ai-docs/templates/new-method/03-tests.md +201 -0
- package/ai-docs/templates/new-method/04-validation.md +141 -0
- package/ai-docs/templates/new-service/00-master.md +109 -0
- package/ai-docs/templates/new-service/01-pre-questions.md +159 -0
- package/ai-docs/templates/new-service/02-code-generation.md +346 -0
- package/ai-docs/templates/new-service/03-integration.md +178 -0
- package/ai-docs/templates/new-service/04-test-generation.md +205 -0
- package/ai-docs/templates/new-service/05-validation.md +145 -0
- package/dist/cc.js +53 -38
- package/dist/cc.js.map +1 -1
- package/dist/config.js +6 -0
- package/dist/config.js.map +1 -1
- package/dist/constants.js +14 -1
- package/dist/constants.js.map +1 -1
- package/dist/index.js +13 -5
- package/dist/index.js.map +1 -1
- package/dist/metrics/behavioral-events.js +26 -0
- package/dist/metrics/behavioral-events.js.map +1 -1
- package/dist/metrics/constants.js +9 -3
- package/dist/metrics/constants.js.map +1 -1
- package/dist/services/ApiAiAssistant.js +74 -3
- package/dist/services/ApiAiAssistant.js.map +1 -1
- package/dist/services/config/Util.js +2 -2
- package/dist/services/config/Util.js.map +1 -1
- package/dist/services/config/types.js +25 -9
- package/dist/services/config/types.js.map +1 -1
- package/dist/services/core/Utils.js +74 -27
- package/dist/services/core/Utils.js.map +1 -1
- package/dist/services/core/websocket/WebSocketManager.js +2 -1
- package/dist/services/core/websocket/WebSocketManager.js.map +1 -1
- package/dist/services/core/websocket/types.js.map +1 -1
- package/dist/services/index.js +1 -1
- package/dist/services/index.js.map +1 -1
- package/dist/services/task/Task.js +688 -0
- package/dist/services/task/Task.js.map +1 -0
- package/dist/services/task/TaskFactory.js +45 -0
- package/dist/services/task/TaskFactory.js.map +1 -0
- package/dist/services/task/TaskManager.js +725 -612
- package/dist/services/task/TaskManager.js.map +1 -1
- package/dist/services/task/TaskUtils.js +162 -26
- package/dist/services/task/TaskUtils.js.map +1 -1
- package/dist/services/task/constants.js +6 -1
- package/dist/services/task/constants.js.map +1 -1
- package/dist/services/task/digital/Digital.js +77 -0
- package/dist/services/task/digital/Digital.js.map +1 -0
- package/dist/services/task/state-machine/TaskStateMachine.js +837 -0
- package/dist/services/task/state-machine/TaskStateMachine.js.map +1 -0
- package/dist/services/task/state-machine/actions.js +543 -0
- package/dist/services/task/state-machine/actions.js.map +1 -0
- package/dist/services/task/state-machine/constants.js +161 -0
- package/dist/services/task/state-machine/constants.js.map +1 -0
- package/dist/services/task/state-machine/guards.js +340 -0
- package/dist/services/task/state-machine/guards.js.map +1 -0
- package/dist/services/task/state-machine/index.js +53 -0
- package/dist/services/task/state-machine/index.js.map +1 -0
- package/dist/services/task/state-machine/types.js +54 -0
- package/dist/services/task/state-machine/types.js.map +1 -0
- package/dist/services/task/state-machine/uiControlsComputer.js +553 -0
- package/dist/services/task/state-machine/uiControlsComputer.js.map +1 -0
- package/dist/services/task/taskDataNormalizer.js +99 -0
- package/dist/services/task/taskDataNormalizer.js.map +1 -0
- package/dist/services/task/types.js +168 -16
- package/dist/services/task/types.js.map +1 -1
- package/dist/services/task/voice/Voice.js +1042 -0
- package/dist/services/task/voice/Voice.js.map +1 -0
- package/dist/services/task/voice/WebRTC.js +149 -0
- package/dist/services/task/voice/WebRTC.js.map +1 -0
- package/dist/types/cc.d.ts +19 -18
- package/dist/types/config.d.ts +6 -0
- package/dist/types/constants.d.ts +14 -1
- package/dist/types/index.d.ts +11 -5
- package/dist/types/metrics/constants.d.ts +7 -1
- package/dist/types/services/ApiAiAssistant.d.ts +11 -3
- package/dist/types/services/config/types.d.ts +113 -9
- package/dist/types/services/core/Utils.d.ts +23 -10
- package/dist/types/services/core/websocket/WebSocketManager.d.ts +1 -0
- package/dist/types/services/core/websocket/types.d.ts +1 -1
- package/dist/types/services/index.d.ts +1 -1
- package/dist/types/services/task/Task.d.ts +157 -0
- package/dist/types/services/task/TaskFactory.d.ts +12 -0
- package/dist/types/services/task/TaskUtils.d.ts +46 -2
- package/dist/types/services/task/constants.d.ts +5 -0
- package/dist/types/services/task/digital/Digital.d.ts +22 -0
- package/dist/types/services/task/state-machine/TaskStateMachine.d.ts +1144 -0
- package/dist/types/services/task/state-machine/actions.d.ts +10 -0
- package/dist/types/services/task/state-machine/constants.d.ts +107 -0
- package/dist/types/services/task/state-machine/guards.d.ts +90 -0
- package/dist/types/services/task/state-machine/index.d.ts +13 -0
- package/dist/types/services/task/state-machine/types.d.ts +267 -0
- package/dist/types/services/task/state-machine/uiControlsComputer.d.ts +9 -0
- package/dist/types/services/task/taskDataNormalizer.d.ts +10 -0
- package/dist/types/services/task/types.d.ts +551 -78
- package/dist/types/services/task/voice/Voice.d.ts +184 -0
- package/dist/types/services/task/voice/WebRTC.d.ts +53 -0
- package/dist/types/types.d.ts +92 -0
- package/dist/types/webex.d.ts +1 -0
- package/dist/types.js +85 -0
- package/dist/types.js.map +1 -1
- package/dist/webex.js +14 -2
- package/dist/webex.js.map +1 -1
- package/package.json +15 -12
- package/src/cc.ts +63 -43
- package/src/config.ts +6 -0
- package/src/constants.ts +14 -1
- package/src/index.ts +14 -5
- package/src/metrics/ai-docs/AGENTS.md +348 -0
- package/src/metrics/ai-docs/ARCHITECTURE.md +336 -0
- package/src/metrics/behavioral-events.ts +28 -0
- package/src/metrics/constants.ts +9 -4
- package/src/services/ApiAiAssistant.ts +104 -3
- package/src/services/agent/ai-docs/AGENTS.md +238 -0
- package/src/services/agent/ai-docs/ARCHITECTURE.md +302 -0
- package/src/services/ai-docs/AGENTS.md +384 -0
- package/src/services/config/Util.ts +2 -2
- package/src/services/config/ai-docs/AGENTS.md +253 -0
- package/src/services/config/ai-docs/ARCHITECTURE.md +424 -0
- package/src/services/config/types.ts +116 -10
- package/src/services/core/Utils.ts +85 -34
- package/src/services/core/ai-docs/AGENTS.md +379 -0
- package/src/services/core/ai-docs/ARCHITECTURE.md +696 -0
- package/src/services/core/websocket/WebSocketManager.ts +2 -0
- package/src/services/core/websocket/types.ts +1 -1
- package/src/services/index.ts +1 -1
- package/src/services/task/Task.ts +837 -0
- package/src/services/task/TaskFactory.ts +55 -0
- package/src/services/task/TaskManager.ts +738 -697
- package/src/services/task/TaskUtils.ts +205 -25
- package/src/services/task/ai-docs/AGENTS.md +455 -0
- package/src/services/task/ai-docs/ARCHITECTURE.md +585 -0
- package/src/services/task/constants.ts +5 -0
- package/src/services/task/digital/Digital.ts +95 -0
- package/src/services/task/state-machine/TaskStateMachine.ts +1077 -0
- package/src/services/task/state-machine/actions.ts +685 -0
- package/src/services/task/state-machine/ai-docs/AGENTS.md +495 -0
- package/src/services/task/state-machine/ai-docs/ARCHITECTURE.md +1135 -0
- package/src/services/task/state-machine/constants.ts +172 -0
- package/src/services/task/state-machine/guards.ts +406 -0
- package/src/services/task/state-machine/index.ts +28 -0
- package/src/services/task/state-machine/types.ts +241 -0
- package/src/services/task/state-machine/uiControlsComputer.ts +867 -0
- package/src/services/task/taskDataNormalizer.ts +137 -0
- package/src/services/task/types.ts +654 -85
- package/src/services/task/voice/Voice.ts +1267 -0
- package/src/services/task/voice/WebRTC.ts +187 -0
- package/src/types.ts +112 -1
- package/src/utils/AGENTS.md +276 -0
- package/src/webex.js +2 -0
- package/test/unit/spec/cc.ts +133 -3
- package/test/unit/spec/logger-proxy.ts +70 -0
- package/test/unit/spec/services/ApiAiAssistant.ts +122 -17
- package/test/unit/spec/services/WebCallingService.ts +7 -1
- package/test/unit/spec/services/config/index.ts +27 -27
- package/test/unit/spec/services/core/Utils.ts +335 -1
- package/test/unit/spec/services/core/websocket/WebSocketManager.ts +66 -40
- package/test/unit/spec/services/task/AutoWrapup.ts +63 -0
- package/test/unit/spec/services/task/Task.ts +477 -0
- package/test/unit/spec/services/task/TaskFactory.ts +62 -0
- package/test/unit/spec/services/task/TaskManager.ts +821 -1936
- package/test/unit/spec/services/task/TaskUtils.ts +206 -0
- package/test/unit/spec/services/task/digital/Digital.ts +105 -0
- package/test/unit/spec/services/task/state-machine/TaskStateMachine.ts +1825 -0
- package/test/unit/spec/services/task/state-machine/guards.ts +479 -0
- package/test/unit/spec/services/task/state-machine/types.ts +18 -0
- package/test/unit/spec/services/task/state-machine/uiControlsComputer.ts +2020 -0
- package/test/unit/spec/services/task/taskTestUtils.ts +87 -0
- package/test/unit/spec/services/task/voice/Voice.ts +631 -0
- package/test/unit/spec/services/task/voice/WebRTC.ts +235 -0
- package/umd/contact-center.min.js +2 -2
- package/umd/contact-center.min.js.map +1 -1
- package/dist/services/task/index.js +0 -1530
- package/dist/services/task/index.js.map +0 -1
- package/dist/types/services/task/index.d.ts +0 -650
- package/src/services/task/index.ts +0 -1806
- package/test/unit/spec/services/task/index.ts +0 -2205
|
@@ -1,8 +1,135 @@
|
|
|
1
1
|
/* eslint-disable import/prefer-default-export */
|
|
2
2
|
import {Interaction, ITask, TaskData, MEDIA_CHANNEL} from './types';
|
|
3
|
-
import {CC_EVENTS} from '../config/types';
|
|
4
|
-
import {OUTDIAL_DIRECTION, OUTDIAL_MEDIA_TYPE, OUTBOUND_TYPE} from '../../constants';
|
|
5
3
|
import {LoginOption} from '../../types';
|
|
4
|
+
import {PARTICIPANT_TYPE, MEDIA_TYPE_MAIN_CALL} from './state-machine/constants';
|
|
5
|
+
import {TaskContext} from './state-machine/types';
|
|
6
|
+
import {CC_EVENTS} from '../config/types';
|
|
7
|
+
import {OUTBOUND_TYPE, OUTDIAL_DIRECTION, OUTDIAL_MEDIA_TYPE} from '../../constants';
|
|
8
|
+
|
|
9
|
+
const CAMPAIGN_PREVIEW_OUTBOUND_TYPES = ['STANDARD_PREVIEW_CAMPAIGN', 'DIRECT_PREVIEW_CAMPAIGN'];
|
|
10
|
+
const CAMPAIGN_PREVIEW_CAMPAIGN_TYPES = ['preview_standard', 'preview_direct'];
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Checks if the customer is still in the call (not left)
|
|
14
|
+
*
|
|
15
|
+
* @param interaction - The interaction object
|
|
16
|
+
* @param interactionId - The main interaction ID
|
|
17
|
+
* @returns true if customer is in the call
|
|
18
|
+
*/
|
|
19
|
+
export const getIsCustomerInCall = (interaction: Interaction, interactionId: string): boolean => {
|
|
20
|
+
const mainCallMedia = interaction.media?.[interactionId];
|
|
21
|
+
const participants = interaction.participants;
|
|
22
|
+
if (!mainCallMedia?.participants || !participants) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return mainCallMedia.participants.some((participantId: string) => {
|
|
27
|
+
const participant = participants[participantId];
|
|
28
|
+
|
|
29
|
+
return participant?.pType === PARTICIPANT_TYPE.CUSTOMER && !participant.hasLeft;
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Gets the count of active agent participants in the conference
|
|
35
|
+
* Excludes Customer, Supervisor, and VVA participant types
|
|
36
|
+
*
|
|
37
|
+
* @param interaction - The interaction object
|
|
38
|
+
* @param interactionId - The main interaction ID
|
|
39
|
+
* @returns Number of active agent participants
|
|
40
|
+
*/
|
|
41
|
+
export const getConferenceParticipantsCount = (
|
|
42
|
+
interaction: Interaction,
|
|
43
|
+
interactionId: string
|
|
44
|
+
): number => {
|
|
45
|
+
const mainCallMedia = interaction.media?.[interactionId];
|
|
46
|
+
const participants = interaction.participants;
|
|
47
|
+
if (!mainCallMedia?.participants || !participants) {
|
|
48
|
+
return 0;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
let count = 0;
|
|
52
|
+
for (const participantId of mainCallMedia.participants) {
|
|
53
|
+
const participant = participants[participantId];
|
|
54
|
+
if (
|
|
55
|
+
participant &&
|
|
56
|
+
participant.pType !== PARTICIPANT_TYPE.CUSTOMER &&
|
|
57
|
+
participant.pType !== PARTICIPANT_TYPE.SUPERVISOR &&
|
|
58
|
+
participant.pType !== PARTICIPANT_TYPE.VVA &&
|
|
59
|
+
!participant.hasLeft
|
|
60
|
+
) {
|
|
61
|
+
count += 1;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return count;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Determines if a consult is actively in-progress for conference control gating.
|
|
70
|
+
* This is used to disable conference controls (End/Consult) only when a consult leg
|
|
71
|
+
* still exists outside the main call participants.
|
|
72
|
+
*/
|
|
73
|
+
export const getIsConsultInProgressForConferenceControls = (
|
|
74
|
+
interaction: Interaction | undefined,
|
|
75
|
+
mainCallId: string | undefined,
|
|
76
|
+
selfAgentId: string | undefined
|
|
77
|
+
): boolean => {
|
|
78
|
+
if (!interaction || !mainCallId) return false;
|
|
79
|
+
|
|
80
|
+
const mainParticipants = interaction.media?.[mainCallId]?.participants;
|
|
81
|
+
if (!Array.isArray(mainParticipants) || mainParticipants.length === 0) return false;
|
|
82
|
+
|
|
83
|
+
const mainSet = new Set(mainParticipants);
|
|
84
|
+
const media = interaction.media;
|
|
85
|
+
if (!media) return false;
|
|
86
|
+
|
|
87
|
+
return Object.values(media).some((m: any) => {
|
|
88
|
+
if (!m || m.mType !== 'consult') return false;
|
|
89
|
+
if (!Array.isArray(m.participants) || m.participants.length === 0) return false;
|
|
90
|
+
|
|
91
|
+
return m.participants.some((participantId: string) => {
|
|
92
|
+
const p: any = interaction.participants?.[participantId];
|
|
93
|
+
if (!p || p.hasLeft) return false;
|
|
94
|
+
if (selfAgentId && participantId === selfAgentId) return false;
|
|
95
|
+
|
|
96
|
+
const consultState = p.consultState as string | undefined;
|
|
97
|
+
const isRonaPendingConsultee = consultState === 'consultReserved' && p.hasJoined === false;
|
|
98
|
+
const consultLegActive =
|
|
99
|
+
consultState === 'consulting' ||
|
|
100
|
+
p.currentState === 'consulting' ||
|
|
101
|
+
(p.isConsulted === true && consultState !== 'consultCompleted' && !isRonaPendingConsultee);
|
|
102
|
+
|
|
103
|
+
return consultLegActive && !mainSet.has(participantId);
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
export const getIsConsultedAgentForControls = (
|
|
109
|
+
taskData: TaskData | null,
|
|
110
|
+
context: TaskContext,
|
|
111
|
+
isConsultingState: boolean
|
|
112
|
+
): boolean => {
|
|
113
|
+
return Boolean(taskData?.isConsulted) || (isConsultingState && !context.consultInitiator);
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export const getServerHoldStateForControls = (
|
|
117
|
+
context: TaskContext,
|
|
118
|
+
mainCallId?: string,
|
|
119
|
+
fallbackTaskData?: TaskData | null
|
|
120
|
+
): boolean | undefined => {
|
|
121
|
+
const media = context.taskData?.interaction?.media ?? fallbackTaskData?.interaction?.media;
|
|
122
|
+
if (!media) return undefined;
|
|
123
|
+
|
|
124
|
+
if (mainCallId && media[mainCallId]) {
|
|
125
|
+
return media[mainCallId].isHold ?? false;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const mediaId = context.taskData?.mediaResourceId ?? fallbackTaskData?.mediaResourceId;
|
|
129
|
+
if (!mediaId) return undefined;
|
|
130
|
+
|
|
131
|
+
return media[mediaId]?.isHold;
|
|
132
|
+
};
|
|
6
133
|
|
|
7
134
|
/**
|
|
8
135
|
* Determines if the given agent is the primary agent (owner) of the task
|
|
@@ -32,7 +159,9 @@ export const isParticipantInMainInteraction = (task: ITask, agentId: string): bo
|
|
|
32
159
|
|
|
33
160
|
return Object.values(task.data.interaction.media).some(
|
|
34
161
|
(mediaObj) =>
|
|
35
|
-
mediaObj &&
|
|
162
|
+
mediaObj &&
|
|
163
|
+
mediaObj.mType === MEDIA_TYPE_MAIN_CALL &&
|
|
164
|
+
mediaObj.participants?.includes(agentId)
|
|
36
165
|
);
|
|
37
166
|
};
|
|
38
167
|
|
|
@@ -56,29 +185,33 @@ export const checkParticipantNotInInteraction = (task: ITask, agentId: string):
|
|
|
56
185
|
|
|
57
186
|
/**
|
|
58
187
|
* Determines if a conference is currently in progress based on the number of active agent participants
|
|
59
|
-
* @param
|
|
188
|
+
* @param data - The task data to check for conference status
|
|
60
189
|
* @returns true if there are 2 or more active agent participants in the main call, false otherwise
|
|
190
|
+
*
|
|
191
|
+
* For Agent B (consulted agent), their task's interactionId may be different from the main call.
|
|
192
|
+
* We use mainInteractionId from the interaction if available, otherwise fallback to interactionId.
|
|
61
193
|
*/
|
|
62
194
|
export const getIsConferenceInProgress = (data: TaskData): boolean => {
|
|
63
|
-
|
|
195
|
+
if (!data.interaction) return false;
|
|
196
|
+
|
|
197
|
+
const mainCallId = data.interaction.mainInteractionId || data.interactionId;
|
|
198
|
+
const mediaMainCall = data.interaction.media?.[mainCallId];
|
|
64
199
|
const participantsInMainCall = new Set(mediaMainCall?.participants);
|
|
65
|
-
const participants = data.interaction
|
|
200
|
+
const {participants} = data.interaction;
|
|
66
201
|
|
|
67
202
|
const agentParticipants = new Set();
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
)
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
});
|
|
81
|
-
}
|
|
203
|
+
participantsInMainCall.forEach((participantId: string) => {
|
|
204
|
+
const participant = participants[participantId];
|
|
205
|
+
if (
|
|
206
|
+
participant &&
|
|
207
|
+
participant.pType !== PARTICIPANT_TYPE.CUSTOMER &&
|
|
208
|
+
participant.pType !== PARTICIPANT_TYPE.SUPERVISOR &&
|
|
209
|
+
participant.pType !== PARTICIPANT_TYPE.VVA &&
|
|
210
|
+
!participant.hasLeft
|
|
211
|
+
) {
|
|
212
|
+
agentParticipants.add(participantId);
|
|
213
|
+
}
|
|
214
|
+
});
|
|
82
215
|
|
|
83
216
|
return agentParticipants.size >= 2;
|
|
84
217
|
};
|
|
@@ -104,17 +237,30 @@ export const isSecondaryAgent = (interaction: Interaction): boolean => {
|
|
|
104
237
|
/**
|
|
105
238
|
* Checks if the current agent is a secondary EP-DN (Entry Point Dial Number) agent.
|
|
106
239
|
* This is specifically for telephony consultations to external numbers/entry points.
|
|
107
|
-
* @param
|
|
240
|
+
* @param interaction - The interaction object
|
|
108
241
|
* @returns true if this is a secondary EP-DN agent in telephony consultation, false otherwise
|
|
109
242
|
*/
|
|
110
243
|
export const isSecondaryEpDnAgent = (interaction: Interaction): boolean => {
|
|
111
|
-
if (!interaction) {
|
|
112
|
-
return false;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
244
|
return interaction.mediaType === 'telephony' && isSecondaryAgent(interaction);
|
|
116
245
|
};
|
|
117
246
|
|
|
247
|
+
/**
|
|
248
|
+
* Checks if the task belongs to a campaign preview interaction.
|
|
249
|
+
* Campaign preview ContactEnded events are terminal cleanup events and should not trigger wrapup.
|
|
250
|
+
*/
|
|
251
|
+
export const isCampaignPreviewTask = (taskData?: TaskData | null): boolean => {
|
|
252
|
+
const outboundType = taskData?.interaction?.outboundType ?? '';
|
|
253
|
+
const cpd = taskData?.interaction?.callProcessingDetails as unknown as
|
|
254
|
+
| Record<string, string | undefined>
|
|
255
|
+
| undefined;
|
|
256
|
+
const campaignType = cpd?.campaignType ?? '';
|
|
257
|
+
|
|
258
|
+
return (
|
|
259
|
+
CAMPAIGN_PREVIEW_OUTBOUND_TYPES.includes(outboundType) ||
|
|
260
|
+
CAMPAIGN_PREVIEW_CAMPAIGN_TYPES.includes(campaignType)
|
|
261
|
+
);
|
|
262
|
+
};
|
|
263
|
+
|
|
118
264
|
/**
|
|
119
265
|
* Checks if auto-answer is enabled for the agent participant
|
|
120
266
|
* @param interaction - The interaction object
|
|
@@ -221,6 +367,40 @@ export const shouldAutoAnswerTask = (
|
|
|
221
367
|
return false;
|
|
222
368
|
};
|
|
223
369
|
|
|
370
|
+
/**
|
|
371
|
+
* Gets the consult media resource ID for switch-call operations.
|
|
372
|
+
* Searches for the consult media leg in the interaction.
|
|
373
|
+
*
|
|
374
|
+
* @param interaction - The interaction object
|
|
375
|
+
* @param consultMediaResourceId - The consult media resource ID from task data
|
|
376
|
+
* @param agentId - Current agent ID
|
|
377
|
+
* @returns The consult media resource ID or undefined
|
|
378
|
+
*/
|
|
379
|
+
export const getConsultMediaResourceId = (
|
|
380
|
+
interaction: Interaction | undefined,
|
|
381
|
+
consultMediaResourceId: string | undefined,
|
|
382
|
+
agentId: string | undefined
|
|
383
|
+
): string | undefined => {
|
|
384
|
+
// First priority: use consultMediaResourceId from task data if available
|
|
385
|
+
if (consultMediaResourceId) {
|
|
386
|
+
return consultMediaResourceId;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
// Second priority: search for consult media leg in interaction.media
|
|
390
|
+
if (!interaction?.media || !agentId) {
|
|
391
|
+
return undefined;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
// Find the consult media leg where this agent is a participant
|
|
395
|
+
for (const [mediaId, media] of Object.entries(interaction.media)) {
|
|
396
|
+
if (media.mType === 'consult' && media.participants?.includes(agentId)) {
|
|
397
|
+
return mediaId;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
return undefined;
|
|
402
|
+
};
|
|
403
|
+
|
|
224
404
|
/**
|
|
225
405
|
* Checks if a task is a campaign preview reservation that has not yet been accepted.
|
|
226
406
|
* Campaign preview tasks should not trigger incoming call handling until the agent
|