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.
331 lines • 12.5 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.exportedProperties = void 0;
exports.execute = execute;
const OctaveApiRequest_1 = require("../../transport/OctaveApiRequest");
const utils_1 = require("../utils");
const properties = [
{
displayName: 'Sequence: Steps',
name: 'sequenceSteps',
type: 'number',
typeOptions: { minValue: 1 },
default: 4,
description: 'Number of steps in the email sequence',
},
{
displayName: 'Sequence: Length',
name: 'sequenceLength',
type: 'options',
options: [
{ name: 'Short', value: 'SHORT' },
{ name: 'Medium', value: 'MEDIUM' },
{ name: 'Long', value: 'LONG' },
{ name: 'Mixed', value: 'MIXED' },
],
default: 'MIXED',
description: 'Length of the emails in the sequence',
},
{
displayName: 'Sequence: Type',
name: 'sequenceType',
type: 'options',
options: [
{ name: 'Cold Outbound', value: 'COLD_OUTBOUND' },
{ name: 'Follow Up', value: 'FOLLOW_UP' },
],
default: 'COLD_OUTBOUND',
description: 'Type of the email sequence',
},
{
displayName: 'Sequence: Primary Goal',
name: 'sequencePrimaryGoal',
type: 'options',
options: [
{ name: 'Initiate Conversation', value: 'INITIATE_CONVERSATION' },
{ name: 'Book Meeting', value: 'BOOK_MEETING' },
],
default: 'INITIATE_CONVERSATION',
description: 'Primary goal of the email sequence',
},
{
displayName: 'Sequence: Generate Unique Subject Lines',
name: 'sequenceGenerateUniqueSubjectLines',
type: 'boolean',
default: true,
description: 'Whether to generate unique subject lines for each email in the sequence',
},
{
displayName: 'Sequence: Additional Instructions',
name: 'sequenceAdditionalInstructions',
type: 'string',
typeOptions: { rows: 3 },
default: '',
description: 'Additional instructions for the sequence generation',
},
{
displayName: 'Sequence: Example for Intro Email',
name: 'sequenceExampleForIntroEmail',
type: 'string',
typeOptions: { rows: 4 },
default: '',
description: 'Example text for the first email in the sequence',
},
{
displayName: 'Sequence: Example for Final Email',
name: 'sequenceExampleForFinalEmail',
type: 'string',
typeOptions: { rows: 4 },
default: '',
description: 'Example text for the final email in the sequence',
},
{
displayName: 'Offering: URL',
name: 'offeringUrl',
type: 'string',
default: '',
placeholder: 'https://www.example.com',
description: 'URL of the product/service offering',
},
{
displayName: 'Offering: Name',
name: 'offeringName',
type: 'string',
default: '',
placeholder: 'Example product/service',
description: 'Name of the product/service offering',
},
{
displayName: 'Offering: Core Value Proposition (JSON or Text)',
name: 'offeringCoreValueProposition',
type: 'string',
typeOptions: { rows: 3 },
default: '',
description: 'Core value proposition of the offering. Can be simple text or a JSON string.',
},
{
displayName: 'Offering: Key Differentiator (JSON or Text)',
name: 'offeringKeyDifferentiator',
type: 'string',
typeOptions: { rows: 3 },
default: '',
description: 'Key differentiator of the offering. Can be simple text or a JSON string.',
},
{
displayName: 'Offering: Customer Outcomes (JSON or Text)',
name: 'offeringCustomerOutcomes',
type: 'string',
typeOptions: { rows: 3 },
default: '',
description: 'Customer outcomes achieved with the offering. Can be simple text or a JSON string.',
},
{
displayName: 'Offering: Additional Info (JSON or Text)',
name: 'offeringAdditionalOfferingInfo',
type: 'string',
typeOptions: { rows: 3 },
default: '',
description: 'Additional information about the offering. Can be simple text or a JSON string.',
},
{
displayName: 'Recipient: First Name',
name: 'recipientFirstName',
type: 'string',
default: '',
placeholder: 'John',
description: 'First name of the email recipient',
},
{
displayName: 'Recipient: Job Title',
name: 'recipientJobTitle',
type: 'string',
default: '',
placeholder: 'Example title',
description: 'Job title of the email recipient',
},
{
displayName: 'Recipient: LinkedIn Profile URL',
name: 'recipientLinkedInProfile',
type: 'string',
default: '',
placeholder: 'https://www.linkedin.com/in/example',
description: 'LinkedIn profile URL of the recipient',
},
{
displayName: 'Recipient: Additional Info',
name: 'recipientAdditionalRecipientInfo',
type: 'string',
typeOptions: { rows: 3 },
default: '',
description: 'Additional information about the recipient',
},
{
displayName: 'Recipient: Company Name',
name: 'recipientCompanyName',
type: 'string',
default: '',
placeholder: 'Example company name',
description: 'Company name of the recipient',
},
{
displayName: 'Recipient: Company Domain',
name: 'recipientCompanyDomain',
type: 'string',
default: '',
placeholder: 'example.com',
description: 'Company domain of the recipient',
},
{
displayName: 'Sender: First Name',
name: 'senderFirstName',
type: 'string',
default: '',
description: 'First name of the sender',
},
{
displayName: 'Sender: Last Name',
name: 'senderLastName',
type: 'string',
default: '',
description: 'Last name of the sender',
},
{
displayName: 'Sender: Job Title',
name: 'senderJobTitle',
type: 'string',
default: '',
description: 'Job title of the sender',
},
{
displayName: 'Sender: Company Name',
name: 'senderCompanyName',
type: 'string',
default: '',
description: 'Company name of the sender',
},
{
displayName: 'Sender: Company Domain',
name: 'senderCompanyDomain',
type: 'string',
default: '',
description: 'Company domain of the sender',
},
{
displayName: 'Email: Language',
name: 'emailLanguage',
type: 'string',
default: 'en',
description: 'Language for email generation (e.g., en, es)',
},
{
displayName: 'Email: Tone',
name: 'emailTone',
type: 'string',
default: 'Professional',
description: 'Desired tone of the email (e.g., Professional, Casual, Persuasive)',
},
{
displayName: 'Email: Style',
name: 'emailStyle',
type: 'string',
default: 'Concise',
description: 'Writing style of the email (e.g., Concise, Detailed)',
},
{
displayName: 'Email: Output Format',
name: 'emailOutputFormat',
type: 'options',
options: [
{ name: 'Text', value: 'TEXT' },
{ name: 'HTML', value: 'HTML' },
{ name: 'Markdown', value: 'MARKDOWN' },
],
default: 'TEXT',
description: 'Desired output format for the generated emails',
},
{
displayName: 'Email: Persona',
name: 'emailPersona',
type: 'string',
default: '',
description: 'Specific persona to adopt for email generation (optional)',
},
{
displayName: 'Additional Context (JSON)',
name: 'additionalContextJson',
type: 'json',
default: '{}',
description: 'A JSON object for any other contextual information or custom fields',
placeholder: '{\n "customVariable1": "customValue1",\n "integrationId": "int_123xyz"\n}',
},
];
const displayOptions = {
show: {
resource: ['headless'],
operation: ['generateEmails'],
},
};
exports.exportedProperties = (0, utils_1.applyDisplayOptions)(displayOptions, properties);
async function execute(itemIndex) {
const sequence = {
steps: this.getNodeParameter('sequenceSteps', itemIndex, 4),
length: this.getNodeParameter('sequenceLength', itemIndex, 'MIXED'),
type: this.getNodeParameter('sequenceType', itemIndex, 'COLD_OUTBOUND'),
primaryGoal: this.getNodeParameter('sequencePrimaryGoal', itemIndex, 'INITIATE_CONVERSATION'),
generateUniqueSubjectLines: this.getNodeParameter('sequenceGenerateUniqueSubjectLines', itemIndex, true),
additionalInstructions: this.getNodeParameter('sequenceAdditionalInstructions', itemIndex),
exampleForIntroEmail: this.getNodeParameter('sequenceExampleForIntroEmail', itemIndex),
exampleForFinalEmail: this.getNodeParameter('sequenceExampleForFinalEmail', itemIndex),
};
const offering = {
url: this.getNodeParameter('offeringUrl', itemIndex),
name: this.getNodeParameter('offeringName', itemIndex),
coreValueProposition: this.getNodeParameter('offeringCoreValueProposition', itemIndex),
keyDifferentiator: this.getNodeParameter('offeringKeyDifferentiator', itemIndex),
customerOutcomes: this.getNodeParameter('offeringCustomerOutcomes', itemIndex),
additionalOfferingInfo: this.getNodeParameter('offeringAdditionalOfferingInfo', itemIndex),
};
const recipient = {
firstName: this.getNodeParameter('recipientFirstName', itemIndex),
jobTitle: this.getNodeParameter('recipientJobTitle', itemIndex),
linkedInProfile: this.getNodeParameter('recipientLinkedInProfile', itemIndex),
additionalRecipientInfo: this.getNodeParameter('recipientAdditionalRecipientInfo', itemIndex),
companyName: this.getNodeParameter('recipientCompanyName', itemIndex),
companyDomain: this.getNodeParameter('recipientCompanyDomain', itemIndex),
};
const sender = {
firstName: this.getNodeParameter('senderFirstName', itemIndex),
lastName: this.getNodeParameter('senderLastName', itemIndex),
jobTitle: this.getNodeParameter('senderJobTitle', itemIndex),
companyName: this.getNodeParameter('senderCompanyName', itemIndex),
companyDomain: this.getNodeParameter('senderCompanyDomain', itemIndex),
};
const emailDetails = {
lang: this.getNodeParameter('emailLanguage', itemIndex, 'en'),
tone: this.getNodeParameter('emailTone', itemIndex, 'Professional'),
style: this.getNodeParameter('emailStyle', itemIndex, 'Concise'),
outputFormat: this.getNodeParameter('emailOutputFormat', itemIndex, 'TEXT'),
persona: this.getNodeParameter('emailPersona', itemIndex),
};
const additionalContext = utils_1.parseJsonParameter.call(this, 'additionalContextJson', itemIndex, '{}');
const body = {
sequence,
offering,
recipient,
sender,
email: emailDetails,
additionalContext,
};
Object.keys(sequence).forEach(key => sequence[key] === undefined && delete sequence[key]);
Object.keys(offering).forEach(key => offering[key] === undefined && delete offering[key]);
Object.keys(recipient).forEach(key => recipient[key] === undefined && delete recipient[key]);
Object.keys(sender).forEach(key => sender[key] === undefined && delete sender[key]);
Object.keys(emailDetails).forEach(key => emailDetails[key] === undefined && delete emailDetails[key]);
if (Object.keys(additionalContext).length === 0) {
delete body.additionalContext;
}
const responseData = await OctaveApiRequest_1.octaveApiRequest.call(this, 'POST', '/api/v2/headless/generate-emails', body);
const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray([responseData]), { itemData: { item: itemIndex } });
return [executionData];
}
//# sourceMappingURL=generateEmails.operation.js.map