first commit
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled

This commit is contained in:
2026-03-17 16:22:57 +03:30
commit 3d5eaf9445
15349 changed files with 2847338 additions and 0 deletions
@@ -0,0 +1,616 @@
import type { INodeProperties } from 'n8n-workflow';
export const contactOperations: INodeProperties[] = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['contact'],
},
},
options: [
{
name: 'Create',
value: 'create',
description: 'Create a new contact',
action: 'Create a contact',
},
{
name: 'Delete',
value: 'delete',
description: 'Delete a contact',
action: 'Delete a contact',
},
{
name: 'Get',
value: 'get',
description: 'Get a contact',
action: 'Get a contact',
},
{
name: 'Get Many',
value: 'getAll',
description: 'Get many contacts',
action: 'Get many contacts',
},
{
name: 'Update',
value: 'update',
description: 'Update contact properties',
action: 'Update a contact',
},
],
default: 'get',
},
];
export const contactFields: INodeProperties[] = [
/* -------------------------------------------------------------------------- */
/* contact:create */
/* -------------------------------------------------------------------------- */
{
displayName: 'Email',
name: 'email',
type: 'string',
placeholder: 'name@email.com',
displayOptions: {
show: {
resource: ['contact'],
operation: ['create'],
},
},
default: '',
},
{
displayName: 'Campaign Name or ID',
name: 'campaignId',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getCampaigns',
},
displayOptions: {
show: {
resource: ['contact'],
operation: ['create'],
},
},
default: '',
description:
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
},
{
displayName: 'Additional Fields',
name: 'additionalFields',
type: 'collection',
placeholder: 'Add Field',
default: {},
displayOptions: {
show: {
resource: ['contact'],
operation: ['create'],
},
},
options: [
{
displayName: 'Custom Fields',
name: 'customFieldsUi',
type: 'fixedCollection',
default: {},
placeholder: 'Add Custom Field',
typeOptions: {
multipleValues: true,
},
options: [
{
name: 'customFieldValues',
displayName: 'Custom Field',
values: [
{
displayName: 'Field Name or ID',
name: 'customFieldId',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getCustomFields',
},
description:
'The end user specified key of the user defined data. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
default: '',
},
{
displayName: 'Value',
name: 'value',
type: 'string',
description: 'The end user specified value of the user defined data',
default: '',
},
],
},
],
},
{
displayName: 'Day Of Cycle',
name: 'dayOfCycle',
type: 'string',
description:
'The day on which the contact is in the Autoresponder cycle. null indicates the contacts is not in the cycle.',
default: '',
},
{
displayName: 'IP Address',
name: 'ipAddress',
type: 'string',
description: "The contact's IP address. IPv4 and IPv6 formats are accepted.",
default: '',
},
{
displayName: 'Name',
name: 'name',
type: 'string',
default: '',
},
{
displayName: 'Note',
name: 'note',
type: 'string',
default: '',
},
{
displayName: 'Scoring',
name: 'scoring',
type: 'number',
default: '',
description: 'Contact scoring, pass null to remove the score from a contact',
typeOptions: {
minValue: 0,
},
},
{
displayName: 'Tag Names or IDs',
name: 'tags',
type: 'multiOptions',
description:
'Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
typeOptions: {
loadOptionsMethod: 'getTags',
},
default: [],
},
],
},
/* -------------------------------------------------------------------------- */
/* contact:delete */
/* -------------------------------------------------------------------------- */
{
displayName: 'Contact ID',
name: 'contactId',
type: 'string',
required: true,
displayOptions: {
show: {
resource: ['contact'],
operation: ['delete'],
},
},
default: '',
description: 'ID of contact to delete',
},
{
displayName: 'Options',
name: 'options',
type: 'collection',
placeholder: 'Add Field',
default: {},
displayOptions: {
show: {
resource: ['contact'],
operation: ['delete'],
},
},
options: [
{
displayName: 'IP Address',
name: 'ipAddress',
type: 'string',
description:
'This makes it possible to pass the IP from which the contact unsubscribed. Used only if the messageId was send.',
default: '',
},
{
displayName: 'Message ID',
name: 'messageId',
type: 'string',
description:
'The ID of a message (such as a newsletter, an autoresponder, or an RSS-newsletter). When passed, this method will simulate the unsubscribe process, as if the contact clicked the unsubscribe link in a given message.',
default: '',
},
],
},
/* -------------------------------------------------------------------------- */
/* contact:get */
/* -------------------------------------------------------------------------- */
{
displayName: 'Contact ID',
name: 'contactId',
type: 'string',
required: true,
displayOptions: {
show: {
resource: ['contact'],
operation: ['get'],
},
},
default: '',
description: 'Unique identifier for a particular contact',
},
{
displayName: 'Options',
name: 'options',
type: 'collection',
placeholder: 'Add Field',
default: {},
displayOptions: {
show: {
resource: ['contact'],
operation: ['get'],
},
},
options: [
{
displayName: 'Fields',
name: 'fields',
type: 'string',
description:
'List of fields that should be returned. ID is always returned. Fields should be separated by comma',
default: '',
},
],
},
/* -------------------------------------------------------------------------- */
/* contact:getAll */
/* -------------------------------------------------------------------------- */
{
displayName: 'Return All',
name: 'returnAll',
type: 'boolean',
displayOptions: {
show: {
resource: ['contact'],
operation: ['getAll'],
},
},
default: false,
description: 'Whether to return all results or only up to a given limit',
},
{
displayName: 'Limit',
name: 'limit',
type: 'number',
typeOptions: {
minValue: 1,
},
description: 'Max number of results to return',
default: 20,
displayOptions: {
show: {
resource: ['contact'],
operation: ['getAll'],
returnAll: [false],
},
},
},
{
displayName: 'Options',
name: 'options',
type: 'collection',
placeholder: 'Add Field',
default: {},
displayOptions: {
show: {
resource: ['contact'],
operation: ['getAll'],
},
},
options: [
{
displayName: 'Campaign ID',
name: 'campaignId',
type: 'string',
description: 'Search contacts by campaign ID',
default: '',
},
{
displayName: 'Change On From',
name: 'changeOnFrom',
type: 'dateTime',
default: '',
description: 'Search contacts edited from this date',
},
{
displayName: 'Change On To',
name: 'changeOnTo',
type: 'dateTime',
default: '',
description: 'Search contacts edited to this date',
},
{
displayName: 'Created On From',
name: 'createdOnFrom',
type: 'dateTime',
default: '',
description: 'Count data from this date',
},
{
displayName: 'Created On To',
name: 'createdOnTo',
type: 'dateTime',
default: '',
description: 'Count data from this date',
},
{
displayName: 'Exact Match',
name: 'exactMatch',
type: 'boolean',
default: false,
description:
"Whether to search for contacts with the exact value of the email and name provided in the query string. Without this flag, matching is done via a standard 'like' comparison, which may sometimes be slow.",
},
{
displayName: 'Fields',
name: 'fields',
type: 'string',
description:
'List of fields that should be returned. ID is always returned. Fields should be separated by comma',
default: '',
},
{
displayName: 'Name',
name: 'name',
type: 'string',
description: 'Search contacts by name',
default: '',
},
{
displayName: 'Origin',
name: 'origin',
type: 'options',
options: [
{
name: 'API',
value: 'api',
},
{
name: 'Copy',
value: 'copy',
},
{
name: 'Email',
value: 'email',
},
{
name: 'Forward',
value: 'forward',
},
{
name: 'Import',
value: 'import',
},
{
name: 'Iphone',
value: 'iphone',
},
{
name: 'Landing Page',
value: 'landing_page',
},
{
name: 'Leads',
value: 'leads',
},
{
name: 'Panel',
value: 'panel',
},
{
name: 'Sale',
value: 'sale',
},
{
name: 'Survey',
value: 'survey',
},
{
name: 'Webinar',
value: 'webinar',
},
{
name: 'WWW',
value: 'www',
},
],
description: 'Search contacts by origin',
default: '',
},
{
displayName: 'Sort By',
name: 'sortBy',
type: 'options',
options: [
{
name: 'Campaign ID',
value: 'campaignId',
},
{
name: 'Changed On',
value: 'changedOn',
},
{
name: 'Created On',
value: 'createdOn',
},
{
name: 'Email',
value: 'email',
},
],
default: '',
},
{
displayName: 'Sort Order',
name: 'sortOrder',
type: 'options',
options: [
{
name: 'ASC',
value: 'ASC',
},
{
name: 'DESC',
value: 'DESC',
},
],
default: '',
},
],
},
/* -------------------------------------------------------------------------- */
/* contact:update */
/* -------------------------------------------------------------------------- */
{
displayName: 'Contact ID',
name: 'contactId',
type: 'string',
required: true,
displayOptions: {
show: {
resource: ['contact'],
operation: ['update'],
},
},
default: '',
description: 'Unique identifier for a particular contact',
},
{
displayName: 'Update Fields',
name: 'updateFields',
type: 'collection',
placeholder: 'Add Field',
default: {},
displayOptions: {
show: {
resource: ['contact'],
operation: ['update'],
},
},
options: [
{
displayName: 'Campaign Name or ID',
name: 'campaignId',
type: 'options',
description:
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
typeOptions: {
loadOptionsMethod: 'getCampaigns',
},
default: '',
},
{
displayName: 'Custom Fields',
name: 'customFieldsUi',
type: 'fixedCollection',
default: {},
placeholder: 'Add Custom Field',
typeOptions: {
multipleValues: true,
},
options: [
{
name: 'customFieldValues',
displayName: 'Custom Field',
values: [
{
displayName: 'Field Name or ID',
name: 'customFieldId',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getCustomFields',
},
description:
'The end user specified key of the user defined data. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
default: '',
},
{
displayName: 'Value',
name: 'value',
type: 'string',
description: 'The end user specified value of the user defined data',
default: '',
},
],
},
],
},
{
displayName: 'Day Of Cycle',
name: 'dayOfCycle',
type: 'string',
description:
'The day on which the contact is in the Autoresponder cycle. null indicates the contacts is not in the cycle.',
default: '',
},
{
displayName: 'Email',
name: 'email',
type: 'string',
placeholder: 'name@email.com',
default: '',
},
{
displayName: 'IP Address',
name: 'ipAddress',
type: 'string',
description: "The contact's IP address. IPv4 and IPv6 formats are accepted.",
default: '',
},
{
displayName: 'Name',
name: 'name',
type: 'string',
default: '',
},
{
displayName: 'Note',
name: 'note',
type: 'string',
default: '',
},
{
displayName: 'Scoring',
name: 'scoring',
type: 'number',
default: '',
description: 'Contact scoring, pass null to remove the score from a contact',
typeOptions: {
minValue: 0,
},
},
{
displayName: 'Tag Names or IDs',
name: 'tags',
type: 'multiOptions',
description:
'Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
typeOptions: {
loadOptionsMethod: 'getTags',
},
default: [],
},
],
},
];
@@ -0,0 +1,79 @@
import type {
IDataObject,
IExecuteFunctions,
IHookFunctions,
IHttpRequestMethods,
ILoadOptionsFunctions,
IRequestOptions,
IWebhookFunctions,
JsonObject,
} from 'n8n-workflow';
import { NodeApiError } from 'n8n-workflow';
export async function getresponseApiRequest(
this: IWebhookFunctions | IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions,
method: IHttpRequestMethods,
resource: string,
body: any = {},
qs: IDataObject = {},
uri?: string,
option: IDataObject = {},
): Promise<any> {
const authentication = this.getNodeParameter('authentication', 0, 'apiKey') as string;
let options: IRequestOptions = {
headers: {
'Content-Type': 'application/json',
},
method,
body,
qs,
uri: uri || `https://api.getresponse.com/v3${resource}`,
json: true,
};
try {
options = Object.assign({}, options, option);
if (Object.keys(body as IDataObject).length === 0) {
delete options.body;
}
if (authentication === 'apiKey') {
return await this.helpers.requestWithAuthentication.call(this, 'getResponseApi', options);
} else {
return await this.helpers.requestOAuth2.call(this, 'getResponseOAuth2Api', options);
}
} catch (error) {
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
export async function getResponseApiRequestAllItems(
this: IExecuteFunctions | ILoadOptionsFunctions,
method: IHttpRequestMethods,
endpoint: string,
body: any = {},
query: IDataObject = {},
): Promise<any> {
const returnData: IDataObject[] = [];
let responseData;
query.page = 1;
do {
responseData = await getresponseApiRequest.call(
this,
method,
endpoint,
body,
query,
undefined,
{ resolveWithFullResponse: true },
);
query.page++;
returnData.push.apply(returnData, responseData.body as IDataObject[]);
} while (responseData.headers.TotalPages !== responseData.headers.CurrentPage);
return returnData;
}
@@ -0,0 +1,18 @@
{
"node": "n8n-nodes-base.getResponse",
"nodeVersion": "1.0",
"codexVersion": "1.0",
"categories": ["Communication", "Marketing"],
"resources": {
"credentialDocumentation": [
{
"url": "https://docs.n8n.io/integrations/builtin/credentials/getresponse/"
}
],
"primaryDocumentation": [
{
"url": "https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.getresponse/"
}
]
}
}
@@ -0,0 +1,318 @@
import moment from 'moment-timezone';
import type {
IExecuteFunctions,
IDataObject,
ILoadOptionsFunctions,
INodeExecutionData,
INodePropertyOptions,
INodeType,
INodeTypeDescription,
} from 'n8n-workflow';
import { NodeConnectionTypes } from 'n8n-workflow';
import { contactFields, contactOperations } from './ContactDescription';
import { getresponseApiRequest, getResponseApiRequestAllItems } from './GenericFunctions';
export class GetResponse implements INodeType {
description: INodeTypeDescription = {
displayName: 'GetResponse',
name: 'getResponse',
// eslint-disable-next-line n8n-nodes-base/node-class-description-icon-not-svg
icon: 'file:getResponse.png',
group: ['input'],
version: 1,
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
description: 'Consume GetResponse API',
defaults: {
name: 'GetResponse',
},
usableAsTool: true,
inputs: [NodeConnectionTypes.Main],
outputs: [NodeConnectionTypes.Main],
credentials: [
{
name: 'getResponseApi',
required: true,
displayOptions: {
show: {
authentication: ['apiKey'],
},
},
},
{
name: 'getResponseOAuth2Api',
required: true,
displayOptions: {
show: {
authentication: ['oAuth2'],
},
},
},
],
properties: [
{
displayName: 'Authentication',
name: 'authentication',
type: 'options',
options: [
{
name: 'API Key',
value: 'apiKey',
},
{
name: 'OAuth2',
value: 'oAuth2',
},
],
default: 'apiKey',
},
{
displayName: 'Resource',
name: 'resource',
type: 'options',
noDataExpression: true,
options: [
{
name: 'Contact',
value: 'contact',
},
],
default: 'contact',
},
...contactOperations,
...contactFields,
],
};
methods = {
loadOptions: {
// Get all the campaigns to display them to user so that they can
// select them easily
async getCampaigns(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
const campaigns = await getresponseApiRequest.call(this, 'GET', '/campaigns');
for (const campaign of campaigns) {
returnData.push({
name: campaign.name as string,
value: campaign.campaignId,
});
}
return returnData;
},
// Get all the tagd to display them to user so that they can
// select them easily
async getTags(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
const tags = await getresponseApiRequest.call(this, 'GET', '/tags');
for (const tag of tags) {
returnData.push({
name: tag.name as string,
value: tag.tagId,
});
}
return returnData;
},
// Get all the custom fields to display them to user so that they can
// select them easily
async getCustomFields(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
const customFields = await getresponseApiRequest.call(this, 'GET', '/custom-fields');
for (const customField of customFields) {
returnData.push({
name: customField.name as string,
value: customField.customFieldId,
});
}
return returnData;
},
},
};
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
const items = this.getInputData();
const returnData: INodeExecutionData[] = [];
const length = items.length;
const qs: IDataObject = {};
let responseData;
const resource = this.getNodeParameter('resource', 0);
const operation = this.getNodeParameter('operation', 0);
for (let i = 0; i < length; i++) {
try {
if (resource === 'contact') {
//https://apireference.getresponse.com/#operation/createContact
if (operation === 'create') {
const email = this.getNodeParameter('email', i) as string;
const campaignId = this.getNodeParameter('campaignId', i) as string;
const additionalFields = this.getNodeParameter('additionalFields', i);
const body: IDataObject = {
email,
campaign: {
campaignId,
},
};
Object.assign(body, additionalFields);
if (additionalFields.customFieldsUi) {
const customFieldValues = (additionalFields.customFieldsUi as IDataObject)
.customFieldValues as IDataObject[];
if (customFieldValues) {
body.customFieldValues = customFieldValues;
for (let index = 0; index < customFieldValues.length; index++) {
if (!Array.isArray(customFieldValues[index].value)) {
customFieldValues[index].value = [customFieldValues[index].value];
}
}
delete body.customFieldsUi;
}
}
responseData = await getresponseApiRequest.call(this, 'POST', '/contacts', body);
responseData = { success: true };
}
//https://apireference.getresponse.com/?_ga=2.160836350.2102802044.1604719933-1897033509.1604598019#operation/deleteContact
if (operation === 'delete') {
const contactId = this.getNodeParameter('contactId', i) as string;
const options = this.getNodeParameter('options', i);
Object.assign(qs, options);
responseData = await getresponseApiRequest.call(
this,
'DELETE',
`/contacts/${contactId}`,
{},
qs,
);
responseData = { success: true };
}
//https://apireference.getresponse.com/?_ga=2.160836350.2102802044.1604719933-1897033509.1604598019#operation/getContactById
if (operation === 'get') {
const contactId = this.getNodeParameter('contactId', i) as string;
const options = this.getNodeParameter('options', i);
Object.assign(qs, options);
responseData = await getresponseApiRequest.call(
this,
'GET',
`/contacts/${contactId}`,
{},
qs,
);
}
//https://apireference.getresponse.com/?_ga=2.160836350.2102802044.1604719933-1897033509.1604598019#operation/getContactList
if (operation === 'getAll') {
const returnAll = this.getNodeParameter('returnAll', i);
const options = this.getNodeParameter('options', i);
const timezone = this.getTimezone();
Object.assign(qs, options);
const isNotQuery = ['sortBy', 'sortOrder', 'additionalFlags', 'fields', 'exactMatch'];
const isDate = ['createdOnFrom', 'createdOnTo', 'changeOnFrom', 'changeOnTo'];
const dateMapToKey: { [key: string]: string } = {
createdOnFrom: '[createdOn][from]',
createdOnTo: '[createdOn][to]',
changeOnFrom: '[changeOn][from]',
changeOnTo: '[changeOn][to]',
};
for (const key of Object.keys(qs)) {
if (!isNotQuery.includes(key)) {
if (isDate.includes(key)) {
qs[`query${dateMapToKey[key]}`] = moment
.tz(qs[key], timezone)
.format('YYYY-MM-DDTHH:mm:ssZZ');
} else {
qs[`query[${key}]`] = qs[key];
}
delete qs[key];
}
}
if (qs.sortBy) {
qs[`sort[${qs.sortBy}]`] = qs.sortOrder || 'ASC';
}
if (qs.exactMatch === true) {
qs.additionalFlags = 'exactMatch';
delete qs.exactMatch;
}
if (returnAll) {
responseData = await getResponseApiRequestAllItems.call(
this,
'GET',
'/contacts',
{},
qs,
);
} else {
qs.perPage = this.getNodeParameter('limit', i);
responseData = await getresponseApiRequest.call(this, 'GET', '/contacts', {}, qs);
}
}
//https://apireference.getresponse.com/?_ga=2.160836350.2102802044.1604719933-1897033509.1604598019#operation/updateContact
if (operation === 'update') {
const contactId = this.getNodeParameter('contactId', i) as string;
const updateFields = this.getNodeParameter('updateFields', i);
const body: IDataObject = {};
Object.assign(body, updateFields);
if (updateFields.customFieldsUi) {
const customFieldValues = (updateFields.customFieldsUi as IDataObject)
.customFieldValues as IDataObject[];
customFieldValues.forEach((entry) => {
if (typeof entry.value === 'string') {
entry.value = entry.value.split(',').map((value) => value.trim());
}
});
if (customFieldValues) {
body.customFieldValues = customFieldValues;
delete body.customFieldsUi;
}
}
responseData = await getresponseApiRequest.call(
this,
'POST',
`/contacts/${contactId}`,
body,
);
}
}
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray(responseData as IDataObject),
{ itemData: { item: i } },
);
returnData.push(...executionData);
} catch (error) {
if (this.continueOnFail()) {
const executionErrorData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray({ error: error.message }),
{ itemData: { item: i } },
);
returnData.push(...executionErrorData);
continue;
}
throw error;
}
}
return [returnData];
}
}
@@ -0,0 +1,18 @@
{
"node": "n8n-nodes-base.getResponseTrigger",
"nodeVersion": "1.0",
"codexVersion": "1.0",
"categories": ["Communication", "Marketing"],
"resources": {
"credentialDocumentation": [
{
"url": "https://docs.n8n.io/integrations/builtin/credentials/getresponse/"
}
],
"primaryDocumentation": [
{
"url": "https://docs.n8n.io/integrations/builtin/trigger-nodes/n8n-nodes-base.getresponsetrigger/"
}
]
}
}
@@ -0,0 +1,227 @@
import type {
IHookFunctions,
IWebhookFunctions,
IDataObject,
ILoadOptionsFunctions,
INodePropertyOptions,
INodeType,
INodeTypeDescription,
IWebhookResponseData,
JsonObject,
} from 'n8n-workflow';
import { NodeApiError, NodeConnectionTypes } from 'n8n-workflow';
import { getresponseApiRequest, getResponseApiRequestAllItems } from './GenericFunctions';
export class GetResponseTrigger implements INodeType {
description: INodeTypeDescription = {
displayName: 'GetResponse Trigger',
name: 'getResponseTrigger',
// eslint-disable-next-line n8n-nodes-base/node-class-description-icon-not-svg
icon: 'file:getResponse.png',
group: ['trigger'],
version: 1,
description: 'Starts the workflow when GetResponse events occur',
defaults: {
name: 'GetResponse Trigger',
},
inputs: [],
outputs: [NodeConnectionTypes.Main],
credentials: [
{
name: 'getResponseApi',
required: true,
displayOptions: {
show: {
authentication: ['apiKey'],
},
},
},
{
name: 'getResponseOAuth2Api',
required: true,
displayOptions: {
show: {
authentication: ['oAuth2'],
},
},
},
],
webhooks: [
{
name: 'default',
httpMethod: 'GET',
responseMode: 'onReceived',
path: 'webhook',
},
],
properties: [
{
displayName: 'Authentication',
name: 'authentication',
type: 'options',
options: [
{
name: 'API Key',
value: 'apiKey',
},
{
name: 'OAuth2',
value: 'oAuth2',
},
],
default: 'apiKey',
},
{
displayName: 'Events',
name: 'events',
type: 'multiOptions',
options: [
{
name: 'Customer Subscribed',
value: 'subscribe',
description: 'Receive notifications when a customer is subscribed to a list',
},
{
name: 'Customer Unsubscribed',
value: 'unsubscribe',
description: 'Receive notifications when a customer is unsubscribed from a list',
},
{
name: 'Email Clicked',
value: 'click',
description: 'Receive notifications when a email is clicked',
},
{
name: 'Email Opened',
value: 'open',
description: 'Receive notifications when a email is opened',
},
{
name: 'Survey Submitted',
value: 'survey',
description: 'Receive notifications when a survey is submitted',
},
],
default: [],
required: true,
},
{
displayName: 'List Names or IDs',
name: 'listIds',
type: 'multiOptions',
description:
'Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
typeOptions: {
loadOptionsMethod: 'getLists',
},
default: [],
},
{
displayName: 'Options',
name: 'options',
placeholder: 'Add option',
type: 'collection',
default: {},
options: [
{
displayName: 'Delete Current Subscription',
name: 'delete',
type: 'boolean',
default: false,
description: 'Whether to delete the current subscription',
},
],
},
],
};
methods = {
loadOptions: {
// Get all the available teams to display them to user so that they can
// select them easily
async getLists(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
const lists = await getResponseApiRequestAllItems.call(this, 'GET', '/campaigns');
returnData.push({ name: '*', value: '*' });
for (const list of lists) {
returnData.push({
name: list.name,
value: list.campaignId,
});
}
return returnData;
},
},
};
webhookMethods = {
default: {
async checkExists(this: IHookFunctions): Promise<boolean> {
const webhookUrl = this.getNodeWebhookUrl('default');
const deleteCurrentSubscription = this.getNodeParameter('options.delete', false) as boolean;
try {
const data = await getresponseApiRequest.call(this, 'GET', '/accounts/callbacks', {});
if (data.url !== webhookUrl) {
if (!deleteCurrentSubscription) {
throw new NodeApiError(this.getNode(), data as JsonObject, {
message: `The webhook (${data.url}) is active in the account. Delete it manually or set the parameter "Delete Current Subscription" to true, and the node will delete it for you.`,
});
}
}
} catch (error) {
if (error.httpCode === '404') {
return false;
}
}
await getresponseApiRequest.call(this, 'DELETE', '/accounts/callbacks');
return false;
},
async create(this: IHookFunctions): Promise<boolean> {
const webhookUrl = this.getNodeWebhookUrl('default');
const events = this.getNodeParameter('events') as string[];
const body = {
url: webhookUrl,
actions: events.reduce(
(accumulator: { [key: string]: boolean }, currentValue: string) => {
accumulator[currentValue] = true;
return accumulator;
},
{},
),
};
await getresponseApiRequest.call(this, 'POST', '/accounts/callbacks', body);
return true;
},
async delete(this: IHookFunctions): Promise<boolean> {
try {
await getresponseApiRequest.call(this, 'DELETE', '/accounts/callbacks');
} catch (error) {
return false;
}
return true;
},
},
};
async webhook(this: IWebhookFunctions): Promise<IWebhookResponseData> {
const query = this.getQueryData() as IDataObject;
const listIds = this.getNodeParameter('listIds') as string[];
if (!listIds.includes('*') && !listIds.includes(query.CAMPAIGN_ID as string)) {
return {};
}
return {
workflowData: [this.helpers.returnJsonArray(query)],
};
}
}
@@ -0,0 +1,9 @@
{
"type": "object",
"properties": {
"success": {
"type": "boolean"
}
},
"version": 1
}
@@ -0,0 +1,122 @@
{
"type": "object",
"properties": {
"activities": {
"type": "string"
},
"campaign": {
"type": "object",
"properties": {
"campaignId": {
"type": "string"
},
"href": {
"type": "string"
},
"name": {
"type": "string"
}
}
},
"changedOn": {
"type": "string"
},
"contactId": {
"type": "string"
},
"createdOn": {
"type": "string"
},
"customFieldValues": {
"type": "array",
"items": {
"type": "object",
"properties": {
"customFieldId": {
"type": "string"
},
"fieldType": {
"type": "string"
},
"name": {
"type": "string"
},
"type": {
"type": "string"
},
"value": {
"type": "array",
"items": {
"type": "string"
}
},
"values": {
"type": "array",
"items": {
"type": "string"
}
},
"valueType": {
"type": "string"
}
}
}
},
"dayOfCycle": {
"type": "null"
},
"email": {
"type": "string"
},
"geolocation": {
"type": "object",
"properties": {
"continentCode": {
"type": "string"
},
"countryCode": {
"type": "string"
},
"dmaCode": {
"type": "null"
}
}
},
"href": {
"type": "string"
},
"ipAddress": {
"type": "string"
},
"note": {
"type": "null"
},
"origin": {
"type": "string"
},
"tags": {
"type": "array",
"items": {
"type": "object",
"properties": {
"color": {
"type": "string"
},
"href": {
"type": "string"
},
"name": {
"type": "string"
},
"tagId": {
"type": "string"
}
}
}
},
"timeZone": {
"type": "string"
}
},
"version": 1
}
@@ -0,0 +1,50 @@
{
"type": "object",
"properties": {
"activities": {
"type": "string"
},
"campaign": {
"type": "object",
"properties": {
"campaignId": {
"type": "string"
},
"href": {
"type": "string"
},
"name": {
"type": "string"
}
}
},
"changedOn": {
"type": "string"
},
"contactId": {
"type": "string"
},
"createdOn": {
"type": "string"
},
"email": {
"type": "string"
},
"href": {
"type": "string"
},
"ipAddress": {
"type": "string"
},
"note": {
"type": "null"
},
"origin": {
"type": "string"
},
"timeZone": {
"type": "string"
}
},
"version": 1
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 750 B