UNPKG

@cognigy/rest-api-client

Version:

Cognigy REST-Client

50 lines 1.71 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.hangupNode = void 0; /** Custom Modules */ const createNodeDescriptor_1 = require("../../../createNodeDescriptor"); /** Helper Modules */ const design_1 = require("../utils/design"); const hangup_mapper_1 = require("../../voice/mappers/hangup.mapper"); const utils_1 = require("./helper/utils"); exports.hangupNode = (0, createNodeDescriptor_1.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: design_1.nodeColor }, form: [ { type: "field", key: "hangupReason" } ], function: async ({ cognigy, config, nodeId }) => { const { api } = cognigy; const { hangupReason } = config; try { const { isFeatureAccmEnabled } = api.getEndpointSettings(); const payload = isFeatureAccmEnabled ? (0, utils_1.buildPayloadAccm)("hangup", config, nodeId) : hangup_mapper_1.hangUp.handleInput("audioCodes", hangupReason, false); await api.say(null, { _cognigy: payload }); } catch (error) { throw new Error(`Error on hangup node. Error message: ${error.message}`); } } }); //# sourceMappingURL=hangup.js.map