@cognigy/rest-api-client
Version:
Cognigy REST-Client
87 lines • 2.7 kB
JavaScript
import { __awaiter } from "tslib";
/* Custom modules */
import { createNodeDescriptor } from "../../createNodeDescriptor";
/**
* Node name: 'executeFlow'
*
* Purpose:
* Executes a given node in a given Flow
*/
export const EXECUTE_FLOW = 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: ({ cognigy, config, nodeId: thisNodeId }) => __awaiter(void 0, void 0, void 0, function* () {
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)) {
yield api.executeFlow({
flowNode: {
flow: flowId,
node: nodeId || null
},
absorbContext,
parseIntents,
parseKeyphrases
});
}
else {
throw new Error("Infinite Loop Detected");
}
})
});
//# sourceMappingURL=executeFlow.js.map