@cognigy/rest-api-client
Version:
Cognigy REST-Client
242 lines • 8.23 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.OVERWRITE_ANALYTICS = void 0;
/* Custom modules */
const createNodeDescriptor_1 = require("../../createNodeDescriptor");
/**
* Node name: 'Overwrite Analytics'
*
* Purpose:
* Overwrites the analytics record
*/
exports.OVERWRITE_ANALYTICS = (0, createNodeDescriptor_1.createNodeDescriptor)({
type: "overwriteAnalytics",
defaultLabel: "Overwrite Analytics",
summary: "UI__NODE_EDITOR__OVERWRITE_ANALYTICS__SUMMARY",
appearance: {
showIcon: false
},
fields: [
{
key: "customDesc",
type: "description",
label: " ",
params: {
text: "UI__NODE_EDITOR__OVERWRITE_ANALYTICS__CUSTOM_DESC__DESCRIPTION"
}
},
{
key: "defaultDesc",
type: "description",
label: " ",
params: {
text: "UI__NODE_EDITOR__OVERWRITE_ANALYTICS__DEFAULT_DESC__DESCRIPTION"
}
},
{
key: "custom1",
type: "cognigyText",
label: "UI__NODE_EDITOR__OVERWRITE_ANALYTICS__CUSTOM1__LABEL",
},
{
key: "custom2",
type: "cognigyText",
label: "UI__NODE_EDITOR__OVERWRITE_ANALYTICS__CUSTOM2__LABEL",
},
{
key: "custom3",
type: "cognigyText",
label: "UI__NODE_EDITOR__OVERWRITE_ANALYTICS__CUSTOM3__LABEL",
},
{
key: "custom4",
type: "cognigyText",
label: "UI__NODE_EDITOR__OVERWRITE_ANALYTICS__CUSTOM4__LABEL",
},
{
key: "custom5",
type: "cognigyText",
label: "UI__NODE_EDITOR__OVERWRITE_ANALYTICS__CUSTOM5__LABEL",
},
{
key: "custom6",
type: "cognigyText",
label: "UI__NODE_EDITOR__OVERWRITE_ANALYTICS__CUSTOM6__LABEL",
},
{
key: "custom7",
type: "cognigyText",
label: "UI__NODE_EDITOR__OVERWRITE_ANALYTICS__CUSTOM7__LABEL",
},
{
key: "custom8",
type: "cognigyText",
label: "UI__NODE_EDITOR__OVERWRITE_ANALYTICS__CUSTOM8__LABEL",
},
{
key: "custom9",
type: "cognigyText",
label: "UI__NODE_EDITOR__OVERWRITE_ANALYTICS__CUSTOM9__LABEL",
},
{
key: "custom10",
type: "cognigyText",
label: "UI__NODE_EDITOR__OVERWRITE_ANALYTICS__CUSTOM10__LABEL",
},
{
key: "intent",
type: "cognigyText",
label: "UI__NODE_EDITOR__OVERWRITE_ANALYTICS__INTENT__LABEL",
},
{
key: "intentScore",
type: "number",
label: "UI__NODE_EDITOR__OVERWRITE_ANALYTICS__INTENT_SCORE__LABEL"
},
{
key: "inputText",
type: "cognigyText",
label: "UI__NODE_EDITOR__OVERWRITE_ANALYTICS__INPUT_TEXT__LABEL",
},
{
key: "inputData",
type: "json",
label: "UI__NODE_EDITOR__OVERWRITE_ANALYTICS__INPUT_DATA__LABEL",
defaultValue: "{}"
},
{
key: "state",
type: "cognigyText",
label: "UI__NODE_EDITOR__OVERWRITE_ANALYTICS__STATE__LABEL",
},
{
key: "handoverEscalations",
type: "cognigyText",
label: "UI__NODE_EDITOR__OVERWRITE_ANALYTICS__HANDOVER_ESCALATIONS__LABEL",
},
{
key: "slots",
type: "json",
label: "UI__NODE_EDITOR__OVERWRITE_ANALYTICS__SLOTS__LABEL",
defaultValue: "{}"
},
{
key: "completedGoals",
type: "textArray",
label: "UI__NODE_EDITOR__OVERWRITE_ANALYTICS__COMPLETED_GOALS__LABEL",
},
{
key: "understood",
type: "select",
label: "UI__NODE_EDITOR__OVERWRITE_ANALYTICS__UNDERSTOOD__LABEL",
defaultValue: "cUndefined",
params: {
options: [
{
label: "UI__NODE_EDITOR__OVERWRITE_ANALYTICS__UNDERSTOOD__CUNDEFINED__LABEL",
value: "cUndefined",
},
{
label: "UI__NODE_EDITOR__OVERWRITE_ANALYTICS__UNDERSTOOD__TRUE__LABEL",
value: "true",
},
{
label: "UI__NODE_EDITOR__OVERWRITE_ANALYTICS__UNDERSTOOD__FALSE__LABEL",
value: "false",
},
{
label: "UI__NODE_EDITOR__OVERWRITE_ANALYTICS__UNDERSTOOD__NULL__LABEL",
value: "null",
}
]
}
}
],
sections: [
{
key: "customFields",
label: "UI__NODE_EDITOR__OVERWRITE_ANALYTICS__CUSTOM_FIELDS__LABEL",
defaultCollapsed: false,
fields: [
"customDesc",
"custom1",
"custom2",
"custom3",
"custom4",
"custom5",
"custom6",
"custom7",
"custom8",
"custom9",
"custom10",
]
},
{
key: "defaultFields",
label: "UI__NODE_EDITOR__OVERWRITE_ANALYTICS__DEFAULT_FIELDS__LABEL",
defaultCollapsed: false,
fields: [
"defaultDesc",
"intent",
"intentScore",
"inputText",
"inputData",
"state",
"slots",
"completedGoals",
"understood",
"handoverEscalations",
]
},
],
form: [
{ type: "section", key: "customFields" },
{ type: "section", key: "defaultFields" }
],
tags: ["analytics", "customize"],
function: async ({ cognigy, config }) => {
const { api } = cognigy;
let stringUpdateValue = "";
for (let key of Object.keys(config)) {
if (key === "handoverEscalations") {
const parsedHandoverEscalations = parseInt(config[key]);
if (!isNaN(parsedHandoverEscalations)) {
api.setAnalyticsData(key, parsedHandoverEscalations);
stringUpdateValue += `${key}: ${parsedHandoverEscalations}<br>`;
}
continue;
}
switch (typeof config[key]) {
case "string":
if (config[key] && config[key].length > 0 && config[key] !== "cUndefined") {
api.setAnalyticsData(key, config[key]);
stringUpdateValue += `${key}: ${config[key]}<br>`;
}
break;
case "object":
if (config[key] && Array.isArray(config[key]) && config[key].length > 0) {
api.setAnalyticsData(key, config[key]);
}
else if (config[key] && Object.keys(config[key]).length > 0) {
api.setAnalyticsData(key, config[key]);
}
try {
stringUpdateValue += `${key}: ${JSON.stringify(config[key])}<br>`;
}
catch (err) { }
break;
case "number":
if (config[key] && Number(config[key])) {
api.setAnalyticsData(key, config[key]);
stringUpdateValue += `${key}: ${config[key]}<br>`;
}
break;
}
if (key === "understood" && config["understood"] === "null") {
api.setAnalyticsData("understood", null);
}
}
api.logDebugMessage(stringUpdateValue);
}
});
//# sourceMappingURL=overwriteAnalytics.js.map