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.

148 lines 6.41 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: 'Primary Offering Name or ID', name: 'primaryOfferingOId', type: 'options', typeOptions: { loadOptionsMethod: 'getProducts' }, default: '', description: 'Primary offering for context (optional). Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.', hint: 'If not provided, the primary company attached to the Workspace will be used.', }, { displayName: 'Buying Trigger Generation Requests', name: 'buyingTriggers', type: 'fixedCollection', placeholder: 'Add Buying Trigger', typeOptions: { multipleValues: true }, default: {}, description: 'Each request generates one buying trigger', options: [ { displayName: 'Buying Trigger', name: 'buyingTrigger', values: [ { displayName: 'Name', name: 'name', type: 'string', default: '', description: 'Optional name; if provided, used as the entity name', }, { displayName: 'Sources', name: 'sources', type: 'fixedCollection', placeholder: 'Add Source', typeOptions: { multipleValues: true }, default: {}, options: [ { displayName: 'Source', name: 'source', values: [ { displayName: 'Type', name: 'type', type: 'options', options: [ { name: 'Text', value: 'TEXT' }, { name: 'URL', value: 'URL' }, { name: 'Resource', value: 'RESOURCE' }, ], default: 'TEXT', }, { displayName: 'Value', name: 'value', type: 'string', default: '', typeOptions: { rows: 3 }, }, ], }, ], }, ], }, ], }, { displayName: 'Brand Voice OId', name: 'brandVoiceOId', type: 'string', default: '', description: 'Brand voice OId to apply to generated buying triggers (optional)', }, { displayName: 'Linking Strategy Mode', name: 'linkingMode', type: 'options', options: [ { name: 'None', value: 'NONE' }, { name: 'All Products', value: 'ALL' }, { name: 'Specific Products', value: 'SPECIFIC' }, ], default: 'NONE', description: 'Strategy for linking generated buying triggers to products', }, { displayName: 'Product Names or IDs', name: 'offeringOIds', type: 'multiOptions', typeOptions: { loadOptionsMethod: 'getProducts' }, default: [], description: 'Products to link to (required when using Specific Products mode). Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.', displayOptions: { show: { linkingMode: ['SPECIFIC'] }, }, }, ]; const displayOptions = { show: { resource: ['buyingTrigger'], operation: ['generate'], }, }; exports.exportedProperties = (0, utils_1.applyDisplayOptions)(displayOptions, properties); async function execute(itemIndex) { const body = {}; const primaryOfferingOId = this.getNodeParameter('primaryOfferingOId', itemIndex); if (primaryOfferingOId) body.primaryOfferingOId = primaryOfferingOId; const triggersRaw = this.getNodeParameter('buyingTriggers', itemIndex); const triggers = ((triggersRaw === null || triggersRaw === void 0 ? void 0 : triggersRaw.buyingTrigger) || []).map(t => { var _a; return ({ name: t.name, sources: ((_a = t.sources) === null || _a === void 0 ? void 0 : _a.source) || [], }); }); if (triggers.length === 0) { throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'At least one buying trigger generation request is required.', { itemIndex }); } body.buyingTriggers = triggers; const brandVoiceOId = this.getNodeParameter('brandVoiceOId', itemIndex); if (brandVoiceOId) body.brandVoiceOId = brandVoiceOId; const linkingMode = this.getNodeParameter('linkingMode', itemIndex); if (linkingMode === 'ALL') { body.linkingStrategy = { mode: 'ALL' }; } else if (linkingMode === 'SPECIFIC') { const offeringOIds = this.getNodeParameter('offeringOIds', itemIndex); if (!offeringOIds || offeringOIds.length === 0) { throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Products are required when using Specific Products mode.', { itemIndex }); } body.linkingStrategy = { mode: 'SPECIFIC', offeringOIds }; } const responseData = await OctaveApiRequest_1.octaveApiRequest.call(this, 'POST', '/api/v2/buying-trigger/generate', body); return [this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray([responseData]), { itemData: { item: itemIndex } })]; } //# sourceMappingURL=generate.operation.js.map