@cognigy/rest-api-client
Version:
Cognigy REST-Client
828 lines • 31.6 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transferNode = void 0;
/** Custom Modules */
const createNodeDescriptor_1 = require("../../../createNodeDescriptor");
/** Helper Modules */
const transfer_mapper_1 = require("../../voice/mappers/transfer.mapper");
const design_1 = require("../utils/design");
const helper_1 = require("../utils/helper");
const customHeaderDefaultValue = "X-Custom-Header";
exports.transferNode = (0, createNodeDescriptor_1.createNodeDescriptor)({
type: "transfer",
defaultLabel: "Transfer",
preview: {
key: "transferTarget",
type: "text",
},
appearance: {
color: design_1.nodeColor,
},
tags: ["voice"],
fields: [
{
key: "transferType",
label: "UI__NODE_EDITOR__VOICEGATEWAY2__TRANSFER__FIELDS__TRANSFER_TYPE__LABEL",
type: "select",
params: {
options: [
{
label: "UI__NODE_EDITOR__VOICEGATEWAY2__TRANSFER__FIELDS__TRANSFER_TYPE__OPTIONS__REFER__LABEL",
value: "refer",
},
{
label: "UI__NODE_EDITOR__VOICEGATEWAY2__TRANSFER__FIELDS__TRANSFER_TYPE__OPTIONS__DIAL__LABEL",
value: "dial",
},
],
},
defaultValue: "refer",
description: "UI__NODE_EDITOR__VOICEGATEWAY2__TRANSFER__FIELDS__TRANSFER_TYPE__DESCRIPTION",
},
{
key: "transferTarget",
label: "UI__NODE_EDITOR__VOICEGATEWAY2__TRANSFER__FIELDS__TRANSFER_TARGET__LABEL",
type: "cognigyText",
params: {
required: true,
},
description: "UI__NODE_EDITOR__VOICEGATEWAY2__TRANSFER__FIELDS__TRANSFER_TARGET__DESCRIPTION",
defaultValue: "+49123456789",
},
{
key: "referredBy",
label: "UI__NODE_EDITOR__VOICEGATEWAY2__TRANSFER__FIELDS__REFERRED_BY__LABEL",
type: "cognigyText",
description: "UI__NODE_EDITOR__VOICEGATEWAY2__TRANSFER__FIELDS__REFERRED_BY__DESCRIPTION",
defaultValue: "",
condition: {
key: "transferType",
value: "refer"
}
},
{
key: "transferReason",
label: "UI__NODE_EDITOR__VOICEGATEWAY2__TRANSFER__FIELDS__TRANSFER_REASON__LABEL",
type: "cognigyText",
params: {
required: true,
},
description: "UI__NODE_EDITOR__VOICEGATEWAY2__TRANSFER__FIELDS__TRANSFER_REASON__DESCRIPTION",
defaultValue: "Bot initiated a transfer.",
},
{
key: "anchorMedia",
label: "UI__NODE_EDITOR__VOICEGATEWAY2__TRANSFER__FIELDS__ANCHOR_MEDIA__LABEL",
type: "toggle",
description: "UI__NODE_EDITOR__VOICEGATEWAY2__TRANSFER__FIELDS__ANCHOR_MEDIA__DESCRIPTION",
defaultValue: false,
condition: {
key: "transferType",
value: "dial"
}
},
{
key: "mediaPath",
label: "UI__NODE_EDITOR__VOICEGATEWAY2__TRANSFER__FIELDS__MEDIA_PATH__LABEL",
type: "select",
description: "UI__NODE_EDITOR__VOICEGATEWAY2__TRANSFER__FIELDS__MEDIA_PATH__DESCRIPTION",
defaultValue: "partialMedia",
params: {
options: [
{
label: "UI__NODE_EDITOR__VOICEGATEWAY2__TRANSFER__FIELDS__MEDIA_PATH__OPTIONS__FULL_MEDIA__LABEL",
value: "fullMedia"
},
{
label: "UI__NODE_EDITOR__VOICEGATEWAY2__TRANSFER__FIELDS__MEDIA_PATH__OPTIONS__PARTIAL_MEDIA__LABEL",
value: "partialMedia"
},
{
label: "UI__NODE_EDITOR__VOICEGATEWAY2__TRANSFER__FIELDS__MEDIA_PATH__OPTIONS__NO_MEDIA__LABEL",
value: "noMedia"
}
]
},
condition: {
key: "transferType",
value: "dial"
}
},
{
key: "useTransferSipHeaders",
label: "UI__NODE_EDITOR__VOICEGATEWAY2__TRANSFER__FIELDS__USE_TRANSFER_SIP_HEADERS__LABEL",
type: "toggle",
description: "UI__NODE_EDITOR__VOICEGATEWAY2__TRANSFER__FIELDS__USE_TRANSFER_SIP_HEADERS__DESCRIPTION",
defaultValue: false,
},
{
key: "transferSipHeaders",
label: "UI__NODE_EDITOR__VOICEGATEWAY2__TRANSFER__FIELDS__TRANSFER_SIP_HEADERS__LABEL",
type: "json",
description: "UI__NODE_EDITOR__VOICEGATEWAY2__TRANSFER__FIELDS__TRANSFER_SIP_HEADERS__DESCRIPTION",
defaultValue: {
[customHeaderDefaultValue]: "YourValue",
},
condition: {
key: "useTransferSipHeaders",
value: true,
},
},
/* Dial specific */
{
key: "dialCallerId",
label: "UI__NODE_EDITOR__TRANSFER__FIELDS__DIAL_CALLER_ID__LABEL",
type: "text",
description: "UI__NODE_EDITOR__TRANSFER__DIAL_CALLER_ID__DESCRIPTION",
condition: {
key: "transferType",
value: "dial"
}
},
{
key: "dialMusic",
label: "UI__NODE_EDITOR__TRANSFER__FIELDS__DIAL_MUSIC__LABEL",
type: "text",
description: "UI__NODE_EDITOR__TRANSFER__FIELDS__DIAL_MUSIC__DESCRIPTION",
condition: {
key: "transferType",
value: "dial"
}
},
{
key: "dialTranscriptionWebhook",
label: "UI__NODE_EDITOR__TRANSFER__FIELDS__DIAL_TRANSCRIPTION_WEBHOOK__LABEL",
type: "cognigyText",
description: "UI__NODE_EDITOR__TRANSFER__FIELDS__DIAL_TRANSCRIPTION_WEBHOOK__DESCRIPTION",
condition: {
key: "transferType",
value: "dial"
}
},
{
key: "sttLabel",
label: "UI__NODE_EDITOR__TRANSFER__FIELDS__DIAL_TRANSCRIPTION_STT_LABEL__LABEL",
type: "text",
description: "UI__NODE_EDITOR__TRANSFER__FIELDS__DIAL_TRANSCRIPTION_STT_LABEL__DESCRIPTION",
condition: {
key: "transferType",
value: "dial"
}
},
{
key: "dialTimeout",
label: "UI__NODE_EDITOR__TRANSFER__FIELDS__TIMEOUT__LABEL",
type: "number",
description: "UI__NODE_EDITOR__TRANSFER__FIELDS__TIMEOUT__DESCRIPTION",
condition: {
key: "transferType",
value: "dial"
},
defaultValue: 60,
params: {
min: 0,
max: 300
}
},
{
key: "enableTimeLimit",
label: "UI__NODE_EDITOR__TRANSFER__FIELDS__ENABLE_DURATION_LIMIT__LABEL",
type: "toggle",
description: "UI__NODE_EDITOR__TRANSFER__FIELDS__ENABLE_DURATION_LIMIT__DESCRIPTION",
condition: {
key: "transferType",
value: "dial"
},
defaultValue: false,
},
{
key: "timeLimit",
label: "UI__NODE_EDITOR__TRANSFER__FIELDS__DURATION_LIMIT__LABEL",
type: "number",
description: "UI__NODE_EDITOR__TRANSFER__FIELDS__DURATION_LIMIT__DESCRIPTION",
condition: {
and: [
{
key: "transferType",
value: "dial"
},
{
key: "enableTimeLimit",
value: true
},
]
},
defaultValue: 600,
params: {
max: 12000
}
},
{
key: "agentAssistEnabled",
label: "UI__NODE_EDITOR__TRANSFER__FIELDS__AGENT_ASSIST_ENABLED__LABEL",
type: "toggle",
description: "UI__NODE_EDITOR__TRANSFER__FIELDS__AGENT_ASSIST_ENABLED__DESCRIPTION",
defaultValue: false,
condition: {
key: "transferType",
value: "dial"
}
},
{
key: "agentAssistHeadersKey",
label: "UI__NODE_EDITOR__TRANSFER__FIELDS__AGENT_ASSIST_HEADERS_KEY__LABEL",
type: "cognigyText",
description: "UI__NODE_EDITOR__TRANSFER__FIELDS__AGENT_ASSIST_HEADERS_KEY__DESCRIPTION",
defaultValue: customHeaderDefaultValue,
condition: {
key: "agentAssistEnabled",
value: true
}
},
{
key: "amdEnabled",
label: "UI__NODE_EDITOR__TRANSFER__FIELDS__AMD_ENABLED__LABEL",
type: "toggle",
description: "UI__NODE_EDITOR__TRANSFER__FIELDS__AMD_ENABLED__DESCRIPTION",
defaultValue: false,
condition: {
key: "transferType",
value: "dial"
}
},
{
key: "amdRedirectOnMachineDetected",
label: "UI__NODE_EDITOR__TRANSFER__FIELDS__AMD_REDIRECT_ON_MACHINE_DETECTED__LABEL",
type: "toggle",
description: "UI__NODE_EDITOR__TRANSFER__FIELDS__AMD_REDIRECT_ON_MACHINE_DETECTED__DESCRIPTION",
defaultValue: false,
condition: {
key: "amdEnabled",
value: true
}
},
{
key: "amdRedirectText",
label: "UI__NODE_EDITOR__TRANSFER__FIELDS__AMD_REDIRECT_TEXT__LABEL",
type: "cognigyText",
description: "UI__NODE_EDITOR__TRANSFER__FIELDS__AMD_REDIRECT_TEXT__DESCRIPTION",
defaultValue: "",
condition: {
and: [
{
key: "amdEnabled",
value: true
},
{
key: "amdRedirectOnMachineDetected",
value: true
}
]
}
},
{
key: "recognitionChannel",
label: "UI__NODE_EDITOR__TRANSFER__FIELDS__RECOGNITION_CHANNEL__LABEL",
type: "select",
params: {
options: [
{
label: "UI__NODE_EDITOR__TRANSFER__FIELDS__RECOGNITION_CHANNEL__OPTIONS__CALLER__LABEL",
value: 1
},
{
label: "UI__NODE_EDITOR__TRANSFER__FIELDS__RECOGNITION_CHANNEL__OPTIONS__CALLED__LABEL",
value: 2
},
{
label: "UI__NODE_EDITOR__TRANSFER__FIELDS__RECOGNITION_CHANNEL__OPTIONS__BOTH__LABEL",
value: 0
}
]
},
defaultValue: 0,
description: "UI__NODE_EDITOR__TRANSFER__FIELDS__RECOGNITION_CHANNEL__DESCRIPTION",
condition: {
key: "transferType",
value: "dial"
}
},
{
key: "sttVendor",
type: "sttSelect",
label: "_unused_",
description: "_unused_",
defaultValue: "",
params: {
languageKey: "config.sttLanguage",
modelKey: "config.sttModel"
},
condition: {
key: "transferType",
value: "dial"
}
},
{
key: "sttModel",
type: "sttSelect",
label: "_unused_",
description: "_unused_",
defaultValue: "nova-2",
condition: {
key: "sttVendor",
value: "deepgram"
}
},
{
key: "sttLanguage",
type: "sttSelect",
label: "_unused_",
description: "_unused_",
defaultValue: "",
},
{
key: "sttDisablePunctuation",
type: "toggle",
label: "UI__NODE_EDITOR__VOICEGATEWAY2__SET_SESSION_CONFIG__STT_DISABLE_PUNCTUATION__LABEL",
description: "UI__NODE_EDITOR__VOICEGATEWAY2__SET_SESSION_CONFIG__STT_DISABLE_PUNCTUATION__DESCRIPTION",
defaultValue: false,
condition: {
or: [
{
key: "sttVendor",
value: "google"
},
{
key: "sttVendor",
value: "deepgram"
}
]
}
},
{
key: "deepgramEndpointing",
type: "toggle",
label: "UI__NODE_EDITOR__VOICEGATEWAY2__SET_SESSION_CONFIG__DEEPGRAM_ENDPOINTING__LABEL",
description: "UI__NODE_EDITOR__VOICEGATEWAY2__SET_SESSION_CONFIG__DEEPGRAM_ENDPOINTING__DESCRIPTION",
defaultValue: false,
condition: {
key: "sttVendor",
value: "deepgram"
}
},
{
key: "deepgramEndpointingValue",
type: "number",
label: "UI__NODE_EDITOR__VOICEGATEWAY2__SET_SESSION_CONFIG__DEEPGRAM_ENDPOINTING_TIME__LABEL",
description: "UI__NODE_EDITOR__VOICEGATEWAY2__SET_SESSION_CONFIG__DEEPGRAM_ENDPOINTING_TIME__DESCRIPTION",
defaultValue: 1000,
params: {
min: 10,
max: 1000
},
condition: {
and: [
{
key: "sttVendor",
value: "deepgram"
},
{
key: "deepgramEndpointing",
value: true
},
]
}
},
{
key: "deepgramSmartFormatting",
type: "toggle",
label: "UI__NODE_EDITOR__VOICEGATEWAY2__SET_SESSION_CONFIG__DEEPGRAM_SMART_FORMATTING__LABEL",
description: "UI__NODE_EDITOR__VOICEGATEWAY2__SET_SESSION_CONFIG__DEEPGRAM_SMART_FORMATTING__DESCRIPTION",
defaultValue: false,
condition: {
key: "sttVendor",
value: "deepgram"
}
},
{
key: "deepgramfluxEndpointing",
type: "toggle",
label: "UI__NODE_EDITOR__VOICEGATEWAY2__SET_SESSION_CONFIG__DEEPGRAMFLUX_ENDPOINTING__LABEL",
description: "UI__NODE_EDITOR__VOICEGATEWAY2__SET_SESSION_CONFIG__DEEPGRAMFLUX_ENDPOINTING__DESCRIPTION",
defaultValue: false,
condition: {
key: "sttVendor",
value: "deepgramflux"
}
},
{
key: "deepgramfluxEndOfTurnThreshold",
type: "slider",
label: "UI__NODE_EDITOR__VOICEGATEWAY2__SET_SESSION_CONFIG__DEEPGRAMFLUX_END_OF_TURN_THRESHOLD__LABEL",
description: "UI__NODE_EDITOR__VOICEGATEWAY2__SET_SESSION_CONFIG__DEEPGRAMFLUX_END_OF_TURN_THRESHOLD__DESCRIPTION",
defaultValue: 0.7,
params: {
min: 0.5,
max: 0.9,
step: 0.1
},
condition: {
and: [
{
key: "sttVendor",
value: "deepgramflux"
},
{
key: "deepgramfluxEndpointing",
value: true
},
]
}
},
{
key: "deepgramfluxEndOfTurnTimeoutMs",
type: "number",
label: "UI__NODE_EDITOR__VOICEGATEWAY2__SET_SESSION_CONFIG__DEEPGRAMFLUX_END_OF_TURN_TIMEOUT_MS__LABEL",
description: "UI__NODE_EDITOR__VOICEGATEWAY2__SET_SESSION_CONFIG__DEEPGRAMFLUX_END_OF_TURN_TIMEOUT_MS__DESCRIPTION",
defaultValue: 5000,
params: {
min: 500,
max: 10000
},
condition: {
and: [
{
key: "sttVendor",
value: "deepgramflux"
},
{
key: "deepgramfluxEndpointing",
value: true
},
]
}
},
{
key: "speechmaticsEndpointing",
type: "toggle",
label: "UI__NODE_EDITOR__VOICEGATEWAY2__SET_SESSION_CONFIG__SPEECHMATICS_ENDPOINTING__LABEL",
description: "UI__NODE_EDITOR__VOICEGATEWAY2__SET_SESSION_CONFIG__SPEECHMATICS_ENDPOINTING__DESCRIPTION",
defaultValue: true,
condition: {
key: "sttVendor",
value: "speechmatics"
}
},
{
key: "speechmaticsEndpointingValue",
type: "number",
label: "UI__NODE_EDITOR__VOICEGATEWAY2__SET_SESSION_CONFIG__SPEECHMATICS_ENDPOINTING_TIME__LABEL",
description: "UI__NODE_EDITOR__VOICEGATEWAY2__SET_SESSION_CONFIG__SPEECHMATICS_ENDPOINTING_TIME__DESCRIPTION",
defaultValue: 500,
params: {
min: 10,
max: 5000
},
condition: {
and: [
{
key: "sttVendor",
value: "speechmatics"
},
{
key: "speechmaticsEndpointing",
value: true
},
]
}
},
{
key: "openaiEndpointing",
type: "toggle",
label: "UI__NODE_EDITOR__VOICEGATEWAY2__SET_SESSION_CONFIG__OPENAI_ENDPOINTING__LABEL",
description: "UI__NODE_EDITOR__VOICEGATEWAY2__SET_SESSION_CONFIG__OPENAI_ENDPOINTING__DESCRIPTION",
defaultValue: true,
condition: {
key: "sttVendor",
value: "openai"
}
},
{
key: "openaiEndpointingValue",
type: "number",
label: "UI__NODE_EDITOR__VOICEGATEWAY2__SET_SESSION_CONFIG__OPENAI_ENDPOINTING_TIME__LABEL",
description: "UI__NODE_EDITOR__VOICEGATEWAY2__SET_SESSION_CONFIG__OPENAI_ENDPOINTING_TIME__DESCRIPTION",
defaultValue: 500,
params: {
min: 10,
max: 1000
},
condition: {
and: [
{
key: "sttVendor",
value: "openai"
},
{
key: "openaiEndpointing",
value: true
},
]
}
},
{
key: "niceEndpointing",
type: "toggle",
label: "UI__NODE_EDITOR__VOICEGATEWAY2__SET_SESSION_CONFIG__NICE_ENDPOINTING__LABEL",
description: "UI__NODE_EDITOR__VOICEGATEWAY2__SET_SESSION_CONFIG__NICE_ENDPOINTING__DESCRIPTION",
defaultValue: true,
condition: {
key: "sttVendor",
value: "nice"
}
},
{
key: "niceEndpointingValue",
type: "number",
label: "UI__NODE_EDITOR__VOICEGATEWAY2__SET_SESSION_CONFIG__NICE_ENDPOINTING_TIME__LABEL",
description: "UI__NODE_EDITOR__VOICEGATEWAY2__SET_SESSION_CONFIG__NICE_ENDPOINTING_TIME__DESCRIPTION",
defaultValue: 250,
params: {
min: 10,
max: 1000
},
condition: {
and: [
{
key: "sttVendor",
value: "nice"
},
{
key: "niceEndpointing",
value: true
},
]
}
},
{
key: "googleModel",
type: "select",
label: "UI__NODE_EDITOR__GOOGLE_MODEL__LABEL",
description: "UI__NODE_EDITOR__GOOGLE_MODEL__DESCRIPTION",
defaultValue: "latest_short",
condition: {
key: "sttVendor",
value: "google"
},
params: {
options: [
{
label: "UI__NODE_EDITOR__GOOGLE_MODEL__OPTIONS__LATEST_SHORT__LABEL",
value: "latest_short"
},
{
label: "UI__NODE_EDITOR__GOOGLE_MODEL__OPTIONS__LATEST_LONG__LABEL",
value: "latest_long"
},
{
label: "UI__NODE_EDITOR__GOOGLE_MODEL__OPTIONS__COMMAND_AND_SEARCH__LABEL",
value: "command_and_search"
},
{
label: "UI__NODE_EDITOR__GOOGLE_MODEL__OPTIONS__PHONE_CALL__LABEL",
value: "phone_call"
},
{
label: "UI__NODE_EDITOR__GOOGLE_MODEL__OPTIONS__VIDEO__LABEL",
value: "video"
},
{
label: "UI__NODE_EDITOR__GOOGLE_MODEL__OPTIONS__MEDICAL_DICTATION__LABEL",
value: "medical_dictation"
},
{
label: "UI__NODE_EDITOR__GOOGLE_MODEL__OPTIONS__MEDICAL_CONVERSATION__LABEL",
value: "medical_conversation"
},
{
label: "UI__NODE_EDITOR__GOOGLE_MODEL__OPTIONS__DEFAULT__CUSTOM",
value: "custom",
},
{
label: "UI__NODE_EDITOR__GOOGLE_MODEL__OPTIONS__DEFAULT__LABEL",
value: "default"
}
]
}
},
{
key: "googleModelCustom",
label: "UI__NODE_EDITOR__GOOGLE_MODEL_CUSTOM__LABEL",
type: "cognigyText",
defaultValue: "",
condition: {
key: "googleModel",
value: "custom"
}
},
],
sections: [
{
key: "transcribe",
label: "UI__NODE_EDITOR__VOICEGATEWAY2__TRANSFER__FIELDS__TRANSCRIBE__LABEL",
defaultCollapsed: true,
fields: [
"sttVendor",
"sttLabel",
"sttDisablePunctuation",
"deepgramEndpointing",
"deepgramEndpointingValue",
"deepgramSmartFormatting",
"deepgramfluxEndpointing",
"deepgramfluxEndOfTurnThreshold",
"deepgramfluxEndOfTurnTimeoutMs",
"speechmaticsEndpointing",
"speechmaticsEndpointingValue",
"openaiEndpointing",
"openaiEndpointingValue",
"niceEndpointing",
"niceEndpointingValue",
"googleModel",
"googleModelCustom",
"dialTranscriptionWebhook",
"recognitionChannel"
],
condition: {
key: "transferType",
value: "dial"
}
},
{
key: "amd",
label: "UI__NODE_EDITOR__VOICEGATEWAY2__TRANSFER__FIELDS__AMD__LABEL",
defaultCollapsed: true,
fields: ["amdEnabled", "amdRedirectOnMachineDetected", "amdRedirectText"],
condition: {
key: "transferType",
value: "dial"
}
},
{
key: "advanced",
label: "UI__NODE_EDITOR__VOICEGATEWAY2__TRANSFER__FIELDS__ADVANCED__LABEL",
defaultCollapsed: true,
fields: [
"referredBy",
process.env.FEATURE_DISABLE_VG_MEDIA_PATH === "true" ? "anchorMedia" : "mediaPath",
"useTransferSipHeaders",
"transferSipHeaders",
"enableAnsweringMachineDetection"
]
}
],
form: [
{
type: "field",
key: "transferType"
},
{
type: "field",
key: "transferReason"
},
{
type: "field",
key: "transferTarget"
},
{
type: "field",
key: "dialCallerId"
},
{
type: "field",
key: "dialMusic"
},
{
type: "field",
key: "dialTimeout"
},
{
type: "field",
key: "enableTimeLimit"
},
{
type: "field",
key: "timeLimit"
},
{
type: "field",
key: "agentAssistEnabled"
},
{
type: "field",
key: "agentAssistHeadersKey"
},
{
type: "section",
key: "transcribe"
},
{
type: "section",
key: "amd"
},
{
type: "section",
key: "advanced"
}
],
summary: "UI__NODE_EDITOR__VOICEGATEWAY2__TRANSFER__SUMMARY",
function: async ({ cognigy, config, }) => {
const { api, input } = cognigy;
const { transferType, transferTarget, referredBy, mediaPath, useTransferSipHeaders, transferSipHeaders = {}, transferReason, dialMusic, dialTranscriptionWebhook, dialCallerId, recognitionChannel, sttVendor, sttLanguage, sttDisablePunctuation, dialTimeout, enableTimeLimit, timeLimit, amdEnabled, amdRedirectOnMachineDetected, amdRedirectText, sttLabel, sttModel, deepgramEndpointing, deepgramEndpointingValue, deepgramSmartFormatting, deepgramfluxEndpointing, deepgramfluxEndOfTurnThreshold, deepgramfluxEndOfTurnTimeoutMs, speechmaticsEndpointing, speechmaticsEndpointingValue, openaiEndpointing, openaiEndpointingValue, niceEndpointing, niceEndpointingValue, agentAssistEnabled, agentAssistHeadersKey = customHeaderDefaultValue, anchorMedia } = config;
const transferParams = {
transferType,
transferReason,
transferTarget,
referredBy,
useTransferSipHeaders,
transferSipHeaders,
dialMusic,
dialCallerId,
dialTranscriptionWebhook,
amdEnabled,
amdRedirectOnMachineDetected,
amdRedirectText,
dialTimeout,
timeLimit,
sttLabel,
};
let media = mediaPath;
try {
if (input.channel === "adminconsole") {
let textWarningAdminChannel = "Transferring a call is not supported in the Interaction Panel, please use the VoiceGateway endpoint.";
if (agentAssistEnabled && !dialTranscriptionWebhook) {
textWarningAdminChannel = `${textWarningAdminChannel + "\n"} Copilot is enabled but no transcription webhook is configured. Please configure a transcription webhook in the Transfer node.`;
}
await api.say(textWarningAdminChannel, null);
return;
}
if (!enableTimeLimit) {
delete transferParams.timeLimit;
}
if (transferType === "dial" && typeof anchorMedia === "boolean" && (mediaPath === null || mediaPath === undefined) && process.env.FEATURE_DISABLE_VG_MEDIA_PATH === "false") {
if (anchorMedia) {
media = "fullMedia";
}
else {
media = "partialMedia";
}
}
if (config.googleModel === "custom") {
config.googleModel = config.googleModelCustom;
}
if (agentAssistEnabled && dialTranscriptionWebhook) {
try {
const agentAssistConfigId = api.getAgentAssistConfigId();
const params = {
sessionId: input.sessionId,
userId: input.userId,
webhookUrl: dialTranscriptionWebhook,
agentAssistConfigId: agentAssistConfigId,
};
if ((!params.agentAssistConfigId || params.agentAssistConfigId === 'none')) {
delete params.agentAssistConfigId;
}
const uui = (0, helper_1.buildUUIValue)(params);
if (!(~dialTranscriptionWebhook.indexOf("userId") && ~dialTranscriptionWebhook.indexOf("sessionId"))) {
transferParams.dialTranscriptionWebhook = `${dialTranscriptionWebhook}?userId=${input.userId}&sessionId=${input.sessionId}`;
}
api.addToInput("UUIValue", uui);
/* As soon as Copilot enabled, we enable SIP Headers and remove the X-Custom-Header */
if (!useTransferSipHeaders) {
transferParams.useTransferSipHeaders = true;
delete transferSipHeaders["X-Custom-Header"];
}
transferSipHeaders[agentAssistHeadersKey] = uui;
}
catch (error) {
api.log("error", "Error on Copilot configuration: " + error.message);
}
}
if (useTransferSipHeaders &&
transferSipHeaders &&
!(0, helper_1.isValidJSON)(transferSipHeaders)) {
delete transferParams.transferSipHeaders;
transferParams.useTransferSipHeaders = false;
api.log("error", "Invalid JSON in Transfer SIP Headers");
}
const payload = transfer_mapper_1.transfer.handleInput("voiceGateway2", transferParams, false, recognitionChannel, sttVendor, sttLanguage, config.googleModel, sttModel, sttDisablePunctuation, deepgramEndpointing, deepgramEndpointingValue, deepgramSmartFormatting, deepgramfluxEndpointing, deepgramfluxEndOfTurnThreshold, deepgramfluxEndOfTurnTimeoutMs, speechmaticsEndpointing, speechmaticsEndpointingValue, openaiEndpointing, openaiEndpointingValue, niceEndpointing, niceEndpointingValue, media, anchorMedia);
await api.say(null, {
_cognigy: payload,
});
api.logDebugMessage(`${transferType} UI__DEBUG_MODE__TRANSFER__MESSAGE ${transferTarget}`);
}
catch (error) {
throw new Error(`Error on Transfer node type: ${transferType}. Error message: ${error.message}`);
}
},
});
//# sourceMappingURL=transfer.js.map