UNPKG

@cognigy/rest-api-client

Version:

Cognigy REST-Client

107 lines 4.09 kB
import { __awaiter } from "tslib"; /** Custom Modules */ import { createNodeDescriptor } from "../../../createNodeDescriptor"; /** Helper Modules */ import { setSessionConfig } from "../mappers/setSessionConfig.mapper"; import { nodeColor } from "../utils/design"; import { voiceConfigParamsToVoiceSettings } from "../mappers/setSessionConfig.mapper"; import { logFullConfigToDebugMode } from "../../../../helper/logFullConfigToDebugMode"; export const BARGE_IN = createNodeDescriptor({ type: "bargeIn", defaultLabel: "Barge In - Config", tags: [""], appearance: { color: 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: ({ cognigy, config }) => __awaiter(void 0, void 0, void 0, function* () { const { api, input } = cognigy; const { endpointType } = input; try { const payload = setSessionConfig.handleInput(endpointType, voiceConfigParamsToVoiceSettings(config, api)); /* we need to store this for the DTMF Collect - Config node */ api.setSystemContext("vgSettings", { bargeInOnDtmf: config.bargeInOnDtmf }); yield api.say(null, { _cognigy: payload, }); logFullConfigToDebugMode(cognigy, config); } catch (error) { throw new Error(`Error on Barge In node. Error message: ${error.message}`); } }), }); //# sourceMappingURL=bargeIn.js.map