UNPKG

@cognigy/rest-api-client

Version:

Cognigy REST-Client

122 lines 3.99 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PLAY = void 0; /** Custom Modules */ const createNodeDescriptor_1 = require("../../../createNodeDescriptor"); /** Helper Modules */ const play_mapper_1 = require("../mappers/play.mapper"); const design_1 = require("../utils/design"); const setSessionConfig_1 = require("../../voicegateway2/nodes/setSessionConfig"); const fields = (setSessionConfig_1.voiceConfigFields.map(field => { if (field.key !== "sttDisablePunctuation" && field.key !== "sttVadEnabled" && field.key !== "sttVadMode" && field.key !== "sttVadVoiceMs") { return field; } return null; })).filter(f => !!f); exports.PLAY = (0, createNodeDescriptor_1.createNodeDescriptor)({ type: "play", defaultLabel: "Play URL", tags: [''], preview: { key: "url", type: "text" }, appearance: { color: design_1.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: (0, setSessionConfig_1.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: async ({ cognigy, config }) => { 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_mapper_1.play.handleInput({ endpointType, config, api, }); await api.say(null, { _cognigy: payload }); } catch (error) { throw new Error(`Error on play node. Error message: ${error.message}`); } ; } }); //# sourceMappingURL=play.js.map