@cognigy/rest-api-client
Version:
Cognigy REST-Client
49 lines • 1.8 kB
JavaScript
import { __awaiter } from "tslib";
/* Custom modules */
import { createNodeDescriptor } from "../../createNodeDescriptor";
export const ADD_MEMORY = createNodeDescriptor({
type: "addMemory",
defaultLabel: "Add Memory",
summary: "UI__NODE_EDITOR__ADD_MEMORY__SUMMARY",
appearance: {
showIcon: false
},
fields: [
{
key: "memory",
type: "cognigyText",
label: "UI__NODE_EDITOR__ADD_MEMORY__MEMORY__LABEL",
description: "UI__NODE_EDITOR__ADD_MEMORY__MEMORY__DESCRIPTION",
params: {
required: true
},
},
],
preview: {
key: "memory",
type: "text"
},
tags: ["analytics", "profile"],
function: ({ cognigy, config }) => __awaiter(void 0, void 0, void 0, function* () {
var _a, _b;
const { memory: memoryText } = config;
const { api } = cognigy;
if (memoryText !== undefined && memoryText !== null && memoryText !== "") {
let memoryToAdd;
if (typeof memoryText === 'string') {
memoryToAdd = memoryText;
}
else if (typeof memoryText === 'object') {
// Convert object to JSON string
memoryToAdd = JSON.stringify(memoryText);
}
else {
// Convert other types (number, boolean, etc.) to string
memoryToAdd = String(memoryText);
}
yield ((_a = api.addContactMemory) === null || _a === void 0 ? void 0 : _a.call(api, memoryToAdd));
(_b = api.logDebugMessage) === null || _b === void 0 ? void 0 : _b.call(api, `UI__DEBUG_MODE__ADD_MEMORY__MESSAGE\n'${memoryToAdd}'`);
}
})
});
//# sourceMappingURL=addMemory.js.map