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.

132 lines 5.4 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: 'Email', name: 'email', type: 'string', default: '', placeholder: 'name@example.com', description: 'Email address of the person (optional)', }, { 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: 'LinkedIn Profile URL', name: 'linkedInProfile', type: 'string', default: '', description: 'LinkedIn profile URL of the person (optional)', }, { displayName: 'Output Format', name: 'outputFormat', type: 'options', options: [ { name: 'Text', value: 'text' }, { name: 'JSON', value: 'json' }, ], default: 'text', description: 'Desired output format (optional)', }, { displayName: 'Runtime Context (JSON)', name: 'runtimeContext', type: 'json', default: '{}', description: 'Additional JSON context (optional)', }, { displayName: 'Runtime Instructions (JSON)', name: 'runtimeInstructions', type: 'json', default: '{}', description: 'Additional JSON instructions for personalization (optional)', }, { displayName: 'Additional Inputs (JSON)', name: 'additionalInputsJson', type: 'json', default: '{}', description: 'A JSON object for any other inputs the agent might accept (optional)', placeholder: '{\n "customField1": "value1",\n "templateId": "xyz123"\n}', }, ]; const displayOptions = { show: { resource: ['agent'], operation: ['personalizeTemplate'], }, }; 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 runtimeContextString = this.getNodeParameter('runtimeContext', itemIndex, '{}'); if (runtimeContextString && runtimeContextString.trim() !== '{}' && runtimeContextString.trim() !== '') { body.runtimeContext = utils_1.parseJsonParameter.call(this, 'runtimeContext', itemIndex, '{}'); } const additionalInputs = utils_1.parseJsonParameter.call(this, 'additionalInputsJson', itemIndex, '{}'); 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.outputFormat = this.getNodeParameter('outputFormat', itemIndex, 'text'); const runtimeInstructionsString = this.getNodeParameter('runtimeInstructions', itemIndex, '{}'); if (runtimeInstructionsString && runtimeInstructionsString.trim() !== '{}' && runtimeInstructionsString.trim() !== '') { body.runtimeInstructions = utils_1.parseJsonParameter.call(this, 'runtimeInstructions', itemIndex, '{}'); } const finalBody = { ...body, ...additionalInputs }; Object.keys(finalBody).forEach(key => (finalBody[key] === undefined) && delete finalBody[key]); const responseDataOuter = await OctaveApiRequest_1.octaveApiRequest.call(this, 'POST', '/api/v2/agents/personalize-template/run', finalBody); 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=personalizeTemplate.operation.js.map