@cognigy/rest-api-client
Version:
Cognigy REST-Client
537 lines • 19.6 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getParamSections = exports.getParameterFields = exports.compileParams = void 0;
/**
* Compile the active parameters from the config
* @param config Node Config
* @param compiledParams Compiled Parameters Object
*/
const compileParams = (config, compiledParams) => {
const EXCLUDEDKEYS = ["activityParams", "text", "setActivityParams", "sttContextBoostAzure", "sttContextBoost", "azureUseContextPhrases"];
Object.keys(config).forEach((key) => {
var _a;
if (EXCLUDEDKEYS.indexOf(key) === -1) {
if (!key.startsWith("dtmfCollect") || (key.startsWith("dtmfCollect") && config["dtmfCollect"])) {
switch (typeof config[key]) {
case "object":
if (Array.isArray(config[key]) && config[key].length > 0) {
switch (key) {
case "sttContextPhrasesAzure":
if (config["azureUseContextPhrases"] === true) {
compiledParams['sttSpeechContexts'] = [{
"phrases": config[key],
"boost": config["sttContextBoostAzure"] || 0
}];
}
break;
case "sttContextPhrases":
if (!config["azureUseContextPhrases"]) {
compiledParams['sttSpeechContexts'] = [{
"phrases": config[key],
"boost": config["sttContextBoost"] || 0
}];
}
break;
default:
compiledParams[key] = config[key];
}
}
break;
case "number":
case "string":
if (config[key] || ((_a = config[key]) === null || _a === void 0 ? void 0 : _a.toString()) === '0')
compiledParams[key] = config[key];
break;
case "boolean":
compiledParams[key] = config[key];
break;
default:
}
}
}
});
};
exports.compileParams = compileParams;
/**
* All necessary fields for the voiceGateway parameters
* @param condition Node Field Condition to hide fields or not, optional
*/
const getParameterFields = () => [
{
key: "azureSpeechRecognitionMode",
type: "select",
label: "UI__NODE_EDITOR__VOICEGATEWAY__AZURE_SPEECH_RECOGNITION_MODE__LABEL",
description: "UI__NODE_EDITOR__VOICEGATEWAY__AZURE_SPEECH_RECOGNITION_MODE__DESCRIPTION",
defaultValue: "",
params: {
options: [
{ label: "UI__NODE_EDITOR__VOICEGATEWAY__AZURE_SPEECH_RECOGNITION_MODE__OPTIONS__CONVERSATION__LABEL", value: "" },
{ label: "UI__NODE_EDITOR__VOICEGATEWAY__AZURE_SPEECH_RECOGNITION_MODE__OPTIONS__DICTATION__LABEL", value: "dictation" },
{ label: "UI__NODE_EDITOR__VOICEGATEWAY__AZURE_SPEECH_RECOGNITION_MODE__OPTIONS__INTERACTIVE__LABEL", value: "interactive" },
]
}
},
{
key: "azureUseContextPhrases",
type: "toggle",
label: "UI__NODE_EDITOR__VOICEGATEWAY__AZURE_USE_CONTEXT_PHRASES__LABEL",
description: "UI__NODE_EDITOR__VOICEGATEWAY__AZURE_USE_CONTEXT_PHRASES__DESCRIPTION",
defaultValue: false,
},
{
key: "sttContextId",
type: "cognigyText",
label: "UI__NODE_EDITOR__VOICEGATEWAY__STT_CONTEXT_ID__LABEL",
description: "UI__NODE_EDITOR__VOICEGATEWAY__STT_CONTEXT_ID__DESCRIPTION",
defaultValue: ""
},
{
key: "ttsDeploymentId",
type: "cognigyText",
label: "UI__NODE_EDITOR__VOICEGATEWAY__TTS_DEPLOYMENT_ID__LABEL",
description: "UI__NODE_EDITOR__VOICEGATEWAY__TTS_DEPLOYMENT_ID__DESCRIPTION",
defaultValue: ""
},
{
key: "azureEnableAudioLogging",
type: "toggle",
label: "UI__NODE_EDITOR__VOICEGATEWAY__AZURE_ENABLE_AUDIO_LOGGING__LABEL",
description: "UI__NODE_EDITOR__VOICEGATEWAY__AZURE_ENABLE_AUDIO_LOGGING__DESCRIPTION",
defaultValue: false,
},
{
key: "sttContextPhrasesAzure",
type: "textArray",
label: "UI__NODE_EDITOR__VOICEGATEWAY__STT_CONTEXT_PHRASES_AZURE__LABEL",
description: "UI__NODE_EDITOR__VOICEGATEWAY__STT_CONTEXT_PHRASES_AZURE__DESCRIPTION",
defaultValue: [""],
condition: {
key: "azureUseContextPhrases",
value: true
}
},
{
key: "bargeIn",
type: "toggle",
label: "UI__NODE_EDITOR__VOICEGATEWAY__BARGE_IN__LABEL",
description: "UI__NODE_EDITOR__VOICEGATEWAY__BARGE_IN__DESCRIPTION",
defaultValue: false,
},
{
key: "bargeInOnDTMF",
type: "toggle",
label: "UI__NODE_EDITOR__VOICEGATEWAY__BARGE_IN_ON_DTMF__LABEL",
description: "UI__NODE_EDITOR__VOICEGATEWAY__BARGE_IN_ON_DTMF__DESCRIPTION",
defaultValue: false,
},
{
key: "bargeInMinWordCount",
type: "slider",
label: "UI__NODE_EDITOR__VOICEGATEWAY__BARGE_IN_MIN_WORD_COUNT__LABEL",
description: "UI__NODE_EDITOR__VOICEGATEWAY__BARGE_IN_MIN_WORD_COUNT__DESCRIPTION",
defaultValue: 1,
params: {
min: 1,
max: 5,
step: 1,
},
},
{
key: "botFailOnErrors",
type: "toggle",
label: "UI__NODE_EDITOR__VOICEGATEWAY__BOT_FAIL_ON_ERRORS__LABEL",
description: "UI__NODE_EDITOR__VOICEGATEWAY__BOT_FAIL_ON_ERRORS__DESCRIPTION",
defaultValue: false,
},
{
key: "botNoInputGiveUpTimeoutMS",
type: "number",
label: "UI__NODE_EDITOR__VOICEGATEWAY__BOT_NO_INPUT_GIVE_UP_TIMEOUT_MS__LABEL",
description: "UI__NODE_EDITOR__VOICEGATEWAY__BOT_NO_INPUT_GIVE_UP_TIMEOUT_MS__DESCRIPTION",
defaultValue: 0,
},
{
key: "botNoInputTimeoutMS",
type: "number",
label: "UI__NODE_EDITOR__VOICEGATEWAY__BOT_NO_INPUT_TIMEOUT_MS__LABEL",
description: "UI__NODE_EDITOR__VOICEGATEWAY__BOT_NO_INPUT_TIMEOUT_MS__DESCRIPTION",
defaultValue: 0,
},
{
key: "botNoInputRetries",
type: "number",
label: "UI__NODE_EDITOR__VOICEGATEWAY__BOT_NO_INPUT_RETRIES__LABEL",
description: "UI__NODE_EDITOR__VOICEGATEWAY__BOT_NO_INPUT_RETRIES__DESCRIPTION",
defaultValue: 0,
},
{
key: "botNoInputSpeech",
type: "cognigyText",
label: "UI__NODE_EDITOR__VOICEGATEWAY__BOT_NO_INPUT_SPEECH__LABEL",
description: "UI__NODE_EDITOR__VOICEGATEWAY__BOT_NO_INPUT_SPEECH__DESCRIPTION",
defaultValue: "",
},
{
key: "botNoInputUrl",
type: "cognigyText",
label: "UI__NODE_EDITOR__VOICEGATEWAY__BOT_NO_INPUT_URL__LABEL",
description: "UI__NODE_EDITOR__VOICEGATEWAY__BOT_NO_INPUT_URL__DESCRIPTION",
defaultValue: "",
},
{
key: "userNoInputTimeoutMS",
type: "number",
label: "UI__NODE_EDITOR__VOICEGATEWAY__USER_NO_INPUT_TIMEOUT_MS__LABEL",
description: "UI__NODE_EDITOR__VOICEGATEWAY__USER_NO_INPUT_TIMEOUT_MS__DESCRIPTION",
defaultValue: 0,
},
{
key: "userNoInputRetries",
type: "number",
label: "UI__NODE_EDITOR__VOICEGATEWAY__USER_NO_INPUT_RETRIES__LABEL",
description: "UI__NODE_EDITOR__VOICEGATEWAY__USER_NO_INPUT_RETRIES__DESCRIPTION",
defaultValue: 0,
params: {
min: 0,
max: 999
}
},
{
key: "userNoInputSendEvent",
type: "toggle",
label: "UI__NODE_EDITOR__VOICEGATEWAY__USER_NO_INPUT_SEND_EVENT__LABEL",
description: "UI__NODE_EDITOR__VOICEGATEWAY__USER_NO_INPUT_SEND_EVENT__DESCRIPTION",
defaultValue: false,
},
{
key: "userNoInputAutoHangup",
type: "toggle",
label: "UI__NODE_EDITOR__VOICEGATEWAY__USER_NO_INPUT_AUTO_HANGUP__LABEL",
description: "UI__NODE_EDITOR__VOICEGATEWAY__USER_NO_INPUT_AUTO_HANGUP__DESCRIPTION",
defaultValue: false,
condition: {
key: "userNoInputSendEvent",
value: true
}
},
{
key: "userNoInputSpeech",
type: "cognigyText",
label: "UI__NODE_EDITOR__VOICEGATEWAY__USER_NO_INPUT_SPEECH__LABEL",
description: "UI__NODE_EDITOR__VOICEGATEWAY__USER_NO_INPUT_SPEECH__DESCRIPTION",
defaultValue: "",
},
{
key: "userNoInputUrl",
type: "cognigyText",
label: "UI__NODE_EDITOR__VOICEGATEWAY__USER_NO_INPUT_URL__LABEL",
description: "UI__NODE_EDITOR__VOICEGATEWAY__USER_NO_INPUT_URL__DESCRIPTION",
defaultValue: "",
condition: {
key: "userNoInputSpeech",
value: ""
}
},
{
key: "continuousASR",
type: "toggle",
label: "UI__NODE_EDITOR__VOICEGATEWAY__CONTINUOUS_ASR__LABEL",
description: "UI__NODE_EDITOR__VOICEGATEWAY__CONTINUOUS_ASR__DESCRIPTION",
defaultValue: false,
},
{
key: "continuousASRDigits",
type: "cognigyText",
label: "UI__NODE_EDITOR__VOICEGATEWAY__CONTINUOUS_ASR_DIGITS__LABEL",
description: "UI__NODE_EDITOR__VOICEGATEWAY__CONTINUOUS_ASR_DIGITS__DESCRIPTION",
defaultValue: "",
condition: {
key: "continuousASR",
value: true
}
},
{
key: "continuousASRTimeoutInMS",
type: "number",
label: "UI__NODE_EDITOR__VOICEGATEWAY__CONTINUOUS_ASR_TIMEOUT_IN_MS__LABEL",
description: "UI__NODE_EDITOR__VOICEGATEWAY__CONTINUOUS_ASR_TIMEOUT_IN_MS__DESCRIPTION",
defaultValue: 3000,
condition: {
key: "continuousASR",
value: true
},
params: {
min: 500,
max: 60000
}
},
{
key: "disableTtsCache",
type: "toggle",
label: "UI__NODE_EDITOR__VOICEGATEWAY__DISABLE_TTS_CACHE__LABEL",
description: "UI__NODE_EDITOR__VOICEGATEWAY__DISABLE_TTS_CACHE__DESCRIPTION",
defaultValue: false,
},
{
key: "googleInteractionType",
type: "select",
label: "UI__NODE_EDITOR__VOICEGATEWAY__GOOGLE_INTERACTION_TYPE__LABEL",
description: "UI__NODE_EDITOR__VOICEGATEWAY__GOOGLE_INTERACTION_TYPE__DESCRIPTION",
defaultValue: "",
params: {
options: [
{ label: "UI__NODE_EDITOR__VOICEGATEWAY__GOOGLE_INTERACTION_TYPE__OPTIONS__INTERACTION_TYPE_UNSPECIFIED__LABEL", value: "" },
{ label: "UI__NODE_EDITOR__VOICEGATEWAY__GOOGLE_INTERACTION_TYPE__OPTIONS__DISCUSSION__LABEL", value: "DISCUSSION" },
{ label: "UI__NODE_EDITOR__VOICEGATEWAY__GOOGLE_INTERACTION_TYPE__OPTIONS__PRESENTATION__LABEL", value: "PRESENTATION" },
{ label: "UI__NODE_EDITOR__VOICEGATEWAY__GOOGLE_INTERACTION_TYPE__OPTIONS__PHONE_CALL__LABEL", value: "PHONE_CALL" },
{ label: "UI__NODE_EDITOR__VOICEGATEWAY__GOOGLE_INTERACTION_TYPE__OPTIONS__VOICEMAIL__LABEL", value: "VOICEMAIL" },
{ label: "UI__NODE_EDITOR__VOICEGATEWAY__GOOGLE_INTERACTION_TYPE__OPTIONS__PROFESSIONALLY_PRODUCED__LABEL", value: "PROFESSIONALLY_PRODUCED" },
{ label: "UI__NODE_EDITOR__VOICEGATEWAY__GOOGLE_INTERACTION_TYPE__OPTIONS__VOICE_SEARCH__LABEL", value: "VOICE_SEARCH" },
{ label: "UI__NODE_EDITOR__VOICEGATEWAY__GOOGLE_INTERACTION_TYPE__OPTIONS__VOICE_COMMAND__LABEL", value: "VOICE_COMMAND" },
{ label: "UI__NODE_EDITOR__VOICEGATEWAY__GOOGLE_INTERACTION_TYPE__OPTIONS__DICTATION__LABEL", value: "DICTATION" }
]
}
},
{
key: "language",
type: "cognigyText",
label: "UI__NODE_EDITOR__VOICEGATEWAY__LANGUAGE__LABEL",
description: "UI__NODE_EDITOR__VOICEGATEWAY__LANGUAGE__DESCRIPTION",
defaultValue: "",
},
{
key: "sendDTMF",
type: "toggle",
label: "UI__NODE_EDITOR__VOICEGATEWAY__SEND_DTMF__LABEL",
description: "UI__NODE_EDITOR__VOICEGATEWAY__SEND_DTMF__DESCRIPTION",
defaultValue: false,
},
{
key: "dtmfCollect",
type: "toggle",
label: "UI__NODE_EDITOR__VOICEGATEWAY__DTMF_COLLECT__LABEL",
description: "UI__NODE_EDITOR__VOICEGATEWAY__DTMF_COLLECT__DESCRIPTION",
defaultValue: false,
condition: {
key: "sendDTMF",
value: true
}
},
{
key: "dtmfCollectInterDigitTimeoutMS",
type: "number",
label: "UI__NODE_EDITOR__VOICEGATEWAY__DTMF_COLLECT_INTER_DIGIT_TIMEOUT_MS__LABEL",
description: "UI__NODE_EDITOR__VOICEGATEWAY__DTMF_COLLECT_INTER_DIGIT_TIMEOUT_MS__DESCRIPTION",
defaultValue: 2000,
condition: {
key: "dtmfCollect",
value: true
}
},
{
key: "dtmfCollectMaxDigits",
type: "number",
label: "UI__NODE_EDITOR__VOICEGATEWAY__DTMF_COLLECT_MAX_DIGITS__LABEL",
description: "UI__NODE_EDITOR__VOICEGATEWAY__DTMF_COLLECT_MAX_DIGITS__DESCRIPTION",
defaultValue: 5,
condition: {
key: "dtmfCollect",
value: true
},
params: {
min: 1
}
},
{
key: "dtmfCollectSubmitDigit",
type: "cognigyText",
label: "UI__NODE_EDITOR__VOICEGATEWAY__DTMF_COLLECT_SUBMIT_DIGIT__LABEL",
description: "UI__NODE_EDITOR__VOICEGATEWAY__DTMF_COLLECT_SUBMIT_DIGIT__DESCRIPTION",
defaultValue: "#",
condition: {
key: "dtmfCollect",
value: true
}
},
{
key: "sttContextGoogleDesc",
type: "description",
label: "UI__NODE_EDITOR__VOICEGATEWAY__STT_CONTEXT_GOOGLE_DESC__LABEL",
params: {
text: "UI__NODE_EDITOR__VOICEGATEWAY__STT_CONTEXT_GOOGLE_DESC__PARAMS__TEXT"
},
condition: {
key: "azureUseContextPhrases",
value: true
}
},
{
key: "sttContextPhrases",
type: "textArray",
label: "UI__NODE_EDITOR__VOICEGATEWAY__STT_CONTEXT_PHRASES__LABEL",
description: "UI__NODE_EDITOR__VOICEGATEWAY__STT_CONTEXT_PHRASES__DESCRIPTION",
defaultValue: [""]
},
{
key: "sttContextBoost",
type: "number",
label: "UI__NODE_EDITOR__VOICEGATEWAY__STT_CONTEXT_BOOST__LABEL",
description: "UI__NODE_EDITOR__VOICEGATEWAY__STT_CONTEXT_BOOST__DESCRIPTION",
defaultValue: 2
},
{
key: "sttContextBoostAzure",
type: "number",
label: "UI__NODE_EDITOR__VOICEGATEWAY__STT_CONTEXT_BOOST_AZURE__LABEL",
description: "UI__NODE_EDITOR__VOICEGATEWAY__STT_CONTEXT_BOOST_AZURE__DESCRIPTION",
defaultValue: 2,
condition: {
key: "azureUseContextPhrases",
value: true
}
},
{
key: "sttDisablePunctuation",
type: "toggle",
label: "UI__NODE_EDITOR__VOICEGATEWAY__STT_DISABLE_PUNCTUATION__LABEL",
description: "UI__NODE_EDITOR__VOICEGATEWAY__STT_DISABLE_PUNCTUATION__DESCRIPTION",
defaultValue: false,
condition: {
or: [
{
key: "sttVendor",
value: "google",
},
{
key: "sttVendor",
value: "deepgram",
},
]
}
},
{
key: "voiceName",
type: "cognigyText",
label: "UI__NODE_EDITOR__VOICEGATEWAY__VOICE_NAME__LABEL",
description: "UI__NODE_EDITOR__VOICEGATEWAY__VOICE_NAME__DESCRIPTION",
defaultValue: ""
},
];
exports.getParameterFields = getParameterFields;
/**
* All necessary sections for the params
* @param condition Node Field Condition to hide fields or not, optional
*/
const getParamSections = (condition) => [
{
key: "params_azure",
label: "UI__NODE_EDITOR__VOICEGATEWAY__AZURE__LABEL",
defaultCollapsed: true,
fields: [
"azureSpeechRecognitionMode",
"sttContextId",
"azureUseContextPhrases",
"sttContextPhrasesAzure",
"sttContextBoostAzure",
"ttsDeploymentId",
"azureEnableAudioLogging",
],
condition
},
{
key: "params_bargein",
label: "UI__NODE_EDITOR__VOICEGATEWAY__BARGEIN__LABEL",
defaultCollapsed: true,
fields: [
"bargeIn",
"bargeInOnDTMF",
"bargeInMinWordCount",
],
condition
},
{
key: "params_bot_timeouts",
label: "UI__NODE_EDITOR__VOICEGATEWAY__BOT_TIMEOUTS__LABEL",
defaultCollapsed: true,
fields: [
"botNoInputTimeoutMS",
"botNoInputRetries",
"botNoInputSpeech",
"botNoInputUrl",
"botFailOnErrors"
],
condition
},
{
key: "params_user_timeouts",
label: "UI__NODE_EDITOR__VOICEGATEWAY__USER_TIMEOUTS__LABEL",
defaultCollapsed: true,
fields: [
"userNoInputTimeoutMS",
"userNoInputRetries",
"userNoInputSendEvent",
"userNoInputAutoHangup",
"userNoInputSpeech",
"userNoInputUrl",
],
condition
},
{
key: "params_continuousasr",
label: "UI__NODE_EDITOR__VOICEGATEWAY__PARAMS_CONTINUOUS_ASR__LABEL",
defaultCollapsed: true,
fields: [
"continuousASR",
"continuousASRDigits",
"continuousASRTimeoutInMS",
],
condition
},
{
key: "params_tts",
label: "UI__NODE_EDITOR__VOICEGATEWAY__TTS_SETTINGS__LABEL",
defaultCollapsed: true,
fields: [
"voiceName",
"disableTtsCache"
],
condition
},
{
key: "params_stt",
label: "UI__NODE_EDITOR__VOICEGATEWAY__STT_SETTINGS__LABEL",
defaultCollapsed: true,
fields: [
"language",
"sttDisablePunctuation"
],
condition
},
{
key: "params_google",
label: "UI__NODE_EDITOR__VOICEGATEWAY__GOOGLE__LABEL",
defaultCollapsed: true,
fields: [
"googleInteractionType",
"sttContextGoogleDesc",
"sttContextPhrases",
"sttContextBoost",
],
condition
},
{
key: "params_dtmf",
label: "UI__NODE_EDITOR__VOICEGATEWAY__DTMF__LABEL",
defaultCollapsed: true,
fields: [
"sendDTMF",
"dtmfCollect",
"dtmfCollectInterDigitTimeoutMS",
"dtmfCollectMaxDigits",
"dtmfCollectSubmitDigit",
],
condition
}
];
exports.getParamSections = getParamSections;
//# sourceMappingURL=paramUtils.js.map