UNPKG

@cognigy/rest-api-client

Version:

Cognigy REST-Client

106 lines 4.1 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 USER_INPUT_TIMEOUT = createNodeDescriptor({ type: "noUserInput", defaultLabel: "User Input Timeout - Config", tags: [""], appearance: { color: 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: ({ 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)); yield api.say(null, { _cognigy: payload, }); logFullConfigToDebugMode(cognigy, config); } catch (error) { throw new Error(`Error on User Input Timeout node. Error message: ${error.message}`); } }), }); //# sourceMappingURL=noUserInput.js.map