UNPKG

@cognigy/rest-api-client

Version:

Cognigy REST-Client

120 lines 3.9 kB
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, buildBargeInSectionFieldKeys } 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", "googleModelCustom" ], condition: { key: "setActivityParams", value: true } }, { key: "params_bargein", label: "UI__NODE_EDITOR__PLAY__SECTIONS__BARGEIN__LABEL", defaultCollapsed: true, fields: buildBargeInSectionFieldKeys(), 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; if (config.googleModel === "custom" && typeof config.googleModelCustom === "string") { const customGoogleModel = config.googleModelCustom.trim(); if (customGoogleModel) { config.googleModel = customGoogleModel; } } 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