UNPKG

@cognigy/rest-api-client

Version:

Cognigy REST-Client

109 lines 4.24 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.BARGE_IN = void 0; /** Custom Modules */ const createNodeDescriptor_1 = require("../../../createNodeDescriptor"); /** Helper Modules */ const setSessionConfig_mapper_1 = require("../mappers/setSessionConfig.mapper"); const design_1 = require("../utils/design"); const setSessionConfig_mapper_2 = require("../mappers/setSessionConfig.mapper"); const logFullConfigToDebugMode_1 = require("../../../../helper/logFullConfigToDebugMode"); exports.BARGE_IN = (0, createNodeDescriptor_1.createNodeDescriptor)({ type: "bargeIn", defaultLabel: "Barge In - Config", tags: [""], appearance: { color: design_1.nodeColor, }, summary: "UI__NODE_EDITOR__BARGE_IN__SUMMARY", fields: [ { key: "bargeInOnSpeech", type: "toggle", label: "UI__NODE_EDITOR__BARGE_IN__FIELDS__BARGE_IN_ON_SPEECH__LABEL", description: "UI__NODE_EDITOR__BARGE_IN__FIELDS__BARGE_IN_ON_SPEECH__DESCRIPTION", defaultValue: false, }, { key: "bargeInOnDtmf", type: "toggle", label: "UI__NODE_EDITOR__BARGE_IN__FIELDS__BARGE_IN_ON_DTMF__LABEL", description: "UI__NODE_EDITOR__BARGE_IN__FIELDS__BARGE_IN_ON_DTMF__DESCRIPTION", defaultValue: false, }, { key: "bargeInMinWordCount", type: "slider", label: "UI__NODE_EDITOR__BARGE_IN__FIELDS__BARGE_IN_MIN_WORD_COUNT__LABEL", description: "UI__NODE_EDITOR__BARGE_IN__FIELDS__BARGE_IN_MIN_WORD_COUNT__DESCRIPTION", defaultValue: 1, params: { min: 1, max: 5, step: 1, }, }, { key: "dtmfInterDigitTimeout", type: "number", label: "UI__NODE_EDITOR__BARGE_IN__FIELDS__DTMF_INTER_DIGIT_TIMEOUT__LABEL", description: "UI__NODE_EDITOR__BARGE_IN__FIELDS__DTMF_INTER_DIGIT_TIMEOUT__DESCRIPTION", defaultValue: 2000, params: { min: 0, }, }, { key: "dtmfMaxDigits", type: "number", label: "UI__NODE_EDITOR__BARGE_IN__FIELDS__DTMF_MAX_DIGITS__LABEL", description: "UI__NODE_EDITOR__BARGE_IN__FIELDS__DTMF_MAX_DIGITS__DESCRIPTION", defaultValue: 1, params: { min: 1, }, }, { key: "dtmfSubmitDigit", type: "cognigyText", label: "UI__NODE_EDITOR__BARGE_IN__FIELDS__DTMF_SUBMIT_DIGIT__LABEL", description: "UI__NODE_EDITOR__BARGE_IN__FIELDS__DTMF_SUBMIT_DIGIT__DESCRIPTION", defaultValue: "#", }, ], sections: [ { key: "paramsDtmf", label: "UI__NODE_EDITOR__BARGE_IN__SECTIONS__PARAMS_DTMF__LABEL", defaultCollapsed: false, fields: ["dtmfInterDigitTimeout", "dtmfMaxDigits", "dtmfSubmitDigit"], condition: { key: "bargeInOnDtmf", value: true } } ], form: [ { type: "field", key: "bargeInOnSpeech" }, { type: "field", key: "bargeInOnDtmf" }, { type: "field", key: "bargeInMinWordCount" }, { type: "section", key: "paramsDtmf" } ], function: async ({ cognigy, config }) => { const { api, input } = cognigy; const { endpointType } = input; try { const payload = setSessionConfig_mapper_1.setSessionConfig.handleInput(endpointType, (0, setSessionConfig_mapper_2.voiceConfigParamsToVoiceSettings)(config, api)); /* we need to store this for the DTMF Collect - Config node */ api.setSystemContext("vgSettings", { bargeInOnDtmf: config.bargeInOnDtmf }); await api.say(null, { _cognigy: payload, }); (0, logFullConfigToDebugMode_1.logFullConfigToDebugMode)(cognigy, config); } catch (error) { throw new Error(`Error on Barge In node. Error message: ${error.message}`); } }, }); //# sourceMappingURL=bargeIn.js.map