@cognigy/rest-api-client
Version:
Cognigy REST-Client
67 lines • 2.25 kB
JavaScript
import { __awaiter } from "tslib";
/** Custom Modules */
import { createNodeDescriptor } from "../../../createNodeDescriptor";
/** Helper Modules */
import { nodeColor } from '../utils/design';
import { hangUp } from "../../voice/mappers/hangup.mapper";
export const hangupNode = createNodeDescriptor({
type: "hangup",
defaultLabel: "Hang Up",
preview: {
key: "hangupReason",
type: "text"
},
tags: ["voice"],
appearance: {
color: nodeColor
},
summary: "UI__NODE_EDITOR__VOICEGATEWAY2__HANGUP__SUMMARY",
fields: [
{
key: "hangupReason",
label: "UI__NODE_EDITOR__VOICEGATEWAY2__HANGUP__FIELDS__HANGUP_REASON__LABEL",
type: "cognigyText",
defaultValue: "Bot ended the call",
params: {
required: true
}
},
{
key: "hangupImmediately",
label: "UI__NODE_EDITOR__VOICEGATEWAY2__HANGUP__FIELDS__HANGUP_IMMEDIATELY__LABEL",
description: "UI__NODE_EDITOR__VOICEGATEWAY2__HANGUP__FIELDS__HANGUP_IMMEDIATELY__DESCRIPTION",
type: "toggle",
defaultValue: false,
params: {
required: true
}
}
],
sections: [
{
key: "advanced",
label: "UI__NODE_EDITOR__VOICEGATEWAY2__SECTIONS__ADVANCED__LABEL",
defaultCollapsed: true,
fields: ["hangupImmediately"]
},
],
form: [
{ "type": "field", "key": "hangupReason" },
{ "type": "section", "key": "advanced" },
],
function: ({ cognigy, config }) => __awaiter(void 0, void 0, void 0, function* () {
const { api } = cognigy;
const { hangupReason, hangupImmediately } = config;
try {
const payload = hangUp.handleInput("voiceGateway2", hangupReason, hangupImmediately);
yield api.say(null, {
_cognigy: payload
});
api.logDebugMessage(`UI__DEBUG_MODE__HANGUP__MESSAGE ${hangupReason}`);
}
catch (error) {
throw new Error(`Error on hangup node. Error message: ${error.message}`);
}
})
});
//# sourceMappingURL=hangup.js.map