@cognigy/rest-api-client
Version:
Cognigy REST-Client
71 lines • 2.6 kB
JavaScript
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 CONTINUOUS_ASR = createNodeDescriptor({
type: "continuousASR",
defaultLabel: "Continuous ASR - Config",
tags: [""],
appearance: {
color: nodeColor,
},
summary: "UI__NODE_EDITOR__CONTINUOUS_ASR__SUMMARY",
fields: [
{
key: "asrEnabled",
type: "toggle",
label: "UI__NODE_EDITOR__CONTINUOUS_ASR__FIELDS__ASR_ENABLED__LABEL",
description: "UI__NODE_EDITOR__CONTINUOUS_ASR__FIELDS__ASR_ENABLED__DESCRIPTION",
defaultValue: false,
},
{
key: "asrDigit",
type: "cognigyText",
label: "UI__NODE_EDITOR__CONTINUOUS_ASR__FIELDS__ASR_DIGIT__LABEL",
description: "UI__NODE_EDITOR__CONTINUOUS_ASR__FIELDS__ASR_DIGIT__DESCRIPTION",
defaultValue: "#",
condition: {
key: "asrEnabled",
value: true,
},
params: {
type: "string",
minLength: 1,
maxLength: 1,
},
},
{
key: "asrTimeout",
type: "number",
label: "UI__NODE_EDITOR__CONTINUOUS_ASR__FIELDS__ASR_TIMEOUT__LABEL",
description: "UI__NODE_EDITOR__CONTINUOUS_ASR__FIELDS__ASR_TIMEOUT__DESCRIPTION",
defaultValue: 3000,
params: {
min: 2000
},
condition: {
key: "asrEnabled",
value: 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 Continuous ASR node. Error message: ${error.message}`);
}
}),
});
//# sourceMappingURL=continuousAsr.js.map