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.

301 lines 9.97 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: 'Agent OId Name or ID', name: 'agentOId', type: 'options', required: true, typeOptions: { loadOptionsMethod: 'getAgents' }, default: '', description: 'The OId of the agent to run. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.', }, { displayName: 'Company Domain', name: 'companyDomain', type: 'string', default: '', description: 'Company domain (e.g., example.com) (optional)', }, { displayName: 'Company Name', name: 'companyName', type: 'string', default: '', description: 'Name of the company (optional)', }, { displayName: 'LinkedIn Profile URL', name: 'linkedInProfile', type: 'string', default: '', description: 'LinkedIn profile URL of the person (optional)', hint: 'LinkedIn profile is the preferred input method over email for better enrichment results' }, { displayName: 'First Name', name: 'firstName', type: 'string', default: '', description: 'First name of the person (optional)', }, { displayName: 'Job Title', name: 'jobTitle', type: 'string', default: '', description: 'Job title of the person (optional)', }, { displayName: 'Email', name: 'email', type: 'string', default: '', placeholder: 'name@example.com', description: 'Email address of the person (optional)', }, { displayName: 'Language', name: 'lang', type: 'string', default: '', description: 'Language code for the sequence (e.g., en, es) (optional)', }, { displayName: 'Output Format', name: 'outputFormat', type: 'options', options: [ { name: 'Text', value: 'text' }, { name: 'HTML', value: 'html' }, { name: 'Markdown', value: 'markdown' }, ], default: 'text', description: 'Desired output format (optional)', }, { displayName: 'Runtime Context - All Steps', name: 'runtimeContextAll', type: 'string', typeOptions: { rows: 3, }, default: '', description: 'Context to apply to all steps in the sequence (optional)', }, { displayName: 'Runtime Context - Step 1', name: 'runtimeContextStep1', type: 'string', typeOptions: { rows: 2, }, default: '', description: 'Context specific to step 1 (optional)', }, { displayName: 'Runtime Context - Step 2', name: 'runtimeContextStep2', type: 'string', typeOptions: { rows: 2, }, default: '', description: 'Context specific to step 2 (optional)', }, { displayName: 'Runtime Context - Step 3', name: 'runtimeContextStep3', type: 'string', typeOptions: { rows: 2, }, default: '', description: 'Context specific to step 3 (optional)', }, { displayName: 'Runtime Context - Step 4', name: 'runtimeContextStep4', type: 'string', typeOptions: { rows: 2, }, default: '', description: 'Context specific to step 4 (optional)', }, { displayName: 'Runtime Context - Step 5', name: 'runtimeContextStep5', type: 'string', typeOptions: { rows: 2, }, default: '', description: 'Context specific to step 5 (optional)', }, { displayName: 'Runtime Context - Step 6', name: 'runtimeContextStep6', type: 'string', typeOptions: { rows: 2, }, default: '', description: 'Context specific to step 6 (optional)', }, { displayName: 'Runtime Context - Step 7', name: 'runtimeContextStep7', type: 'string', typeOptions: { rows: 2, }, default: '', description: 'Context specific to step 7 (optional)', }, { displayName: 'Runtime Instructions - All Steps', name: 'runtimeInstructionsAll', type: 'string', typeOptions: { rows: 3, }, default: '', description: 'Instructions to apply to all steps in the sequence (optional)', }, { displayName: 'Runtime Instructions - Step 1', name: 'runtimeInstructionsStep1', type: 'string', typeOptions: { rows: 2, }, default: '', description: 'Instructions specific to step 1 (optional)', }, { displayName: 'Runtime Instructions - Step 2', name: 'runtimeInstructionsStep2', type: 'string', typeOptions: { rows: 2, }, default: '', description: 'Instructions specific to step 2 (optional)', }, { displayName: 'Runtime Instructions - Step 3', name: 'runtimeInstructionsStep3', type: 'string', typeOptions: { rows: 2, }, default: '', description: 'Instructions specific to step 3 (optional)', }, { displayName: 'Runtime Instructions - Step 4', name: 'runtimeInstructionsStep4', type: 'string', typeOptions: { rows: 2, }, default: '', description: 'Instructions specific to step 4 (optional)', }, { displayName: 'Runtime Instructions - Step 5', name: 'runtimeInstructionsStep5', type: 'string', typeOptions: { rows: 2, }, default: '', description: 'Instructions specific to step 5 (optional)', }, { displayName: 'Runtime Instructions - Step 6', name: 'runtimeInstructionsStep6', type: 'string', typeOptions: { rows: 2, }, default: '', description: 'Instructions specific to step 6 (optional)', }, { displayName: 'Runtime Instructions - Step 7', name: 'runtimeInstructionsStep7', type: 'string', typeOptions: { rows: 2, }, default: '', description: 'Instructions specific to step 7 (optional)', }, ]; const displayOptions = { show: { resource: ['agent'], operation: ['runSequence'], }, }; exports.exportedProperties = (0, utils_1.applyDisplayOptions)(displayOptions, properties); async function execute(itemIndex) { const body = {}; const agentOId = this.getNodeParameter('agentOId', itemIndex); if (!agentOId) { throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Agent OId is required for this operation.', { itemIndex }); } body.agentOId = agentOId; const runtimeContext = {}; const runtimeContextAll = this.getNodeParameter('runtimeContextAll', itemIndex, ''); if (runtimeContextAll && runtimeContextAll.trim() !== '') { runtimeContext['all'] = runtimeContextAll; } for (let i = 1; i <= 7; i++) { const stepContext = this.getNodeParameter(`runtimeContextStep${i}`, itemIndex, ''); if (stepContext && stepContext.trim() !== '') { runtimeContext[i.toString()] = stepContext; } } if (Object.keys(runtimeContext).length > 0) { body.runtimeContext = runtimeContext; } const runtimeInstructions = {}; const runtimeInstructionsAll = this.getNodeParameter('runtimeInstructionsAll', itemIndex, ''); if (runtimeInstructionsAll && runtimeInstructionsAll.trim() !== '') { runtimeInstructions['all'] = runtimeInstructionsAll; } for (let i = 1; i <= 7; i++) { const stepInstructions = this.getNodeParameter(`runtimeInstructionsStep${i}`, itemIndex, ''); if (stepInstructions && stepInstructions.trim() !== '') { runtimeInstructions[i.toString()] = stepInstructions; } } if (Object.keys(runtimeInstructions).length > 0) { body.runtimeInstructions = runtimeInstructions; } body.companyDomain = this.getNodeParameter('companyDomain', itemIndex); body.companyName = this.getNodeParameter('companyName', itemIndex); body.email = this.getNodeParameter('email', itemIndex); body.jobTitle = this.getNodeParameter('jobTitle', itemIndex); body.firstName = this.getNodeParameter('firstName', itemIndex); body.linkedInProfile = this.getNodeParameter('linkedInProfile', itemIndex); body.lang = this.getNodeParameter('lang', itemIndex); body.outputFormat = this.getNodeParameter('outputFormat', itemIndex, 'text'); Object.keys(body).forEach(key => (body[key] === undefined) && delete body[key]); const responseDataOuter = await OctaveApiRequest_1.octaveApiRequest.call(this, 'POST', '/api/v2/agents/sequence/run', body); const responseWithMetadata = { data: (responseDataOuter === null || responseDataOuter === void 0 ? void 0 : responseDataOuter.data) !== undefined ? responseDataOuter.data : responseDataOuter, _metadata: responseDataOuter === null || responseDataOuter === void 0 ? void 0 : responseDataOuter._metadata }; const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseWithMetadata), { itemData: { item: itemIndex } }); return [executionData]; } //# sourceMappingURL=runSequence.operation.js.map