UNPKG

@cognigy/rest-api-client

Version:

Cognigy REST-Client

152 lines 4.91 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.playNode = void 0; /** Custom Modules */ const createNodeDescriptor_1 = require("../../../createNodeDescriptor"); /** Helper Modules */ const play_mapper_1 = require("../../voice/mappers/play.mapper"); const design_1 = require("../utils/design"); const setSessionConfig_1 = require("./setSessionConfig"); exports.playNode = (0, createNodeDescriptor_1.createNodeDescriptor)({ type: "play", defaultLabel: "Play", summary: "UI__NODE_EDITOR__VOICEGATEWAY2__PLAY__SUMMARY", preview: { key: "url", type: "text" }, appearance: { color: design_1.nodeColor }, tags: ["voice"], fields: [ { key: "url", label: "UI__NODE_EDITOR__VOICEGATEWAY2__FIELDS__URL__LABEL", type: "cognigyText", description: "UI__NODE_EDITOR__VOICEGATEWAY2__FIELDS__URL__DESCRIPTION", params: { required: true }, defaultValue: "https://www2.cs.uic.edu/~i101/SoundFiles/PinkPanther30.wav" }, { key: "loop", label: "UI__NODE_EDITOR__VOICEGATEWAY2__FIELDS__LOOP__LABEL", description: "UI__NODE_EDITOR__VOICEGATEWAY2__FIELDS__LOOP__DESCRIPTION", type: "number", defaultValue: 1, params: { min: 1, max: 10, step: 1 } }, { key: "setActivityParams", label: "UI__NODE_EDITOR__VOICEGATEWAY2__FIELDS__SET_ACTIVITY_PARAMS__LABEL", type: "toggle", defaultValue: false }, ...setSessionConfig_1.voiceConfigFields, { key: "sessionParams", label: "UI__NODE_EDITOR__VOICEGATEWAY2__FIELDS__SESSION_PARAMS__LABEL", type: "json", defaultValue: "{}", params: { required: true } } ], sections: [ { key: "params_stt", label: "UI__NODE_EDITOR__VOICEGATEWAY2__SECTIONS__STT__LABEL", defaultCollapsed: true, fields: [ "sttVendor", "sttHints", "sttHintsDynamicHints", "googleModel", "sttLabel", "deepgramEndpointing", "deepgramEndpointingValue", "deepgramSmartFormatting", "sttDisablePunctuation", "sttVadEnabled", "sttVadMode", "sttVadVoiceMs", "enableAdvancedSTTConfig", "azureSttContextId", "azureEnableAudioLogging" ], condition: { key: "setActivityParams", value: true } }, { key: "params_bargein", label: "UI__NODE_EDITOR__VOICEGATEWAY2__SECTIONS__BARGEIN__LABEL", defaultCollapsed: true, fields: ["bargeInOnSpeech", "bargeInOnDtmf", "bargeInMinWordCount"], condition: { key: "setActivityParams", value: true } }, { key: "params_dtmf", label: "UI__NODE_EDITOR__VOICEGATEWAY2__SECTIONS__DTMF__LABEL", defaultCollapsed: true, fields: [ "dtmfEnable", "dtmfInterDigitTimeout", "dtmfMaxDigits", "dtmfMinDigits", "dtmfSubmitDigit" ], condition: { key: "setActivityParams", value: true } }, { key: "advanced", label: "UI__NODE_EDITOR__VOICEGATEWAY2__SECTIONS__ADVANCED__LABEL", defaultCollapsed: true, fields: ["sessionParams"], condition: { key: "setActivityParams", value: true } }, ], form: [ { type: "field", key: "url" }, { type: "field", key: "loop" }, { type: "field", key: "setActivityParams" }, { type: "section", key: "params_stt" }, { type: "section", key: "params_bargein" }, { type: "section", key: "params_dtmf" }, { type: "section", key: "advanced" } ], function: async ({ cognigy, config }) => { const { api } = cognigy; try { const payload = play_mapper_1.play.handleInput({ endpointType: "voiceGateway2", 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