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.

62 lines 2.6 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: 'Callback URL', name: 'callbackUrl', type: 'string', required: true, default: '', description: 'The URL that Octave will call back upon completion of the asynchronous task', placeholder: 'https://example.com/webhook/octave-callback' }, { displayName: 'Agent OId', name: 'agentOId', type: 'string', required: true, default: '', description: 'The OId of the agent to run asynchronously', }, { displayName: 'Inputs (JSON Format)', name: 'inputsJson', type: 'json', default: '{}', description: 'JSON object containing the inputs for the agent run. Structure depends on the agent type (e.g., email, companyDomain, etc.).', placeholder: '{\n "email": "test@example.com",\n "companyDomain": "example.com"\n}', }, ]; const displayOptions = { show: { resource: ['async'], operation: ['runAgent'], }, }; exports.exportedProperties = (0, utils_1.applyDisplayOptions)(displayOptions, properties); async function execute(itemIndex) { const callbackUrl = this.getNodeParameter('callbackUrl', itemIndex); const agentOId = this.getNodeParameter('agentOId', itemIndex); if (!callbackUrl || !agentOId) { throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Callback URL and Agent OId are required for async runAgent.', { itemIndex }); } const inputs = utils_1.parseJsonParameter.call(this, 'inputsJson', itemIndex, '{}'); const body = { callbackUrl, agentOId, inputs, }; const responseData = await OctaveApiRequest_1.octaveApiRequest.call(this, 'POST', '/api/v2/async/agent/run', body); const responseWithMetadata = { data: (responseData === null || responseData === void 0 ? void 0 : responseData.data) !== undefined ? responseData.data : responseData, _metadata: responseData === null || responseData === void 0 ? void 0 : responseData._metadata }; const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseWithMetadata), { itemData: { item: itemIndex } }); return [executionData]; } //# sourceMappingURL=runAgent.operation.js.map