UNPKG

@cognigy/rest-api-client

Version:

Cognigy REST-Client

166 lines 5.51 kB
import { __awaiter } from "tslib"; /** Custom Modules */ import { createNodeDescriptor } from "../../../createNodeDescriptor"; /** Helper Modules */ import { play } from '../../voice/mappers/play.mapper'; import { nodeColor } from '../utils/design'; import { voiceConfigFields, buildBargeInSectionFieldKeys } from './setSessionConfig'; export const playNode = createNodeDescriptor({ type: "play", defaultLabel: "Play", summary: "UI__NODE_EDITOR__VOICEGATEWAY2__PLAY__SUMMARY", preview: { key: "url", type: "text" }, appearance: { color: 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 }, ...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", "googleModelCustom", "sttLabel", "deepgramEndpointing", "deepgramEndpointingValue", "deepgramSmartFormatting", "deepgramfluxEndpointing", "deepgramfluxEndOfTurnThreshold", "deepgramfluxEndOfTurnTimeoutMs", "speechmaticsEndpointing", "speechmaticsEndpointingValue", "openaiEndpointing", "openaiEndpointingValue", "niceEndpointing", "niceEndpointingValue", "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: buildBargeInSectionFieldKeys(), 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: ({ cognigy, config }) => __awaiter(void 0, void 0, void 0, function* () { const { api } = cognigy; if (config.googleModel === "custom" && typeof config.googleModelCustom === "string") { const customGoogleModel = config.googleModelCustom.trim(); if (customGoogleModel) { config.googleModel = customGoogleModel; } } try { const payload = play.handleInput({ endpointType: "voiceGateway2", 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