@cognigy/rest-api-client
Version:
Cognigy REST-Client
108 lines • 4.27 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.USER_INPUT_TIMEOUT = 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.USER_INPUT_TIMEOUT = (0, createNodeDescriptor_1.createNodeDescriptor)({
type: "noUserInput",
defaultLabel: "User Input Timeout - Config",
tags: [""],
appearance: {
color: design_1.nodeColor,
},
summary: "UI__NODE_EDITOR__NO_USER_INPUT__SUMMARY",
fields: [
{
key: "userNoInputMode",
type: "select",
label: "UI__NODE_EDITOR__NO_USER_INPUT__FIELDS__USER_NO_INPUT_MODE__LABEL",
description: "UI__NODE_EDITOR__NO_USER_INPUT__FIELDS__USER_NO_INPUT_MODE__DESCRIPTION",
defaultValue: "event",
params: {
options: [
{
label: "UI__NODE_EDITOR__NO_USER_INPUT__FIELDS__USER_NO_INPUT_MODE__OPTIONS__SPEECH__LABEL",
value: "speech",
},
{
label: "UI__NODE_EDITOR__NO_USER_INPUT__FIELDS__USER_NO_INPUT_MODE__OPTIONS__PLAY__LABEL",
value: "play",
},
{
label: "UI__NODE_EDITOR__NO_USER_INPUT__FIELDS__USER_NO_INPUT_MODE__OPTIONS__EVENT__LABEL",
value: "event",
},
],
},
},
{
key: "userNoInputTimeout",
type: "number",
label: "UI__NODE_EDITOR__NO_USER_INPUT__FIELDS__USER_NO_INPUT_TIMEOUT__LABEL",
description: "UI__NODE_EDITOR__NO_USER_INPUT__FIELDS__USER_NO_INPUT_TIMEOUT__DESCRIPTION",
defaultValue: 10000,
params: {
min: 1000,
},
},
{
key: "userNoInputRetries",
type: "number",
label: "UI__NODE_EDITOR__NO_USER_INPUT__FIELDS__USER_NO_INPUT_RETRIES__LABEL",
description: "UI__NODE_EDITOR__NO_USER_INPUT__FIELDS__USER_NO_INPUT_RETRIES__DESCRIPTION",
defaultValue: 1,
params: {
min: 0,
max: 999
},
},
{
key: "userNoInputSpeech",
type: "cognigyText",
label: "UI__NODE_EDITOR__NO_USER_INPUT__FIELDS__USER_NO_INPUT_SPEECH__LABEL",
description: "UI__NODE_EDITOR__NO_USER_INPUT__FIELDS__USER_NO_INPUT_SPEECH__DESCRIPTION",
defaultValue: "",
condition: {
key: "userNoInputMode",
value: "speech",
},
params: {
required: true,
},
},
{
key: "userNoInputUrl",
type: "cognigyText",
label: "UI__NODE_EDITOR__NO_USER_INPUT__FIELDS__USER_NO_INPUT_URL__LABEL",
description: "UI__NODE_EDITOR__NO_USER_INPUT__FIELDS__USER_NO_INPUT_URL__DESCRIPTION",
defaultValue: "",
condition: {
key: "userNoInputMode",
value: "play",
},
params: {
required: true,
},
},
],
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));
await api.say(null, {
_cognigy: payload,
});
(0, logFullConfigToDebugMode_1.logFullConfigToDebugMode)(cognigy, config);
}
catch (error) {
throw new Error(`Error on User Input Timeout node. Error message: ${error.message}`);
}
},
});
//# sourceMappingURL=noUserInput.js.map