n8n-nodes-cleverflow
Version:
n8n node to integrate with CleverFlow API for creating workflow runs and processing Tally Forms
380 lines • 15.6 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CleverFlow = void 0;
const n8n_workflow_1 = require("n8n-workflow");
const create = __importStar(require("./actions/create"));
const get = __importStar(require("./actions/get"));
const processTallyForm = __importStar(require("./actions/processTallyForm"));
const loadOptionsMethods = __importStar(require("./methods/loadOptions"));
class CleverFlow {
constructor() {
this.description = {
displayName: 'CleverFlow',
name: 'cleverFlow',
icon: 'file:cleverflowhq.svg',
group: ['transform'],
version: 1,
subtitle: '={{$parameter["operation"]}}',
description: 'Create or retrieve a Run in CleverFlow',
defaults: {
name: 'CleverFlow',
},
inputs: [{
type: "main",
}],
outputs: [{
type: "main",
}],
credentials: [
{
name: 'cleverFlowApi',
required: true,
},
],
properties: [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
options: [
{
name: 'Create',
value: 'create',
action: 'Create a run',
description: 'Create a new run in CleverFlow',
},
{
name: 'Get',
value: 'get',
action: 'Get a run',
description: 'Get a run by UID or run ID',
},
{
name: 'Process Tally Form',
value: 'processTallyForm',
action: 'Process tally form webhook',
description: 'Process a Tally form webhook and create a CleverFlow run',
},
],
default: 'create',
},
{
displayName: 'Run Identifier Type',
name: 'runIdentifierType',
type: 'options',
options: [
{
name: 'Run UID (Requires Workspace)',
value: 'uid',
description: 'Identify run by UID within a workspace (e.g., PL-1)',
},
{
name: 'Run ID',
value: 'id',
description: 'Identify run directly by numeric ID (e.g., 110796)',
},
],
default: 'uid',
required: true,
displayOptions: {
show: {
operation: [
'get',
],
},
},
},
{
displayName: 'Workspace Name or ID',
name: 'workspaceId',
type: 'options',
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
typeOptions: {
loadOptionsMethod: 'getWorkspaces',
},
default: '',
required: true,
displayOptions: {
show: {
operation: [
'create',
'processTallyForm',
],
},
},
},
{
displayName: 'Workspace Name or ID',
name: 'workspaceId',
type: 'options',
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
typeOptions: {
loadOptionsMethod: 'getWorkspaces',
},
default: '',
required: true,
displayOptions: {
show: {
operation: [
'get',
],
runIdentifierType: [
'uid',
],
},
},
},
{
displayName: 'Run UID',
name: 'runUid',
type: 'string',
default: '',
required: true,
description: 'The run identifier (e.g., PL-1)',
displayOptions: {
show: {
operation: [
'get',
],
runIdentifierType: [
'uid',
],
},
},
},
{
displayName: 'Run ID',
name: 'runId',
type: 'number',
default: '',
required: true,
description: 'The numeric run identifier (e.g., 110796)',
displayOptions: {
show: {
operation: [
'get',
],
runIdentifierType: [
'id',
],
},
},
},
{
displayName: 'Workflow Name or ID',
name: 'workflowId',
type: 'options',
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
displayOptions: {
show: {
operation: [
'create',
'processTallyForm',
],
},
},
typeOptions: {
loadOptionsDependsOn: ['workspaceId'],
loadOptionsMethod: 'getWorkflows',
},
default: '',
required: true,
},
{
displayName: 'Run Name',
name: 'runName',
type: 'string',
default: '',
description: 'Optional name for this run',
displayOptions: {
show: {
operation: [
'create',
],
},
},
},
{
displayName: 'Run Name',
name: 'runName',
type: 'string',
default: '={{$json.body?.data?.formName || "Tally Form Submission"}} - {{$json.body?.data?.responseId}}',
description: 'Optional name for this run. Default uses the Tally form name and response ID.',
displayOptions: {
show: {
operation: [
'processTallyForm',
],
},
},
},
{
displayName: 'Input Type',
name: 'inputType',
type: 'options',
options: [
{
name: 'Direct Webhook Data',
value: 'direct',
description: 'Process webhook data directly from the input',
},
{
name: 'JSON Field',
value: 'jsonField',
description: 'Process webhook data from a specific JSON field',
},
],
default: 'direct',
required: true,
displayOptions: {
show: {
operation: [
'processTallyForm',
],
},
},
},
{
displayName: 'JSON Field',
name: 'jsonField',
type: 'string',
default: 'body',
description: 'Field name containing the Tally webhook data',
displayOptions: {
show: {
operation: [
'processTallyForm',
],
inputType: [
'jsonField',
],
},
},
},
{
displayName: 'Skip Invalid Fields',
name: 'skipInvalidFields',
type: 'boolean',
default: true,
description: 'Whether or not enabled, fields that cannot be mapped will be skipped instead of causing an error',
displayOptions: {
show: {
operation: [
'processTallyForm',
],
},
},
},
{
displayName: 'Skip Empty Values',
name: 'skipEmptyValues',
type: 'boolean',
default: true,
description: 'Whether or not enabled, fields with empty values will not be sent to CleverFlow',
displayOptions: {
show: {
operation: [
'processTallyForm',
],
},
},
},
{
displayName: 'Data Fields',
name: 'dynamicDataFields',
placeholder: 'Add Field Value',
type: 'fixedCollection',
typeOptions: {
multipleValues: true,
},
default: {},
options: [
{
name: 'fields',
displayName: 'Field',
values: [
{
displayName: 'Field Name or ID',
name: 'field',
type: 'options',
typeOptions: {
loadOptionsDependsOn: ['workspaceId', 'workflowId'],
loadOptionsMethod: 'getWorkflowFields',
},
default: '',
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
required: true,
},
{
displayName: 'Field Value',
name: 'value',
type: 'string',
default: '',
required: true,
},
],
},
],
displayOptions: {
show: {
operation: [
'create',
],
},
},
},
],
};
this.methods = {
loadOptions: {
getWorkspaces: loadOptionsMethods.getWorkspaces,
getWorkflows: loadOptionsMethods.getWorkflows,
getWorkflowFields: loadOptionsMethods.getWorkflowFields,
},
};
}
async execute() {
const operation = this.getNodeParameter('operation', 0);
let responseData;
switch (operation) {
case 'create':
responseData = await create.execute.call(this, 0);
break;
case 'get':
responseData = await get.execute.call(this, 0);
break;
case 'processTallyForm':
responseData = await processTallyForm.execute.call(this, 0);
break;
default:
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `The operation "${operation}" is not supported!`);
}
return [this.helpers.returnJsonArray(responseData)];
}
}
exports.CleverFlow = CleverFlow;
//# sourceMappingURL=CleverFlow.node.js.map