@cognigy/rest-api-client
Version:
Cognigy REST-Client
78 lines • 2.85 kB
JavaScript
import { __awaiter } from "tslib";
/** Custom Modules */
import { createNodeDescriptor } from "../../../createNodeDescriptor";
/** Helper Modules */
import { nodeColor } from '../utils/design';
import { compileParams, getParameterFields, getParamSections } from "../utils/paramUtils";
import { buildPayloadAccm } from "./helper/utils";
export const setSessionParamsNode = createNodeDescriptor({
type: "setSessionParams",
defaultLabel: "Set Session Parameters",
summary: "UI__NODE_EDITOR__SET_SESSION_PARAMS__SUMMARY",
// @ts-ignore
fields: [
{
key: "sessionParams",
label: "UI__NODE_EDITOR__SET_SESSION_PARAMS__FIELDS__SESSION_PARAMS__LABEL",
type: "json",
defaultValue: "{}",
params: {
required: true
}
}
].concat(getParameterFields()),
sections: [
{
key: "advanced",
label: "UI__NODE_EDITOR__SET_SESSION_PARAMS__SECTIONS__ADVANCED__LABEL",
defaultCollapsed: true,
fields: [
"sessionParams",
]
}
].concat(getParamSections()),
appearance: {
color: nodeColor
},
form: [
{ type: "section", key: "params_stt" },
{ type: "section", key: "params_tts" },
{ type: "section", key: "params_dtmf" },
{ type: "section", key: "params_bargein" },
{ type: "section", key: "params_continuousasr" },
{ type: "section", key: "params_user_timeouts" },
{ type: "section", key: "params_bot_timeouts" },
{ type: "section", key: "params_azure" },
{ type: "section", key: "params_google" },
{ type: "section", key: "advanced" },
],
function: ({ cognigy, config, nodeId }) => __awaiter(void 0, void 0, void 0, function* () {
const { api } = cognigy;
const { sessionParams } = config;
const { isFeatureAccmEnabled } = api.getEndpointSettings();
if (isFeatureAccmEnabled) {
return yield api.say(null, {
_cognigy: buildPayloadAccm("setSessionParams", config, nodeId)
});
}
let compiledParams = sessionParams || {};
compileParams(config, compiledParams);
// output the activity to the voice gateway
yield api.output(null, {
"_cognigy": {
"_voiceGateway": {
"json": {
"activities": [
{
"type": "event",
"name": "config",
"sessionParams": compiledParams
}
]
}
}
}
});
})
});
//# sourceMappingURL=setSessionParams.js.map