UNPKG

@cognigy/rest-api-client

Version:

Cognigy REST-Client

69 lines 2.34 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"); exports.hangupNode = (0, createNodeDescriptor_1.createNodeDescriptor)({ type: "hangup", defaultLabel: "Hang Up", preview: { key: "hangupReason", type: "text" }, tags: ["voice"], appearance: { color: design_1.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: async ({ cognigy, config }) => { const { api } = cognigy; const { hangupReason, hangupImmediately } = config; try { const payload = hangup_mapper_1.hangUp.handleInput("voiceGateway2", hangupReason, hangupImmediately); await 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