UNPKG

n8n-nodes-octavehq

Version:

Octave is the AI-powered messaging brain for B2B go-to-market teams, helping articulate product value, synthesize customer interaction data, and deploy consistent, effective messaging across all channels.

111 lines 4.32 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.exportedProperties = void 0; exports.execute = execute; const n8n_workflow_1 = require("n8n-workflow"); const OctaveApiRequest_1 = require("../../transport/OctaveApiRequest"); const utils_1 = require("../utils"); const properties = [ { displayName: 'Name', name: 'name', type: 'string', required: true, default: '', description: 'Name of the experiment', }, { displayName: 'Description', name: 'description', type: 'string', default: '', description: 'Description of the experiment', }, { displayName: 'Agent Type', name: 'agentType', type: 'options', required: true, default: 'CONTENT', options: [ { name: 'Call Prep', value: 'CALL_PREP' }, { name: 'Content', value: 'CONTENT' }, { name: 'Email', value: 'EMAIL' }, { name: 'Enrich Company', value: 'ENRICH_COMPANY' }, { name: 'Enrich Person', value: 'ENRICH_PERSON' }, { name: 'Prospector', value: 'PROSPECTOR' }, { name: 'Qualify Company', value: 'QUALIFY_COMPANY' }, { name: 'Qualify Person', value: 'QUALIFY_PERSON' }, ], description: 'Type of agent for the experiment', }, { displayName: 'Run Strategy', name: 'runStrategy', type: 'options', required: true, default: 'RANDOM', options: [ { name: 'Random', value: 'RANDOM' }, { name: 'Round Robin', value: 'ROUND_ROBIN' }, { name: 'Weighted', value: 'WEIGHTED' }, ], description: 'Strategy for running the experiment', }, { displayName: 'Agent OIds', name: 'agentOIds', type: 'string', required: true, default: '', description: 'Comma-separated list of agent OIds to include in the experiment', }, { displayName: 'Weights', name: 'weights', type: 'json', default: '[]', displayOptions: { show: { runStrategy: ['WEIGHTED'], }, }, description: 'Array of weight objects for weighted strategy: [{"oId": "agent_id", "weight": 0.5}]', }, ]; const displayOptions = { show: { resource: ['experiment'], operation: ['create'], }, }; exports.exportedProperties = (0, utils_1.applyDisplayOptions)(displayOptions, properties); async function execute(itemIndex) { const body = {}; const name = this.getNodeParameter('name', itemIndex); if (!name) { throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Name is required for this operation.', { itemIndex }); } body.name = name; body.description = this.getNodeParameter('description', itemIndex); body.agentType = this.getNodeParameter('agentType', itemIndex); body.runStrategy = this.getNodeParameter('runStrategy', itemIndex); const agentOIds = this.getNodeParameter('agentOIds', itemIndex); if (!agentOIds) { throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Agent OIds are required for this operation.', { itemIndex }); } body.agentOIds = agentOIds.split(',').map((id) => id.trim()); const runStrategy = body.runStrategy; if (runStrategy === 'WEIGHTED') { const weightsString = this.getNodeParameter('weights', itemIndex, '[]'); if (weightsString && weightsString.trim() !== '[]' && weightsString.trim() !== '') { body.weights = utils_1.parseJsonParameter.call(this, 'weights', itemIndex, '[]'); } } Object.keys(body).forEach(key => (body[key] === undefined) && delete body[key]); const responseDataOuter = await OctaveApiRequest_1.octaveApiRequest.call(this, 'POST', '/api/v2/agents/experiment/create', body); const responseDataInner = responseDataOuter === null || responseDataOuter === void 0 ? void 0 : responseDataOuter.data; const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseDataInner || responseDataOuter || {}), { itemData: { item: itemIndex } }); return [executionData]; } //# sourceMappingURL=create.operation.js.map