1async addParticipant(contact, call, isBlindTransfer) {
2....
3....
4 let transferCall = await this.createVoiceCall(parentCall.callId, Constants.CALL_TYPE.TRANSFER, parentCall.phoneNumber, additionalFields);
5....
6....
7....
8....
9if (this.state?.flowConfig?.isUnifiedRoutingEnabled) {
10
11
12 /* This block display integration of new Route voice call API for Transfer to Queue/Transfer to agent use case. */
13 if (flowConfig.useRouteFlowApi) {
14 const routePayload = { routingTarget: transferTo };
15 await this.routeVoiceCall(voiceCallIdOrVendorKey, routePayload);
16 } else {
17/* This block display integration of existing ExecuteOmniflow API for Transfer to Queue/Transfer to agent use case. */
18 const callInfoData = { transferTo, voiceCallId: voiceCallIdOrVendorKey };
19 const flowConfigData = { dialedNumber: flowConfig.dialedNumber };
20 await this.executeOmniFlowForUnifiedRouting(callInfoData, flowConfigData);
21 }
22
23}
24....
25....
26 /**
27 * Route a voice call to an Agent, Queue, or Flow.
28 * @param {string} voiceCallId - VoiceCall Identifier for which routing needs to be executed
29 * @param {Object} requestBody - Route request
30 * @param {string} requestBody.routingTarget - Agent ID, Queue ID, or Flow ID to route to
31 * @param {string} [requestBody.fallbackQueue] - Fallback queue ID
32 * @param {Object.<string, string>} [requestBody.flowInputParameters] - Input parameters for Flow
33 * @returns {Promise<{status: string}>} RouteVoiceCallResponse with status (success or exception message)
34 */
35 async routeVoiceCall(voiceCallId, requestBody) {
36 if (!voiceCallId) {
37 return Promise.reject(new Error('voiceCallId is required for routeVoiceCall'));
38 }
39 const { routingTarget, fallbackQueue, flowInputParameters } = requestBody || {};
40 if (!routingTarget) {
41 return Promise.reject(new Error('routingTarget is required for routeVoiceCall'));
42 }
43 const body = { routingTarget };
44 if (fallbackQueue != null) body.fallbackQueue = fallbackQueue;
45 if (flowInputParameters != null) body.flowInputParameters = flowInputParameters;
46
47 const response = await fetch('/api/voiceCalls/' + encodeURIComponent(voiceCallId), {
48 method: 'PATCH',
49 headers: { 'Content-Type': 'application/json' },
50 body: JSON.stringify(body)
51 });
52 const data = await response.json().catch(() => ({}));
53 if (!response.ok) {
54 return Promise.reject(new Error(data.status || data.message || response.statusText));
55 }
56 return data;
57 }