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.
130 lines • 4.96 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: 'Name for the solution',
},
{
displayName: 'Sources',
name: 'sources',
type: 'fixedCollection',
placeholder: 'Add Source',
typeOptions: { multipleValues: true },
default: {},
description: 'Source materials (at least one required)',
options: [
{
displayName: 'Source',
name: 'source',
values: [
{
displayName: 'Type',
name: 'type',
type: 'options',
options: [
{ name: 'Company Name', value: 'COMPANY_NAME' },
{ name: 'Generative Name', value: 'GENERATIVE_NAME' },
{ name: 'OId', value: 'OID' },
{ name: 'Resource', value: 'RESOURCE' },
{ name: 'Text', value: 'TEXT' },
{ name: 'URL', value: 'URL' },
],
default: 'TEXT',
},
{
displayName: 'Value',
name: 'value',
type: 'string',
default: '',
typeOptions: { rows: 3 },
},
{
displayName: 'Name',
name: 'name',
type: 'string',
default: '',
},
{
displayName: 'Details',
name: 'details',
type: 'string',
default: '',
},
],
},
],
},
{
displayName: 'Instructions',
name: 'instructions',
type: 'string',
default: '',
description: 'Optional generation instructions',
typeOptions: { rows: 3 },
},
{
displayName: 'Brand Voice OId',
name: 'brandVoiceOId',
type: 'string',
default: '',
description: 'Brand voice to apply (optional)',
},
{
displayName: 'Enable RAG Enrichment',
name: 'enableRagEnrichment',
type: 'boolean',
default: false,
},
{
displayName: 'Linked Entity OIds (JSON)',
name: 'linkedEntities',
type: 'json',
default: '{}',
description: 'Optional object with OId arrays: offeringOIds, useCaseOIds, personaOIds, segmentOIds, referenceOIds, collateralOIds, competitorOIds, alternativeOIds, buyingTriggerOIds, proofPointOIds, genericTextEntityOIds',
typeOptions: { rows: 6 },
},
];
const displayOptions = {
show: {
resource: ['solution'],
operation: ['generate'],
},
};
exports.exportedProperties = (0, utils_1.applyDisplayOptions)(displayOptions, properties);
async function execute(itemIndex) {
const name = this.getNodeParameter('name', itemIndex);
if (!name) {
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Name is required.', { itemIndex });
}
const sourcesRaw = this.getNodeParameter('sources', itemIndex);
const sources = (sourcesRaw === null || sourcesRaw === void 0 ? void 0 : sourcesRaw.source) || [];
if (sources.length === 0) {
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'At least one source is required.', { itemIndex });
}
const body = { name, sources };
const instructions = this.getNodeParameter('instructions', itemIndex);
if (instructions)
body.instructions = instructions;
const brandVoiceOId = this.getNodeParameter('brandVoiceOId', itemIndex);
if (brandVoiceOId)
body.brandVoiceOId = brandVoiceOId;
body.enableRagEnrichment = this.getNodeParameter('enableRagEnrichment', itemIndex);
const linked = utils_1.parseJsonParameter.call(this, 'linkedEntities', itemIndex, '{}');
for (const k of Object.keys(linked || {})) {
if (Array.isArray(linked[k]) && linked[k].length > 0)
body[k] = linked[k];
}
const responseData = await OctaveApiRequest_1.octaveApiRequest.call(this, 'POST', '/api/v2/solution/generate', body);
return [this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray([responseData]), { itemData: { item: itemIndex } })];
}
//# sourceMappingURL=generate.operation.js.map