@cognigy/rest-api-client
Version:
Cognigy REST-Client
89 lines • 2.76 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.EXECUTE_FLOW = void 0;
/* Custom modules */
const createNodeDescriptor_1 = require("../../createNodeDescriptor");
/**
* Node name: 'executeFlow'
*
* Purpose:
* Executes a given node in a given Flow
*/
exports.EXECUTE_FLOW = (0, createNodeDescriptor_1.createNodeDescriptor)({
type: "executeFlow",
defaultLabel: "Execute Flow",
summary: "UI__NODE_EDITOR__EXECUTE_FLOW__SUMMARY",
appearance: {
showIcon: false
},
fields: [
{
key: "flowNode",
type: "flowNode",
label: "UI__NODE_EDITOR__EXECUTE_FLOW__FLOW_NODE__LABEL",
},
{
key: "parseIntents",
type: "toggle",
label: "UI__NODE_EDITOR__EXECUTE_FLOW__PARSE_INTENTS__LABEL",
description: "UI__NODE_EDITOR__EXECUTE_FLOW__PARSE_INTENTS__DESCRIPTION",
defaultValue: true
},
{
key: "parseKeyphrases",
type: "toggle",
label: "UI__NODE_EDITOR__EXECUTE_FLOW__PARSE_KEYPHRASES__LABEL",
description: "UI__NODE_EDITOR__EXECUTE_FLOW__PARSE_KEYPHRASES__DESCRIPTION",
defaultValue: true
},
{
key: "absorbContext",
type: "toggle",
label: "UI__NODE_EDITOR__EXECUTE_FLOW__ABSORB_CONTEXT__LABEL",
description: "UI__NODE_EDITOR__EXECUTE_FLOW__ABSORB_CONTEXT__DESCRIPTION",
}
],
sections: [
{
key: "advanced",
label: "UI__NODE_EDITOR__EXECUTE_FLOW__ADVANCED__LABEL",
defaultCollapsed: true,
fields: [
"parseIntents",
"parseKeyphrases",
"absorbContext"
]
}
],
form: [
{ type: "field", key: "flowNode" },
{ type: "section", key: "advanced" },
],
preview: {
key: "flowNode",
type: "resource",
},
tags: ["logic"],
function: async ({ cognigy, config, nodeId: thisNodeId }) => {
const { flowNode: { flow: flowId, node: nodeId }, parseIntents, parseKeyphrases, absorbContext } = config;
const { api } = cognigy;
if (!flowId) {
throw new Error("flowId is required");
}
if (!api.checkThink(thisNodeId)) {
await api.executeFlow({
flowNode: {
flow: flowId,
node: nodeId || null
},
absorbContext,
parseIntents,
parseKeyphrases
});
}
else {
throw new Error("Infinite Loop Detected");
}
}
});
//# sourceMappingURL=executeFlow.js.map