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.
58 lines • 2.42 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: 'Callback URL',
name: 'callbackUrl',
type: 'string',
required: true,
default: '',
description: 'The URL that Octave will call back upon completion of the email generation',
placeholder: 'https://example.com/webhook/octave-email-callback'
},
{
displayName: 'Agent OID (Email Agent)',
name: 'agentOId',
type: 'string',
required: true,
default: '',
description: 'The OId of the email agent to use for asynchronous generation',
},
{
displayName: 'Email Generation Inputs (JSON Format)',
name: 'emailInputsJson',
type: 'json',
default: '{}',
description: 'JSON object containing inputs for email generation (e.g., email, firstName, companyName, etc.)',
placeholder: '{\n "email": "target@example.com",\n "firstName": "John",\n "companyName": "Acme Corp"\n}',
},
];
const displayOptions = {
show: {
resource: ['async'],
operation: ['generateHeadlessEmails'],
},
};
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 email generation.', { itemIndex });
}
const inputs = utils_1.parseJsonParameter.call(this, 'emailInputsJson', itemIndex, '{}');
const body = {
callbackUrl,
agentOId,
inputs,
};
const responseData = await OctaveApiRequest_1.octaveApiRequest.call(this, 'POST', '/api/v2/async/headless/generate-emails', body);
const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray([responseData]), { itemData: { item: itemIndex } });
return [executionData];
}
//# sourceMappingURL=generateHeadlessEmails.operation.js.map