@cognigy/rest-api-client
Version:
Cognigy REST-Client
113 lines • 3.58 kB
JavaScript
import { __awaiter } from "tslib";
/** Custom Modules */
import { createNodeDescriptor } from "../../../createNodeDescriptor";
/** Helper Modules */
import { play } from "../mappers/play.mapper";
import { nodeColor } from "../utils/design";
import { voiceConfigFields } from "../../voicegateway2/nodes/setSessionConfig";
const fields = (voiceConfigFields.map(field => {
if (field.key !== "sttDisablePunctuation" &&
field.key !== "sttVadEnabled" &&
field.key !== "sttVadMode" &&
field.key !== "sttVadVoiceMs") {
return field;
}
return null;
})).filter(f => !!f);
export const PLAY = createNodeDescriptor({
type: "play",
defaultLabel: "Play URL",
tags: [''],
preview: {
key: "url",
type: "text"
},
appearance: {
color: nodeColor
},
fields: [
{
key: "url",
label: "UI__NODE_EDITOR__PLAY__FIELDS__URL__LABEL",
type: "cognigyText",
description: "UI__NODE_EDITOR__PLAY__FIELDS__URL__DESCRIPTION",
params: {
required: true
},
defaultValue: "https://www2.cs.uic.edu/~i101/SoundFiles/PinkPanther30.wav"
},
{
key: "setActivityParams",
label: "UI__NODE_EDITOR__PLAY__FIELDS__SET_ACTIVITY_PARAMS__LABEL",
type: "toggle",
defaultValue: false
},
...fields
],
sections: [
{
key: "params_stt",
label: "UI__NODE_EDITOR__PLAY__SECTIONS__STT__LABEL",
defaultCollapsed: true,
fields: [
"sttVendor",
"sttHints",
"enableAdvancedSTTConfig",
"azureSttContextId",
"azureEnableAudioLogging",
"googleModel"
],
condition: {
key: "setActivityParams",
value: true
}
},
{
key: "params_bargein",
label: "UI__NODE_EDITOR__PLAY__SECTIONS__BARGEIN__LABEL",
defaultCollapsed: true,
fields: ["bargeInOnSpeech", "bargeInOnDtmf", "bargeInMinWordCount"],
condition: {
key: "setActivityParams",
value: true
}
},
{
key: "params_dtmf",
label: "UI__NODE_EDITOR__PLAY__SECTIONS__DTMF__LABEL",
defaultCollapsed: true,
fields: ["dtmfEnable", "dtmfInterDigitTimeout", "dtmfMaxDigits", "dtmfSubmitDigit"],
condition: {
key: "setActivityParams",
value: true
}
},
],
form: [
{ type: "field", key: "url" },
{ type: "field", key: "setActivityParams" },
{ type: "section", key: "params_stt" },
{ type: "section", key: "params_bargein" },
{ type: "section", key: "params_dtmf" },
],
summary: "UI__NODE_EDITOR__PLAY__SUMMARY",
function: ({ cognigy, config }) => __awaiter(void 0, void 0, void 0, function* () {
const { api, input } = cognigy;
const { endpointType } = input;
try {
const payload = play.handleInput({
endpointType,
config,
api,
});
yield api.say(null, {
_cognigy: payload
});
}
catch (error) {
throw new Error(`Error on play node. Error message: ${error.message}`);
}
;
})
});
//# sourceMappingURL=play.js.map