@cognigy/rest-api-client
Version:
Cognigy REST-Client
48 lines • 1.61 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";
import { buildPayloadAccm } from "./helper/utils";
export const hangupNode = createNodeDescriptor({
type: "hangup",
defaultLabel: "Hang Up",
summary: "UI__NODE_EDITOR__VG__HANGUP__SUMMARY",
fields: [
{
key: "hangupReason",
label: "UI__NODE_EDITOR__VG__HANGUP__FIELDS__HANGUP_REASON__LABEL",
type: "cognigyText",
defaultValue: "Bot ended the call",
params: {
required: true
}
},
],
preview: {
key: "hangupReason",
type: "text"
},
appearance: {
color: nodeColor
},
form: [
{ type: "field", key: "hangupReason" }
],
function: ({ cognigy, config, nodeId }) => __awaiter(void 0, void 0, void 0, function* () {
const { api } = cognigy;
const { hangupReason } = config;
try {
const { isFeatureAccmEnabled } = api.getEndpointSettings();
const payload = isFeatureAccmEnabled ? buildPayloadAccm("hangup", config, nodeId) : hangUp.handleInput("audioCodes", hangupReason, false);
yield api.say(null, {
_cognigy: payload
});
}
catch (error) {
throw new Error(`Error on hangup node. Error message: ${error.message}`);
}
})
});
//# sourceMappingURL=hangup.js.map