UNPKG

@cognigy/rest-api-client

Version:

Cognigy REST-Client

137 lines 5.13 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.msTeamsTransferNode = void 0; /** Custom Modules */ const createNodeDescriptor_1 = require("../../../createNodeDescriptor"); /** Helper Modules */ const msTeamsTransfer_mapper_1 = require("../../voice/mappers/msTeamsTransfer.mapper"); const design_1 = require("../utils/design"); const customHeaderDefaultValue = "X-Custom-Header"; const isMSTeamsTransferNodeAllowed = (organisationId) => { const allowlist = process.env.FEATURE_ENABLE_MS_TEAMS_TRANSFER_NODE_ALLOWLIST; if (!allowlist || !organisationId) { return false; } const entries = allowlist.split(",").map((entry) => entry.trim()); return entries.includes("*") || entries.includes(organisationId); }; exports.msTeamsTransferNode = (0, createNodeDescriptor_1.createNodeDescriptor)({ type: "msTeamsTransfer", defaultLabel: "MS Teams Transfer", preview: { key: "transferTarget", type: "text", }, appearance: { color: design_1.nodeColor, }, tags: ["voice"], fields: [ { key: "transferTarget", label: "UI__NODE_EDITOR__VOICEGATEWAY2__TRANSFER__FIELDS__TRANSFER_TARGET__LABEL", type: "cognigyText", params: { required: true, }, description: "UI__NODE_EDITOR__VOICEGATEWAY2__TRANSFER__FIELDS__TRANSFER_TARGET__DESCRIPTION", defaultValue: "+49123456789", }, { key: "callerName", label: "UI__NODE_EDITOR__VOICEGATEWAY2__MSTEAMS_TRANSFER__FIELDS__CALLER_NAME__LABEL", type: "cognigyText", description: "UI__NODE_EDITOR__VOICEGATEWAY2__MSTEAMS_TRANSFER__FIELDS__CALLER_NAME__DESCRIPTION", defaultValue: "", }, { key: "topic", label: "UI__NODE_EDITOR__VOICEGATEWAY2__MSTEAMS_TRANSFER__FIELDS__TOPIC__LABEL", type: "cognigyText", description: "UI__NODE_EDITOR__VOICEGATEWAY2__MSTEAMS_TRANSFER__FIELDS__TOPIC__DESCRIPTION", defaultValue: "", }, { key: "context", label: "UI__NODE_EDITOR__VOICEGATEWAY2__MSTEAMS_TRANSFER__FIELDS__CONTEXT__LABEL", type: "cognigyText", description: "UI__NODE_EDITOR__VOICEGATEWAY2__MSTEAMS_TRANSFER__FIELDS__CONTEXT__DESCRIPTION", defaultValue: "My context", params: { required: true, }, }, { key: "callSentiment", label: "UI__NODE_EDITOR__VOICEGATEWAY2__MSTEAMS_TRANSFER__FIELDS__CALL_SENTIMENT__LABEL", type: "cognigyText", description: "UI__NODE_EDITOR__VOICEGATEWAY2__MSTEAMS_TRANSFER__FIELDS__CALL_SENTIMENT__DESCRIPTION", defaultValue: "", }, { key: "suggestedActions", label: "UI__NODE_EDITOR__VOICEGATEWAY2__MSTEAMS_TRANSFER__FIELDS__SUGGESTED_ACTIONS__LABEL", type: "cognigyText", description: "UI__NODE_EDITOR__VOICEGATEWAY2__MSTEAMS_TRANSFER__FIELDS__SUGGESTED_ACTIONS__DESCRIPTION", defaultValue: "", }, ], form: [ { type: "field", key: "transferTarget" }, { type: "field", key: "callerName" }, { type: "field", key: "topic" }, { type: "field", key: "context" }, { type: "field", key: "callSentiment" }, { type: "field", key: "suggestedActions" }, ], summary: "UI__NODE_EDITOR__VOICEGATEWAY2__TRANSFER__SUMMARY", function: async ({ cognigy, config, organisationId, }) => { const { api, input } = cognigy; if (!isMSTeamsTransferNodeAllowed(organisationId)) { throw new Error("MS Teams Transfer node is not enabled for this organisation."); } const { transferTarget, callerName, topic, context, callSentiment, suggestedActions, } = config; const transferParams = { transferTarget, callerName, topic, context, callSentiment, suggestedActions, }; try { if (input.channel === "adminconsole") { let textWarningAdminChannel = "Transferring a call is not supported in the Interaction Panel, please use the VoiceGateway endpoint."; await api.say(textWarningAdminChannel, null); return; } const payload = msTeamsTransfer_mapper_1.msTeamsTransfer.handleInput("voiceGateway2", transferParams); await api.say(null, { _cognigy: payload, }); api.logDebugMessage(`UI__DEBUG_MODE__MS_TEAMS__TRANSFER__MESSAGE ${transferTarget}`); } catch (error) { throw new Error(`Error on Transfer node type:. Error message: ${error.message}`); } }, }); //# sourceMappingURL=msTeamsTransfer.js.map