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.
149 lines • 5.9 kB
JavaScript
;
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: 'External name of the buying trigger',
},
{
displayName: 'Internal Name',
name: 'internalName',
type: 'string',
default: '',
description: 'Internal name of the buying trigger (optional)',
},
{
displayName: 'Description',
name: 'description',
type: 'string',
default: '',
description: 'Description of the buying trigger (optional)',
typeOptions: { rows: 3 },
},
{
displayName: 'Why This Creates Urgency (JSON Array)',
name: 'whyThisCreatesUrgency',
type: 'json',
default: '[]',
description: 'String array — why this moment shifts the buyer from passive to active',
typeOptions: { rows: 3 },
},
{
displayName: 'Who Feels This Most (JSON Array)',
name: 'whoFeelsThisMost',
type: 'json',
default: '[]',
description: 'String array — which organizations and roles feel this trigger most',
typeOptions: { rows: 3 },
},
{
displayName: 'What\'s the Cost of Inaction (JSON Array)',
name: 'whatsTheCostOfInaction',
type: 'json',
default: '[]',
description: 'String array — consequences of waiting while this trigger is in play',
typeOptions: { rows: 3 },
},
{
displayName: 'How We Help in This Moment (JSON Array)',
name: 'howWeHelpInThisMoment',
type: 'json',
default: '[]',
description: 'String array — concrete ways the offering maps to this moment',
typeOptions: { rows: 3 },
},
{
displayName: 'Custom Fields (JSON Array)',
name: 'customFields',
type: 'json',
default: '[]',
description: 'JSON array: [{"title": "field", "value": ["item1"]}] (optional)',
typeOptions: { rows: 3 },
},
{
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>.',
},
{
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 this buying trigger 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: ['create'],
},
};
exports.exportedProperties = (0, utils_1.applyDisplayOptions)(displayOptions, properties);
async function execute(itemIndex) {
const body = {};
body.name = this.getNodeParameter('name', itemIndex);
if (!body.name) {
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Name is required.', { itemIndex });
}
const internalName = this.getNodeParameter('internalName', itemIndex);
if (internalName)
body.internalName = internalName;
const description = this.getNodeParameter('description', itemIndex);
if (description)
body.description = description;
const arrFields = ['whyThisCreatesUrgency', 'whoFeelsThisMost', 'whatsTheCostOfInaction', 'howWeHelpInThisMoment'];
for (const f of arrFields) {
const v = utils_1.parseJsonParameter.call(this, f, itemIndex, '[]');
if (Array.isArray(v) && v.length > 0)
body[f] = v;
}
const customFields = utils_1.parseJsonParameter.call(this, 'customFields', itemIndex, '[]');
if (Array.isArray(customFields) && customFields.length > 0)
body.customFields = customFields;
const primaryOfferingOId = this.getNodeParameter('primaryOfferingOId', itemIndex);
if (primaryOfferingOId)
body.primaryOfferingOId = primaryOfferingOId;
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/create', body);
return [this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray([responseData]), { itemData: { item: itemIndex } })];
}
//# sourceMappingURL=create.operation.js.map