@cognigy/rest-api-client
Version:
Cognigy REST-Client
50 lines • 1.74 kB
JavaScript
import { __awaiter } from "tslib";
/* Custom modules */
import { createNodeDescriptor } from "../../createNodeDescriptor";
/**
* Node name: 'disableSlotFillers'
*
* Purpose:
* Disables slot fillers
*/
export const DISABLE_SLOT_FILLERS = createNodeDescriptor({
type: "disableSlotFillers",
defaultLabel: "Disable Slot Fillers",
summary: "UI__NODE_EDITOR__DISABLE_SLOT_FILLERS__SUMMARY",
appearance: {
showIcon: false
},
fields: [
{
key: "slotFillersToDisable",
type: "slotFillerArray",
label: "UI__NODE_EDITOR__DISABLE_SLOT_FILLERS__SLOT_FILLERS_TO_DISABLE__LABEL",
description: "UI__NODE_EDITOR__DISABLE_SLOT_FILLERS__SLOT_FILLERS_TO_DISABLE__DESCRIPTION"
},
{
key: "reset",
type: "toggle",
label: "UI__NODE_EDITOR__DISABLE_SLOT_FILLERS__RESET__LABEL",
}
],
tags: ["ai", "nlu"],
function: ({ cognigy, config }) => __awaiter(void 0, void 0, void 0, function* () {
const { slotFillersToDisable, reset } = config;
const { api, flowReferenceId } = cognigy;
let slotFillers = api.getSystemContext("slotFillers");
if (slotFillers) {
if (reset) {
slotFillers[flowReferenceId] = [];
}
else {
slotFillers[flowReferenceId] = slotFillers[flowReferenceId] && slotFillers[flowReferenceId].filter(filler => slotFillersToDisable.indexOf(filler) === -1);
}
}
else {
slotFillers = {};
slotFillers[flowReferenceId] = [];
}
api.setSystemContext("slotFillers", slotFillers);
})
});
//# sourceMappingURL=disableSlotFillers.js.map