UNPKG

@cognigy/rest-api-client

Version:

Cognigy REST-Client

133 lines 5.18 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.playURLNode = 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 paramUtils_1 = require("../utils/paramUtils"); const utils_1 = require("./helper/utils"); exports.playURLNode = (0, createNodeDescriptor_1.createNodeDescriptor)({ type: "playURL", defaultLabel: "Play URL", summary: "UI__NODE_EDITOR__VG__PLAY_URL__SUMMARY", // @ts-ignore fields: [ { key: "playUrlUrl", label: "UI__NODE_EDITOR__VG__PLAY_URL__FIELDS__PLAY_URL_URL__LABEL", type: "cognigyText", params: { required: true } }, { key: "playUrlMediaFormat", label: "UI__NODE_EDITOR__VG__PLAY_URL__FIELDS__PLAY_URL_MEDIA_FORMAT__LABEL", type: "select", defaultValue: "wav/lpcm16", description: "UI__NODE_EDITOR__VG__PLAY_URL__FIELDS__PLAY_URL_MEDIA_FORMAT__DESCRIPTION", params: { options: [ { label: "UI__NODE_EDITOR__VG__PLAY_URL__FIELDS__PLAY_URL_MEDIA_FORMAT__OPTIONS__WAV_LPCM16__LABEL", value: "wav/lpcm16" }, { label: "UI__NODE_EDITOR__VG__PLAY_URL__FIELDS__PLAY_URL_MEDIA_FORMAT__OPTIONS__RAW_LPCM16__LABEL", value: "raw/lpcm16" }, { label: "UI__NODE_EDITOR__VG__PLAY_URL__FIELDS__PLAY_URL_MEDIA_FORMAT__OPTIONS__WAV_MULAW__LABEL", value: "wav/mulaw" }, { label: "UI__NODE_EDITOR__VG__PLAY_URL__FIELDS__PLAY_URL_MEDIA_FORMAT__OPTIONS__RAW_MULAW__LABEL", value: "raw/mulaw" } ] } }, { key: "playUrlAltText", label: "UI__NODE_EDITOR__VG__PLAY_URL__FIELDS__PLAY_URL_ALT_TEXT__LABEL", type: "cognigyText", description: "UI__NODE_EDITOR__VG__PLAY_URL__FIELDS__PLAY_URL_ALT_TEXT__DESCRIPTION", defaultValue: "" }, { key: "playUrlCaching", label: "UI__NODE_EDITOR__VG__PLAY_URL__FIELDS__PLAY_URL_CACHING__LABEL", type: "toggle", defaultValue: false }, { key: "setActivityParams", label: "UI__NODE_EDITOR__VG__PLAY_URL__FIELDS__SET_ACTIVITY_PARAMS__LABEL", type: "toggle", defaultValue: false }, { key: "activityParams", label: "UI__NODE_EDITOR__VG__PLAY_URL__FIELDS__ACTIVITY_PARAMS__LABEL", type: "json", defaultValue: "{}" } ].concat((0, paramUtils_1.getParameterFields)()), sections: [ { key: "advanced", label: "UI__NODE_EDITOR__VG__PLAY_URL__SECTIONS__ADVANCED__LABEL", defaultCollapsed: true, fields: [ "activityParams", ], condition: { key: "setActivityParams", value: true } } ].concat((0, paramUtils_1.getParamSections)({ key: "setActivityParams", value: true })), form: [ { type: "field", key: "playUrlUrl" }, { type: "field", key: "playUrlMediaFormat" }, { type: "field", key: "playUrlCaching" }, { type: "field", key: "setActivityParams" }, { type: "section", key: "params_stt" }, { type: "section", key: "params_tts" }, { type: "section", key: "params_dtmf" }, { type: "section", key: "params_bargein" }, { type: "section", key: "params_continuousasr" }, { type: "section", key: "params_user_timeouts" }, { type: "section", key: "params_bot_timeouts" }, { type: "section", key: "params_azure" }, { type: "section", key: "params_google" }, { type: "section", key: "advanced" }, ], preview: { type: "text", key: "playUrlUrl" }, appearance: { color: design_1.nodeColor }, function: async ({ cognigy, config, nodeId }) => { const { api } = cognigy; const { playUrlUrl, playUrlMediaFormat } = config; if (playUrlUrl && playUrlMediaFormat) { try { const { isFeatureAccmEnabled } = api.getEndpointSettings(); const payload = isFeatureAccmEnabled ? (0, utils_1.buildPayloadAccm)("playURL", config, nodeId) : play_mapper_1.play.handleInput({ endpointType: 'audioCodes', config }); await api.say(null, { _cognigy: payload }); } catch (error) { throw new Error(`Error on play node. Error message: ${error.message}`); } ; } } }); //# sourceMappingURL=playURL.js.map