# nodes

node_type: n8n-nodes-base.Egoi
name: Egoi
display_name: E-goi
description: Consume E-goi API
category: output
icon: file:egoi.png
code_hash: 7959ec1b723673e5851fff364a8c113937b48cf3ed38305425b2874697670c8a
documentation_url: https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.Egoi
documentation_title: E-goi node documentation
operations: []
api_methods: []
documentation_examples: []
templates: [{"name":"e-goi","description":"Templates for e-goi"}]
related_resources: []
required_scopes: []
example_parameters: {}
properties_schema: []
package_name: n8n-nodes-base
version: 1.0
extracted_at: 2025-06-08 18:33:48
updated_at: 2025-06-08 18:33:48
source_code:
  "use strict";
  var __importDefault = (this && this.__importDefault) || function (mod) {
      return (mod && mod.__esModule) ? mod : { "default": mod };
  };
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.Egoi = void 0;
  const GenericFunctions_1 = require("./GenericFunctions");
  const moment_timezone_1 = __importDefault(require("moment-timezone"));
  class Egoi {
      constructor() {
          this.description = {
              displayName: 'E-goi',
              name: 'egoi',
              icon: 'file:egoi.png',
              group: ['output'],
              version: 1,
              subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
              description: 'Consume E-goi API',
              defaults: {
                  name: 'E-goi',
              },
              inputs: ['main'],
              outputs: ['main'],
              credentials: [
                  {
                      name: 'egoiApi',
                      required: true,
                  },
              ],
              properties: [
                  {
                      displayName: 'Resource',
                      name: 'resource',
                      type: 'options',
                      noDataExpression: true,
                      required: true,
                      options: [
                          {
                              name: 'Contact',
                              value: 'contact',
                          },
                      ],
                      default: 'contact',
                  },
                  {
                      displayName: 'Operation',
                      name: 'operation',
                      type: 'options',
                      noDataExpression: true,
                      required: true,
                      options: [
                          {
                              name: 'Create',
                              value: 'create',
                              description: 'Create a member',
                              action: 'Create a member',
                          },
                          {
                              name: 'Get',
                              value: 'get',
                              description: 'Get a member',
                              action: 'Get a member',
                          },
                          {
                              name: 'Get Many',
                              value: 'getAll',
                              description: 'Get many members',
                              action: 'Get many members',
                          },
                          {
                              name: 'Update',
                              value: 'update',
                              description: 'Update a member',
                              action: 'Update a member',
                          },
                      ],
                      default: 'create',
                  },
                  {
                      displayName: 'List Name or ID',
                      name: 'list',
                      type: 'options',
                      typeOptions: {
                          loadOptionsMethod: 'getLists',
                      },
                      displayOptions: {
                          show: {
                              operation: ['getAll', 'create', 'update', 'get'],
                          },
                      },
                      default: '',
                      description: 'ID of list to operate on. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
                  },
                  {
                      displayName: 'Email',
                      name: 'email',
                      type: 'string',
                      placeholder: 'name@email.com',
                      displayOptions: {
                          show: {
                              operation: ['create'],
                          },
                      },
                      default: '',
                      description: 'Email address for a subscriber',
                  },
                  {
                      displayName: 'Contact ID',
                      name: 'contactId',
                      type: 'string',
                      displayOptions: {
                          show: {
                              resource: ['contact'],
                              operation: ['update'],
                          },
                      },
                      default: '',
                      description: 'Contact ID of the subscriber',
                  },
                  {
                      displayName: 'Resolve Data',
                      name: 'resolveData',
                      type: 'boolean',
                      displayOptions: {
                          show: {
                              operation: ['create', 'update'],
                          },
                      },
                      default: true,
                      description: 'By default the response just includes the contact ID. If this option gets activated, it will resolve the data automatically.',
                  },
                  {
                      displayName: 'Additional Fields',
                      name: 'additionalFields',
                      type: 'collection',
                      placeholder: 'Add Field',
                      displayOptions: {
                          show: {
                              operation: ['create'],
                              resource: ['contact'],
                          },
                      },
                      default: {},
                      options: [
                          {
                              displayName: 'Birth Date',
                              name: 'birth_date',
                              type: 'dateTime',
                              default: '',
                              description: 'Birth date of a subscriber',
                          },
                          {
                              displayName: 'Cellphone',
                              name: 'cellphone',
                              type: 'string',
                              default: '',
                              description: 'Cellphone of a subscriber',
                          },
                          {
                              displayName: 'Extra Fields',
                              name: 'extraFieldsUi',
                              type: 'fixedCollection',
                              placeholder: 'Add Field',
                              default: {},
                              typeOptions: {
                                  multipleValues: true,
                              },
                              options: [
                                  {
                                      displayName: 'Extra Field',
                                      name: 'extraFieldValues',
                                      typeOptions: {
                                          multipleValueButtonText: 'Add Field',
                                      },
                                      values: [
                                          {
                                              displayName: 'Field Name or ID',
                                              name: 'field_id',
                                              type: 'options',
                                              description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
                                              typeOptions: {
                                                  loadOptionsMethod: 'getExtraFields',
                                                  loadOptionsDependsOn: ['list'],
                                              },
                                              default: '',
                                          },
                                          {
                                              displayName: 'Value',
                                              name: 'value',
                                              type: 'string',
                                              default: '',
                                          },
                                      ],
                                  },
                              ],
                          },
                          {
                              displayName: 'First Name',
                              name: 'first_name',
                              type: 'string',
                              default: '',
                              description: 'Name of a subscriber',
                          },
                          {
                              displayName: 'Last Name',
                              name: 'last_name',
                              type: 'string',
                              default: '',
                              description: 'Name of a subscriber',
                          },
                          {
                              displayName: 'Status',
                              name: 'status',
                              type: 'options',
                              options: [
                                  {
                                      name: 'Unconfirmed',
                                      value: 'unconfirmed',
                                  },
                                  {
                                      name: 'Active',
                                      value: 'active',
                                  },
                                  {
                                      name: 'Inactive',
                                      value: 'inactive',
                                  },
                                  {
                                      name: 'Removed',
                                      value: 'removed',
                                  },
                              ],
                              default: 'active',
                              description: "Subscriber's current status",
                          },
                          {
                              displayName: 'Tag Names or IDs',
                              name: 'tagIds',
                              type: 'multiOptions',
                              typeOptions: {
                                  loadOptionsMethod: 'getListTags',
                              },
                              default: [],
                              description: 'List of tag IDs to be added. Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
                          },
                      ],
                  },
                  {
                      displayName: 'Update Fields',
                      name: 'updateFields',
                      type: 'collection',
                      placeholder: 'Add Field',
                      default: {},
                      displayOptions: {
                          show: {
                              operation: ['update'],
                          },
                      },
                      options: [
                          {
                              displayName: 'Birth Date',
                              name: 'birth_date',
                              type: 'dateTime',
                              default: '',
                              description: 'Birth date of subscriber',
                          },
                          {
                              displayName: 'Cellphone',
                              name: 'cellphone',
                              type: 'string',
                              default: '',
                              description: 'Cellphone of subscriber',
                          },
                          {
                              displayName: 'Email',
                              name: 'email',
                              type: 'string',
                              placeholder: 'name@email.com',
                              default: '',
                              description: 'Email address for subscriber',
                          },
                          {
                              displayName: 'Extra Fields',
                              name: 'extraFieldsUi',
                              type: 'fixedCollection',
                              placeholder: 'Add Field',
                              default: {},
                              typeOptions: {
                                  multipleValues: true,
                              },
                              options: [
                                  {
                                      displayName: 'Extra Field',
                                      name: 'extraFieldValues',
                                      typeOptions: {
                                          multipleValueButtonText: 'Add Field',
                                      },
                                      values: [
                                          {
                                              displayName: 'Field Name or ID',
                                              name: 'field_id',
                                              type: 'options',
                                              description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
                                              typeOptions: {
                                                  loadOptionsMethod: 'getExtraFields',
                                                  loadOptionsDependsOn: ['list'],
                                              },
                                              default: '',
                                          },
                                          {
                                              displayName: 'Value',
                                              name: 'value',
                                              type: 'string',
                                              default: '',
                                          },
                                      ],
                                  },
                              ],
                          },
                          {
                              displayName: 'First Name',
                              name: 'first_name',
                              type: 'string',
                              default: '',
                              description: 'Name of subscriber',
                          },
                          {
                              displayName: 'Last Name',
                              name: 'last_name',
                              type: 'string',
                              default: '',
                              description: 'Name of subscriber',
                          },
                          {
                              displayName: 'Status',
                              name: 'status',
                              type: 'options',
                              options: [
                                  {
                                      name: 'Unconfirmed',
                                      value: 'unconfirmed',
                                  },
                                  {
                                      name: 'Active',
                                      value: 'active',
                                  },
                                  {
                                      name: 'Inactive',
                                      value: 'inactive',
                                  },
                                  {
                                      name: 'Removed',
                                      value: 'removed',
                                  },
                              ],
                              default: 'active',
                              description: "Subscriber's current status",
                          },
                          {
                              displayName: 'Tag Names or IDs',
                              name: 'tagIds',
                              type: 'multiOptions',
                              typeOptions: {
                                  loadOptionsMethod: 'getListTags',
                              },
                              default: [],
                              description: 'List of tag IDs to be added. Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
                          },
                      ],
                  },
                  {
                      displayName: 'By',
                      name: 'by',
                      type: 'options',
                      options: [
                          {
                              name: 'Contact ID',
                              value: 'id',
                          },
                          {
                              name: 'Email',
                              value: 'email',
                          },
                      ],
                      displayOptions: {
                          show: {
                              operation: ['get'],
                              resource: ['contact'],
                          },
                      },
                      default: 'id',
                      description: 'Search by',
                  },
                  {
                      displayName: 'Contact ID',
                      name: 'contactId',
                      type: 'string',
                      displayOptions: {
                          show: {
                              resource: ['contact'],
                              operation: ['get'],
                              by: ['id'],
                          },
                      },
                      default: '',
                      description: 'Contact ID of the subscriber',
                  },
                  {
                      displayName: 'Email',
                      name: 'email',
                      type: 'string',
                      placeholder: 'name@email.com',
                      displayOptions: {
                          show: {
                              resource: ['contact'],
                              operation: ['get'],
                              by: ['email'],
                          },
                      },
                      default: '',
                      description: 'Email address for subscriber',
                  },
                  {
                      displayName: 'Return All',
                      name: 'returnAll',
                      type: 'boolean',
                      displayOptions: {
                          show: {
                              operation: ['getAll'],
                              resource: ['contact'],
                          },
                      },
                      default: false,
                      description: 'Whether to return all results or only up to a given limit',
                  },
                  {
                      displayName: 'Limit',
                      name: 'limit',
                      type: 'number',
                      displayOptions: {
                          show: {
                              operation: ['getAll'],
                              resource: ['contact'],
                              returnAll: [false],
                          },
                      },
                      typeOptions: {
                          minValue: 1,
                          maxValue: 500,
                      },
                      default: 100,
                      description: 'Max number of results to return',
                  },
                  {
                      displayName: 'Simplify',
                      name: 'simple',
                      type: 'boolean',
                      displayOptions: {
                          show: {
                              operation: ['get', 'getAll'],
                              resource: ['contact'],
                          },
                      },
                      default: true,
                      description: 'Whether to return a simplified version of the response instead of the raw data',
                  },
              ],
          };
          this.methods = {
              loadOptions: {
                  async getLists() {
                      const returnData = [];
                      const lists = await GenericFunctions_1.egoiApiRequestAllItems.call(this, 'items', 'GET', '/lists');
                      for (const list of lists) {
                          const listName = list.internal_name;
                          const listId = list.list_id;
                          returnData.push({
                              name: listName,
                              value: listId,
                          });
                      }
                      return returnData;
                  },
                  async getExtraFields() {
                      const returnData = [];
                      const listId = this.getCurrentNodeParameter('list');
                      const extraFields = await GenericFunctions_1.egoiApiRequest.call(this, 'GET', `/lists/${listId}/fields`);
                      for (const field of extraFields) {
                          if (field.type === 'extra') {
                              const fieldName = field.name;
                              const fieldId = field.field_id;
                              returnData.push({
                                  name: fieldName,
                                  value: fieldId,
                              });
                          }
                      }
                      return returnData;
                  },
                  async getListTags() {
                      const returnData = [];
                      const tagList = await GenericFunctions_1.egoiApiRequestAllItems.call(this, 'items', 'GET', '/tags');
                      for (const tag of tagList) {
                          const tagName = tag.name;
                          const tagId = tag.tag_id;
                          returnData.push({
                              name: tagName,
                              value: tagId,
                          });
                      }
                      return returnData;
                  },
              },
          };
      }
      async execute() {
          let responseData;
          const returnData = [];
          const items = this.getInputData();
          const length = items.length;
          const operation = this.getNodeParameter('operation', 0);
          const resource = this.getNodeParameter('resource', 0);
          for (let i = 0; i < length; i++) {
              try {
                  if (resource === 'contact') {
                      if (operation === 'create') {
                          const listId = this.getNodeParameter('list', i);
                          const email = this.getNodeParameter('email', i);
                          const resolveData = this.getNodeParameter('resolveData', i);
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          const body = {
                              base: {
                                  email,
                              },
                              extra: [],
                          };
                          if (additionalFields.birth_date) {
                              additionalFields.birth_date = (0, moment_timezone_1.default)(additionalFields.birth_date).format('YYYY-MM-DD');
                          }
                          if (additionalFields.extraFieldsUi) {
                              const extraFields = additionalFields.extraFieldsUi
                                  .extraFieldValues;
                              if (extraFields) {
                                  body.extra = extraFields;
                              }
                          }
                          Object.assign(body.base, additionalFields);
                          responseData = await GenericFunctions_1.egoiApiRequest.call(this, 'POST', `/lists/${listId}/contacts`, body);
                          const contactId = responseData.contact_id;
                          if (additionalFields.tagIds) {
                              const tags = additionalFields.tagIds;
                              for (const tag of tags) {
                                  await GenericFunctions_1.egoiApiRequest.call(this, 'POST', `/lists/${listId}/contacts/actions/attach-tag`, { tag_id: tag, contacts: [contactId] });
                              }
                          }
                          if (resolveData) {
                              responseData = await GenericFunctions_1.egoiApiRequest.call(this, 'GET', `/lists/${listId}/contacts/${contactId}`);
                          }
                      }
                      if (operation === 'get') {
                          const listId = this.getNodeParameter('list', i);
                          const simple = this.getNodeParameter('simple', i);
                          const by = this.getNodeParameter('by', 0);
                          let endpoint = '';
                          if (by === 'id') {
                              const contactId = this.getNodeParameter('contactId', i);
                              endpoint = `/lists/${listId}/contacts/${contactId}`;
                          }
                          else {
                              const email = this.getNodeParameter('email', i);
                              endpoint = `/lists/${listId}/contacts?email=${email}`;
                          }
                          responseData = await GenericFunctions_1.egoiApiRequest.call(this, 'GET', endpoint, {});
                          if (responseData.items) {
                              responseData = responseData.items;
                          }
                          if (simple) {
                              const data = (await GenericFunctions_1.simplify.call(this, [responseData], listId))[0];
                              responseData = {
                                  ...data,
                                  email_stats: responseData.email_stats,
                                  sms_stats: responseData.sms_stats,
                                  push_stats: responseData.push_stats,
                                  webpush_stats: responseData.webpush_stats,
                                  voice_stats: responseData.voice_stats,
                              };
                          }
                      }
                      if (operation === 'getAll') {
                          const listId = this.getNodeParameter('list', i);
                          const returnAll = this.getNodeParameter('returnAll', 0);
                          const simple = this.getNodeParameter('simple', i);
                          if (returnAll) {
                              responseData = await GenericFunctions_1.egoiApiRequestAllItems.call(this, 'items', 'GET', `/lists/${listId}/contacts`, {});
                          }
                          else {
                              const limit = this.getNodeParameter('limit', i);
                              responseData = await GenericFunctions_1.egoiApiRequest.call(this, 'GET', `/lists/${listId}/contacts`, {}, { limit });
                              responseData = responseData.items;
                          }
                          if (simple) {
                              responseData = await GenericFunctions_1.simplify.call(this, responseData, listId);
                          }
                      }
                      if (operation === 'update') {
                          const listId = this.getNodeParameter('list', i);
                          const contactId = this.getNodeParameter('contactId', i);
                          const resolveData = this.getNodeParameter('resolveData', i);
                          const updateFields = this.getNodeParameter('updateFields', i);
                          const body = {
                              base: {},
                              extra: [],
                          };
                          if (updateFields.birth_date) {
                              updateFields.birth_date = (0, moment_timezone_1.default)(updateFields.birth_date).format('YYYY-MM-DD');
                          }
                          if (updateFields.extraFieldsUi) {
                              const extraFields = updateFields.extraFieldsUi
                                  .extraFieldValues;
                              if (extraFields) {
                                  body.extra = extraFields;
                              }
                          }
                          Object.assign(body.base, updateFields);
                          responseData = await GenericFunctions_1.egoiApiRequest.call(this, 'PATCH', `/lists/${listId}/contacts/${contactId}`, body);
                          if (updateFields.tagIds) {
                              const tags = updateFields.tagIds;
                              for (const tag of tags) {
                                  await GenericFunctions_1.egoiApiRequest.call(this, 'POST', `/lists/${listId}/contacts/actions/attach-tag`, { tag_id: tag, contacts: [contactId] });
                              }
                          }
                          if (resolveData) {
                              responseData = await GenericFunctions_1.egoiApiRequest.call(this, 'GET', `/lists/${listId}/contacts/${contactId}`);
                          }
                      }
                  }
              }
              catch (error) {
                  if (!this.continueOnFail()) {
                      throw error;
                  }
                  else {
                      const executionErrorData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({ error: error.message }), { itemData: { item: i } });
                      returnData.push(...executionErrorData);
                      continue;
                  }
              }
              const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
              returnData.push(...executionData);
          }
          return [returnData];
      }
  }
  exports.Egoi = Egoi;
  //# sourceMappingURL=Egoi.node.js.map

credential_code:
  "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.EgoiApi = void 0;
  class EgoiApi {
      constructor() {
          this.name = 'egoiApi';
          this.displayName = 'E-Goi API';
          this.documentationUrl = 'egoi';
          this.properties = [
              {
                  displayName: 'API Key',
                  name: 'apiKey',
                  type: 'string',
                  typeOptions: { password: true },
                  default: '',
              },
          ];
      }
  }
  exports.EgoiApi = EgoiApi;
  //# sourceMappingURL=EgoiApi.credentials.js.map

  // --- Next Credential File ---

  "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.EgoiApi = void 0;
  class EgoiApi {
      constructor() {
          this.name = 'egoiApi';
          this.displayName = 'E-Goi API';
          this.documentationUrl = 'egoi';
          this.properties = [
              {
                  displayName: 'API Key',
                  name: 'apiKey',
                  type: 'string',
                  typeOptions: { password: true },
                  default: '',
              },
          ];
      }
  }
  exports.EgoiApi = EgoiApi;
  //# sourceMappingURL=EgoiApi.credentials.js.map

documentation_markdown:
  ---
  #https://www.notion.so/n8n/Frontmatter-432c2b8dff1f43d4b1c8d20075510fe4
  title: E-goi node documentation
  description: Learn how to use the E=goi node in n8n. Follow technical documentation to integrate E=goi node into your workflows.
  contentType: [integration, reference]
  ---

  # E-goi node

  Use the E-goi node to automate work in E-goi, and integrate E-goi with other applications. n8n has built-in support for a wide range of E-goi features, including creating, updating, deleting, and getting contacts. 

  On this page, you'll find a list of operations the E-goi node supports and links to more resources.

  /// note | Credentials
  Refer to [E-goi credentials](/integrations/builtin/credentials/egoi.md) for guidance on setting up authentication. 
  ///

  ## Operations

  **Contact**

  - Create a member
  - Get a member
  - Get all members
  - Update a member

  ## Templates and examples

  <!-- see https://www.notion.so/n8n/Pull-in-templates-for-the-integrations-pages-37c716837b804d30a33b47475f6e3780 -->
  [[ templatesWidget(page.title, 'e-goi') ]]

example_workflow:
  {"name":"E-goi Example Workflow","nodes":[{"parameters":{},"id":"3i9b5nuk0pepmb33n28xbp","name":"E-goi","type":"n8n-nodes-base.exampleNode","typeVersion":1,"position":[250,300]}],"connections":{},"active":false,"settings":{},"tags":["example","generated"]}


node_type: n8n-nodes-base.Elasticsearch
name: Elasticsearch
display_name: Elasticsearch
description: Consume the Elasticsearch API
category: transform
icon: file:elasticsearch.svg
code_hash: 1a912478e4feb858d6fae8d87b347488d464bc2349ae630d36f52c53db076273
documentation_url: https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.Elasticsearch
documentation_title: Elasticsearch node documentation
operations: []
api_methods: []
documentation_examples: []
templates: [{"name":"elasticsearch","description":"Templates for elasticsearch"}]
related_resources: []
required_scopes: []
example_parameters: {}
properties_schema: []
package_name: n8n-nodes-base
version: 1.0
extracted_at: 2025-06-08 18:33:48
updated_at: 2025-06-08 18:33:48
source_code:
  "use strict";
  var __importDefault = (this && this.__importDefault) || function (mod) {
      return (mod && mod.__esModule) ? mod : { "default": mod };
  };
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.Elasticsearch = void 0;
  const n8n_workflow_1 = require("n8n-workflow");
  const GenericFunctions_1 = require("./GenericFunctions");
  const descriptions_1 = require("./descriptions");
  const omit_1 = __importDefault(require("lodash/omit"));
  class Elasticsearch {
      constructor() {
          this.description = {
              displayName: 'Elasticsearch',
              name: 'elasticsearch',
              icon: 'file:elasticsearch.svg',
              group: ['transform'],
              version: 1,
              subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
              description: 'Consume the Elasticsearch API',
              defaults: {
                  name: 'Elasticsearch',
              },
              inputs: ['main'],
              outputs: ['main'],
              credentials: [
                  {
                      name: 'elasticsearchApi',
                      required: true,
                  },
              ],
              properties: [
                  {
                      displayName: 'Resource',
                      name: 'resource',
                      type: 'options',
                      noDataExpression: true,
                      options: [
                          {
                              name: 'Document',
                              value: 'document',
                          },
                          {
                              name: 'Index',
                              value: 'index',
                          },
                      ],
                      default: 'document',
                  },
                  ...descriptions_1.documentOperations,
                  ...descriptions_1.documentFields,
                  ...descriptions_1.indexOperations,
                  ...descriptions_1.indexFields,
              ],
          };
      }
      async execute() {
          const items = this.getInputData();
          const returnData = [];
          const resource = this.getNodeParameter('resource', 0);
          const operation = this.getNodeParameter('operation', 0);
          let responseData;
          for (let i = 0; i < items.length; i++) {
              if (resource === 'document') {
                  if (operation === 'delete') {
                      const indexId = this.getNodeParameter('indexId', i);
                      const documentId = this.getNodeParameter('documentId', i);
                      const endpoint = `/${indexId}/_doc/${documentId}`;
                      responseData = await GenericFunctions_1.elasticsearchApiRequest.call(this, 'DELETE', endpoint);
                  }
                  else if (operation === 'get') {
                      const indexId = this.getNodeParameter('indexId', i);
                      const documentId = this.getNodeParameter('documentId', i);
                      const qs = {};
                      const options = this.getNodeParameter('options', i);
                      if (Object.keys(options).length) {
                          Object.assign(qs, options);
                          qs._source = true;
                      }
                      const endpoint = `/${indexId}/_doc/${documentId}`;
                      responseData = await GenericFunctions_1.elasticsearchApiRequest.call(this, 'GET', endpoint, {}, qs);
                      const simple = this.getNodeParameter('simple', i);
                      if (simple) {
                          responseData = {
                              _id: responseData._id,
                              ...responseData._source,
                          };
                      }
                  }
                  else if (operation === 'getAll') {
                      const indexId = this.getNodeParameter('indexId', i);
                      const body = {};
                      const qs = {};
                      const options = this.getNodeParameter('options', i);
                      if (Object.keys(options).length) {
                          const { query, ...rest } = options;
                          if (query) {
                              Object.assign(body, (0, n8n_workflow_1.jsonParse)(query, { errorMessage: "Invalid JSON in 'Query' option" }));
                          }
                          Object.assign(qs, rest);
                          qs._source = true;
                      }
                      const returnAll = this.getNodeParameter('returnAll', 0);
                      if (returnAll) {
                          qs.size = 10000;
                          if (qs.sort) {
                              responseData = await GenericFunctions_1.elasticsearchApiRequestAllItems.call(this, indexId, body, qs);
                          }
                          else {
                              responseData = await GenericFunctions_1.elasticsearchApiRequest.call(this, 'GET', `/${indexId}/_search`, body, qs);
                              responseData = responseData.hits.hits;
                          }
                      }
                      else {
                          qs.size = this.getNodeParameter('limit', 0);
                          responseData = await GenericFunctions_1.elasticsearchApiRequest.call(this, 'GET', `/${indexId}/_search`, body, qs);
                          responseData = responseData.hits.hits;
                      }
                      const simple = this.getNodeParameter('simple', 0);
                      if (simple) {
                          responseData = responseData.map((item) => {
                              return {
                                  _id: item._id,
                                  ...item._source,
                              };
                          });
                      }
                  }
                  else if (operation === 'create') {
                      const body = {};
                      const dataToSend = this.getNodeParameter('dataToSend', 0);
                      if (dataToSend === 'defineBelow') {
                          const fields = this.getNodeParameter('fieldsUi.fieldValues', i, []);
                          fields.forEach(({ fieldId, fieldValue }) => (body[fieldId] = fieldValue));
                      }
                      else {
                          const inputData = items[i].json;
                          const rawInputsToIgnore = this.getNodeParameter('inputsToIgnore', i);
                          const inputsToIgnore = rawInputsToIgnore.split(',').map((c) => c.trim());
                          for (const key of Object.keys(inputData)) {
                              if (inputsToIgnore.includes(key))
                                  continue;
                              body[key] = inputData[key];
                          }
                      }
                      const qs = {};
                      const additionalFields = this.getNodeParameter('additionalFields', i);
                      if (Object.keys(additionalFields).length) {
                          Object.assign(qs, (0, omit_1.default)(additionalFields, ['documentId']));
                      }
                      const indexId = this.getNodeParameter('indexId', i);
                      const { documentId } = additionalFields;
                      if (documentId) {
                          const endpoint = `/${indexId}/_doc/${documentId}`;
                          responseData = await GenericFunctions_1.elasticsearchApiRequest.call(this, 'PUT', endpoint, body);
                      }
                      else {
                          const endpoint = `/${indexId}/_doc`;
                          responseData = await GenericFunctions_1.elasticsearchApiRequest.call(this, 'POST', endpoint, body);
                      }
                  }
                  else if (operation === 'update') {
                      const body = { doc: {} };
                      const dataToSend = this.getNodeParameter('dataToSend', 0);
                      if (dataToSend === 'defineBelow') {
                          const fields = this.getNodeParameter('fieldsUi.fieldValues', i, []);
                          fields.forEach(({ fieldId, fieldValue }) => (body.doc[fieldId] = fieldValue));
                      }
                      else {
                          const inputData = items[i].json;
                          const rawInputsToIgnore = this.getNodeParameter('inputsToIgnore', i);
                          const inputsToIgnore = rawInputsToIgnore.split(',').map((c) => c.trim());
                          for (const key of Object.keys(inputData)) {
                              if (inputsToIgnore.includes(key))
                                  continue;
                              body.doc[key] = inputData[key];
                          }
                      }
                      const indexId = this.getNodeParameter('indexId', i);
                      const documentId = this.getNodeParameter('documentId', i);
                      const endpoint = `/${indexId}/_update/${documentId}`;
                      responseData = await GenericFunctions_1.elasticsearchApiRequest.call(this, 'POST', endpoint, body);
                  }
              }
              else if (resource === 'index') {
                  if (operation === 'create') {
                      const indexId = this.getNodeParameter('indexId', i);
                      const body = {};
                      const qs = {};
                      const additionalFields = this.getNodeParameter('additionalFields', i);
                      if (Object.keys(additionalFields).length) {
                          const { aliases, mappings, settings, ...rest } = additionalFields;
                          Object.assign(body, aliases, mappings, settings);
                          Object.assign(qs, rest);
                      }
                      responseData = await GenericFunctions_1.elasticsearchApiRequest.call(this, 'PUT', `/${indexId}`);
                      responseData = { id: indexId, ...responseData };
                      delete responseData.index;
                  }
                  else if (operation === 'delete') {
                      const indexId = this.getNodeParameter('indexId', i);
                      responseData = await GenericFunctions_1.elasticsearchApiRequest.call(this, 'DELETE', `/${indexId}`);
                      responseData = { success: true };
                  }
                  else if (operation === 'get') {
                      const indexId = this.getNodeParameter('indexId', i);
                      const qs = {};
                      const additionalFields = this.getNodeParameter('additionalFields', i);
                      if (Object.keys(additionalFields).length) {
                          Object.assign(qs, additionalFields);
                      }
                      responseData = await GenericFunctions_1.elasticsearchApiRequest.call(this, 'GET', `/${indexId}`, {}, qs);
                      responseData = { id: indexId, ...responseData[indexId] };
                  }
                  else if (operation === 'getAll') {
                      responseData = await GenericFunctions_1.elasticsearchApiRequest.call(this, 'GET', '/_aliases');
                      responseData = Object.keys(responseData).map((index) => ({
                          indexId: index,
                      }));
                      const returnAll = this.getNodeParameter('returnAll', i);
                      if (!returnAll) {
                          const limit = this.getNodeParameter('limit', i);
                          responseData = responseData.slice(0, limit);
                      }
                  }
              }
              const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
              returnData.push(...executionData);
          }
          return [returnData];
      }
  }
  exports.Elasticsearch = Elasticsearch;
  //# sourceMappingURL=Elasticsearch.node.js.map

credential_code:
  "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.ElasticsearchApi = void 0;
  class ElasticsearchApi {
      constructor() {
          this.name = 'elasticsearchApi';
          this.displayName = 'Elasticsearch API';
          this.documentationUrl = 'elasticsearch';
          this.properties = [
              {
                  displayName: 'Username',
                  name: 'username',
                  type: 'string',
                  default: '',
              },
              {
                  displayName: 'Password',
                  name: 'password',
                  type: 'string',
                  typeOptions: {
                      password: true,
                  },
                  default: '',
              },
              {
                  displayName: 'Base URL',
                  name: 'baseUrl',
                  type: 'string',
                  default: '',
                  placeholder: 'https://mydeployment.es.us-central1.gcp.cloud.es.io:9243',
                  description: "Referred to as Elasticsearch 'endpoint' in the Elastic deployment dashboard",
              },
              {
                  displayName: 'Ignore SSL Issues',
                  name: 'ignoreSSLIssues',
                  type: 'boolean',
                  default: false,
              },
          ];
          this.authenticate = {
              type: 'generic',
              properties: {
                  auth: {
                      username: '={{$credentials.username}}',
                      password: '={{$credentials.password}}',
                  },
                  skipSslCertificateValidation: '={{$credentials.ignoreSSLIssues}}',
              },
          };
          this.test = {
              request: {
                  baseURL: '={{$credentials.baseUrl}}',
                  url: '/_xpack?human=false',
              },
          };
      }
  }
  exports.ElasticsearchApi = ElasticsearchApi;
  //# sourceMappingURL=ElasticsearchApi.credentials.js.map

documentation_markdown:
  ---
  #https://www.notion.so/n8n/Frontmatter-432c2b8dff1f43d4b1c8d20075510fe4
  title: Elasticsearch node documentation
  description: Learn how to use the Elasticsearch node in n8n. Follow technical documentation to integrate Elasticsearch node into your workflows.
  contentType: [integration, reference]
  priority: medium
  ---

  # Elasticsearch node

  Use the Elasticsearch node to automate work in Elasticsearch, and integrate Elasticsearch with other applications. n8n has built-in support for a wide range of Elasticsearch features, including creating, updating, deleting, and getting documents and indexes. 

  On this page, you'll find a list of operations the Elasticsearch node supports and links to more resources.

  /// note | Credentials
  Refer to [Elasticsearch credentials](/integrations/builtin/credentials/elasticsearch.md) for guidance on setting up authentication. 
  ///

  --8<-- "_snippets/integrations/builtin/app-nodes/ai-tools.md"

  ## Operations

  * Document
      * Create a document
      * Delete a document
      * Get a document
      * Get all documents
      * Update a document
  * Index
      * Create
      * Delete
      * Get
      * Get All

  ## Templates and examples

  <!-- see https://www.notion.so/n8n/Pull-in-templates-for-the-integrations-pages-37c716837b804d30a33b47475f6e3780 -->
  [[ templatesWidget(page.title, 'elasticsearch') ]]

  --8<-- "_snippets/integrations/builtin/app-nodes/operation-not-supported.md"

example_workflow:
  {"name":"Elasticsearch Example Workflow","nodes":[{"parameters":{},"id":"06tdast3zawlumeppidt0w","name":"Elasticsearch","type":"n8n-nodes-base.exampleNode","typeVersion":1,"position":[250,300]}],"connections":{},"active":false,"settings":{},"tags":["example","generated"]}


node_type: n8n-nodes-base.ElasticSecurity
name: ElasticSecurity
display_name: Elastic Security
description: Consume the Elastic Security API
category: transform
icon: file:elasticSecurity.svg
code_hash: d63c1501e626316617d40fe0f6070a3506e512574eba3c6663360949ee49cb87
documentation_url: https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.ElasticSecurity
documentation_title: Elastic Security node documentation
operations: []
api_methods: []
documentation_examples: []
templates: [{"name":"elastic-security","description":"Templates for elastic-security"}]
related_resources: []
required_scopes: []
example_parameters: {}
properties_schema: []
package_name: n8n-nodes-base
version: 1.0
extracted_at: 2025-06-08 18:33:48
updated_at: 2025-06-08 18:33:48
source_code:
  "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.ElasticSecurity = void 0;
  const n8n_workflow_1 = require("n8n-workflow");
  const GenericFunctions_1 = require("./GenericFunctions");
  const descriptions_1 = require("./descriptions");
  class ElasticSecurity {
      constructor() {
          this.description = {
              displayName: 'Elastic Security',
              name: 'elasticSecurity',
              icon: 'file:elasticSecurity.svg',
              group: ['transform'],
              version: 1,
              subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
              description: 'Consume the Elastic Security API',
              defaults: {
                  name: 'Elastic Security',
              },
              inputs: ['main'],
              outputs: ['main'],
              credentials: [
                  {
                      name: 'elasticSecurityApi',
                      required: true,
                      testedBy: 'elasticSecurityApiTest',
                  },
              ],
              properties: [
                  {
                      displayName: 'Resource',
                      name: 'resource',
                      noDataExpression: true,
                      type: 'options',
                      options: [
                          {
                              name: 'Case',
                              value: 'case',
                          },
                          {
                              name: 'Case Comment',
                              value: 'caseComment',
                          },
                          {
                              name: 'Case Tag',
                              value: 'caseTag',
                          },
                          {
                              name: 'Connector',
                              value: 'connector',
                          },
                      ],
                      default: 'case',
                  },
                  ...descriptions_1.caseOperations,
                  ...descriptions_1.caseFields,
                  ...descriptions_1.caseCommentOperations,
                  ...descriptions_1.caseCommentFields,
                  ...descriptions_1.caseTagOperations,
                  ...descriptions_1.caseTagFields,
                  ...descriptions_1.connectorOperations,
                  ...descriptions_1.connectorFields,
              ],
          };
          this.methods = {
              loadOptions: {
                  async getTags() {
                      const tags = (await GenericFunctions_1.elasticSecurityApiRequest.call(this, 'GET', '/cases/tags'));
                      return tags.map((tag) => ({ name: tag, value: tag }));
                  },
                  async getConnectors() {
                      const endpoint = '/cases/configure/connectors/_find';
                      const connectors = (await GenericFunctions_1.elasticSecurityApiRequest.call(this, 'GET', endpoint));
                      return connectors.map(({ name, id }) => ({ name, value: id }));
                  },
              },
              credentialTest: {
                  async elasticSecurityApiTest(credential) {
                      const { username, password, baseUrl: rawBaseUrl, } = credential.data;
                      const baseUrl = (0, GenericFunctions_1.tolerateTrailingSlash)(rawBaseUrl);
                      const token = Buffer.from(`${username}:${password}`).toString('base64');
                      const endpoint = '/cases/status';
                      const options = {
                          headers: {
                              Authorization: `Basic ${token}`,
                              'kbn-xsrf': true,
                          },
                          method: 'GET',
                          body: {},
                          qs: {},
                          uri: `${baseUrl}/api${endpoint}`,
                          json: true,
                      };
                      try {
                          await this.helpers.request(options);
                          return {
                              status: 'OK',
                              message: 'Authentication successful',
                          };
                      }
                      catch (error) {
                          return {
                              status: 'Error',
                              message: error.message,
                          };
                      }
                  },
              },
          };
      }
      async execute() {
          var _a, _b;
          const items = this.getInputData();
          const returnData = [];
          const resource = this.getNodeParameter('resource', 0);
          const operation = this.getNodeParameter('operation', 0);
          let responseData;
          for (let i = 0; i < items.length; i++) {
              try {
                  if (resource === 'case') {
                      if (operation === 'create') {
                          const body = {
                              title: this.getNodeParameter('title', i),
                              connector: {},
                              owner: 'securitySolution',
                              description: '',
                              tags: [],
                              settings: {
                                  syncAlerts: this.getNodeParameter('additionalFields.syncAlerts', i, false),
                              },
                          };
                          const connectorId = this.getNodeParameter('connectorId', i);
                          const { id: fetchedId, name: fetchedName, type: fetchedType, } = await GenericFunctions_1.getConnector.call(this, connectorId);
                          const selectedConnectorType = this.getNodeParameter('connectorType', i);
                          if (fetchedType !== selectedConnectorType) {
                              throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Connector Type does not match the type of the connector in Connector Name', { itemIndex: i });
                          }
                          const connector = {
                              id: fetchedId,
                              name: fetchedName,
                              type: fetchedType,
                              fields: {},
                          };
                          if (selectedConnectorType === '.jira') {
                              connector.fields = {
                                  issueType: this.getNodeParameter('issueType', i),
                                  priority: this.getNodeParameter('priority', i),
                                  parent: null,
                              };
                          }
                          else if (selectedConnectorType === '.servicenow') {
                              connector.fields = {
                                  urgency: this.getNodeParameter('urgency', i),
                                  severity: this.getNodeParameter('severity', i),
                                  impact: this.getNodeParameter('impact', i),
                                  category: this.getNodeParameter('category', i),
                                  subcategory: null,
                              };
                          }
                          else if (selectedConnectorType === '.resilient') {
                              const rawIssueTypes = this.getNodeParameter('issueTypes', i);
                              connector.fields = {
                                  issueTypes: rawIssueTypes.split(',').map(Number),
                                  severityCode: this.getNodeParameter('severityCode', i),
                                  incidentTypes: null,
                              };
                          }
                          body.connector = connector;
                          const { syncAlerts, ...rest } = this.getNodeParameter('additionalFields', i);
                          if (Object.keys(rest).length) {
                              Object.assign(body, rest);
                          }
                          responseData = await GenericFunctions_1.elasticSecurityApiRequest.call(this, 'POST', '/cases', body);
                      }
                      else if (operation === 'delete') {
                          const caseId = this.getNodeParameter('caseId', i);
                          await GenericFunctions_1.elasticSecurityApiRequest.call(this, 'DELETE', `/cases?ids=["${caseId}"]`);
                          responseData = { success: true };
                      }
                      else if (operation === 'get') {
                          const caseId = this.getNodeParameter('caseId', i);
                          responseData = await GenericFunctions_1.elasticSecurityApiRequest.call(this, 'GET', `/cases/${caseId}`);
                      }
                      else if (operation === 'getAll') {
                          const qs = {};
                          const { tags, status } = this.getNodeParameter('filters', i);
                          const sortOptions = this.getNodeParameter('sortOptions', i);
                          qs.sortField = (_a = sortOptions.sortField) !== null && _a !== void 0 ? _a : 'createdAt';
                          qs.sortOrder = (_b = sortOptions.sortOrder) !== null && _b !== void 0 ? _b : 'asc';
                          if (status) {
                              qs.status = status;
                          }
                          if (tags === null || tags === void 0 ? void 0 : tags.length) {
                              qs.tags = tags.join(',');
                          }
                          responseData = await GenericFunctions_1.handleListing.call(this, 'GET', '/cases/_find', {}, qs);
                      }
                      else if (operation === 'getStatus') {
                          responseData = await GenericFunctions_1.elasticSecurityApiRequest.call(this, 'GET', '/cases/status');
                      }
                      else if (operation === 'update') {
                          const caseId = this.getNodeParameter('caseId', i);
                          const body = {};
                          const updateFields = this.getNodeParameter('updateFields', i);
                          if (!Object.keys(updateFields).length) {
                              GenericFunctions_1.throwOnEmptyUpdate.call(this, resource);
                          }
                          const { syncAlerts, ...rest } = updateFields;
                          Object.assign(body, {
                              cases: [
                                  {
                                      id: caseId,
                                      version: await GenericFunctions_1.getVersion.call(this, `/cases/${caseId}`),
                                      ...(syncAlerts && { settings: { syncAlerts } }),
                                      ...rest,
                                  },
                              ],
                          });
                          responseData = await GenericFunctions_1.elasticSecurityApiRequest.call(this, 'PATCH', '/cases', body);
                      }
                  }
                  else if (resource === 'caseTag') {
                      if (operation === 'add') {
                          const caseId = this.getNodeParameter('caseId', i);
                          const { title, connector, owner, description, settings, tags } = await GenericFunctions_1.elasticSecurityApiRequest.call(this, 'GET', `/cases/${caseId}`);
                          const tagToAdd = this.getNodeParameter('tag', i);
                          if (tags.includes(tagToAdd)) {
                              throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Cannot add tag "${tagToAdd}" to case ID ${caseId} because this case already has this tag.`, { itemIndex: i });
                          }
                          const body = {};
                          Object.assign(body, {
                              cases: [
                                  {
                                      id: caseId,
                                      title,
                                      connector,
                                      owner,
                                      description,
                                      settings,
                                      version: await GenericFunctions_1.getVersion.call(this, `/cases/${caseId}`),
                                      tags: [...tags, tagToAdd],
                                  },
                              ],
                          });
                          responseData = await GenericFunctions_1.elasticSecurityApiRequest.call(this, 'PATCH', '/cases', body);
                      }
                      else if (operation === 'remove') {
                          const caseId = this.getNodeParameter('caseId', i);
                          const tagToRemove = this.getNodeParameter('tag', i);
                          const { title, connector, owner, description, settings, tags } = (await GenericFunctions_1.elasticSecurityApiRequest.call(this, 'GET', `/cases/${caseId}`));
                          if (!tags.includes(tagToRemove)) {
                              throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Cannot remove tag "${tagToRemove}" from case ID ${caseId} because this case does not have this tag.`, { itemIndex: i });
                          }
                          const body = {};
                          Object.assign(body, {
                              cases: [
                                  {
                                      id: caseId,
                                      title,
                                      connector,
                                      owner,
                                      description,
                                      settings,
                                      version: await GenericFunctions_1.getVersion.call(this, `/cases/${caseId}`),
                                      tags: tags.filter((tag) => tag !== tagToRemove),
                                  },
                              ],
                          });
                          responseData = await GenericFunctions_1.elasticSecurityApiRequest.call(this, 'PATCH', '/cases', body);
                      }
                  }
                  else if (resource === 'caseComment') {
                      if (operation === 'add') {
                          const simple = this.getNodeParameter('simple', i);
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          const body = {
                              comment: this.getNodeParameter('comment', i),
                              type: 'user',
                              owner: additionalFields.owner || 'securitySolution',
                          };
                          const caseId = this.getNodeParameter('caseId', i);
                          const endpoint = `/cases/${caseId}/comments`;
                          responseData = await GenericFunctions_1.elasticSecurityApiRequest.call(this, 'POST', endpoint, body);
                          if (simple) {
                              const { comments } = responseData;
                              responseData = comments[comments.length - 1];
                          }
                      }
                      else if (operation === 'get') {
                          const caseId = this.getNodeParameter('caseId', i);
                          const commentId = this.getNodeParameter('commentId', i);
                          const endpoint = `/cases/${caseId}/comments/${commentId}`;
                          responseData = await GenericFunctions_1.elasticSecurityApiRequest.call(this, 'GET', endpoint);
                      }
                      else if (operation === 'getAll') {
                          const caseId = this.getNodeParameter('caseId', i);
                          const endpoint = `/cases/${caseId}/comments`;
                          responseData = await GenericFunctions_1.handleListing.call(this, 'GET', endpoint);
                      }
                      else if (operation === 'remove') {
                          const caseId = this.getNodeParameter('caseId', i);
                          const commentId = this.getNodeParameter('commentId', i);
                          const endpoint = `/cases/${caseId}/comments/${commentId}`;
                          await GenericFunctions_1.elasticSecurityApiRequest.call(this, 'DELETE', endpoint);
                          responseData = { success: true };
                      }
                      else if (operation === 'update') {
                          const simple = this.getNodeParameter('simple', i);
                          const caseId = this.getNodeParameter('caseId', i);
                          const commentId = this.getNodeParameter('commentId', i);
                          const body = {
                              comment: this.getNodeParameter('comment', i),
                              id: commentId,
                              type: 'user',
                              owner: 'securitySolution',
                              version: await GenericFunctions_1.getVersion.call(this, `/cases/${caseId}/comments/${commentId}`),
                          };
                          const patchEndpoint = `/cases/${caseId}/comments`;
                          responseData = await GenericFunctions_1.elasticSecurityApiRequest.call(this, 'PATCH', patchEndpoint, body);
                          if (simple) {
                              const { comments } = responseData;
                              responseData = comments[comments.length - 1];
                          }
                      }
                  }
                  else if (resource === 'connector') {
                      if (operation === 'create') {
                          const connectorType = this.getNodeParameter('connectorType', i);
                          const body = {
                              connector_type_id: connectorType,
                              name: this.getNodeParameter('name', i),
                          };
                          if (connectorType === '.jira') {
                              body.config = {
                                  apiUrl: this.getNodeParameter('apiUrl', i),
                                  projectKey: this.getNodeParameter('projectKey', i),
                              };
                              body.secrets = {
                                  email: this.getNodeParameter('email', i),
                                  apiToken: this.getNodeParameter('apiToken', i),
                              };
                          }
                          else if (connectorType === '.resilient') {
                              body.config = {
                                  apiUrl: this.getNodeParameter('apiUrl', i),
                                  orgId: this.getNodeParameter('orgId', i),
                              };
                              body.secrets = {
                                  apiKeyId: this.getNodeParameter('apiKeyId', i),
                                  apiKeySecret: this.getNodeParameter('apiKeySecret', i),
                              };
                          }
                          else if (connectorType === '.servicenow') {
                              body.config = {
                                  apiUrl: this.getNodeParameter('apiUrl', i),
                              };
                              body.secrets = {
                                  username: this.getNodeParameter('username', i),
                                  password: this.getNodeParameter('password', i),
                              };
                          }
                          responseData = await GenericFunctions_1.elasticSecurityApiRequest.call(this, 'POST', '/actions/connector', body);
                      }
                  }
                  const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { 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];
      }
  }
  exports.ElasticSecurity = ElasticSecurity;
  //# sourceMappingURL=ElasticSecurity.node.js.map

credential_code:
  "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.ElasticSecurityApi = void 0;
  class ElasticSecurityApi {
      constructor() {
          this.name = 'elasticSecurityApi';
          this.displayName = 'Elastic Security API';
          this.documentationUrl = 'elasticSecurity';
          this.properties = [
              {
                  displayName: 'Username',
                  name: 'username',
                  type: 'string',
                  default: '',
                  required: true,
              },
              {
                  displayName: 'Password',
                  name: 'password',
                  type: 'string',
                  typeOptions: {
                      password: true,
                  },
                  default: '',
                  required: true,
              },
              {
                  displayName: 'Base URL',
                  name: 'baseUrl',
                  type: 'string',
                  default: '',
                  placeholder: 'e.g. https://mydeployment.kb.us-central1.gcp.cloud.es.io:9243',
                  description: "Referred to as Kibana 'endpoint' in the Elastic deployment dashboard",
                  required: true,
              },
          ];
      }
  }
  exports.ElasticSecurityApi = ElasticSecurityApi;
  //# sourceMappingURL=ElasticSecurityApi.credentials.js.map

documentation_markdown:
  ---
  #https://www.notion.so/n8n/Frontmatter-432c2b8dff1f43d4b1c8d20075510fe4
  title: Elastic Security node documentation
  description: Learn how to use the Elastic Security node in n8n. Follow technical documentation to integrate Elastic Security node into your workflows.
  contentType: [integration, reference]
  ---

  # Elastic Security node

  Use the Elastic Security node to automate work in Elastic Security, and integrate Elastic Security with other applications. n8n's has built-in support for a wide range of Elastic Security features, including creating, updating, deleting, retrieving, and getting cases.

  On this page, you'll find a list of operations the Elastic Security node supports and links to more resources.

  /// note | Credentials
  Refer to [Elastic Security credentials](/integrations/builtin/credentials/elasticsecurity.md) for guidance on setting up authentication. 
  ///

  ## Operations

  * Case
      * Create a case
      * Delete a case
      * Get a case
      * Retrieve all cases
      * Retrieve a summary of all case activity
      * Update a case
  * Case Comment
      * Add a comment to a case
      * Get a case comment
      * Retrieve all case comments
      * Remove a comment from a case
      * Update a comment in a case
  * Case Tag
      * Add a tag to a case
      * Remove a tag from a case
  * Connector
      * Create a connector

  ## Templates and examples

  <!-- see https://www.notion.so/n8n/Pull-in-templates-for-the-integrations-pages-37c716837b804d30a33b47475f6e3780 -->
  [[ templatesWidget(page.title, 'elastic-security') ]]

example_workflow:
  {"name":"Elastic Security Example Workflow","nodes":[{"parameters":{},"id":"y7gx3x5iaxz9lnrx4akp","name":"Elastic Security","type":"n8n-nodes-base.exampleNode","typeVersion":1,"position":[250,300]}],"connections":{},"active":false,"settings":{},"tags":["example","generated"]}


node_type: n8n-nodes-base.ExecuteCommand
name: ExecuteCommand
display_name: Execute Command
description: Executes a command on the host
category: transform
icon: fa:terminal
code_hash: bf8ab1b48895981a9c275e2cb6b6d840dc705e9e3815ef70f3881402b51fe537
example_parameters: {}
properties_schema: []
package_name: n8n-nodes-base
version: 1.0
extracted_at: 2025-06-08 18:33:49
updated_at: 2025-06-08 18:33:49
source_code:
  "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.ExecuteCommand = void 0;
  const n8n_workflow_1 = require("n8n-workflow");
  const child_process_1 = require("child_process");
  async function execPromise(command) {
      const returnData = {
          error: undefined,
          exitCode: 0,
          stderr: '',
          stdout: '',
      };
      return new Promise((resolve, _reject) => {
          (0, child_process_1.exec)(command, { cwd: process.cwd() }, (error, stdout, stderr) => {
              returnData.stdout = stdout.trim();
              returnData.stderr = stderr.trim();
              if (error) {
                  returnData.error = error;
              }
              resolve(returnData);
          }).on('exit', (code) => {
              returnData.exitCode = code || 0;
          });
      });
  }
  class ExecuteCommand {
      constructor() {
          this.description = {
              displayName: 'Execute Command',
              name: 'executeCommand',
              icon: 'fa:terminal',
              group: ['transform'],
              version: 1,
              description: 'Executes a command on the host',
              defaults: {
                  name: 'Execute Command',
                  color: '#886644',
              },
              inputs: ['main'],
              outputs: ['main'],
              properties: [
                  {
                      displayName: 'Execute Once',
                      name: 'executeOnce',
                      type: 'boolean',
                      default: true,
                      description: 'Whether to execute only once instead of once for each entry',
                  },
                  {
                      displayName: 'Command',
                      name: 'command',
                      typeOptions: {
                          rows: 5,
                      },
                      type: 'string',
                      default: '',
                      placeholder: 'echo "test"',
                      description: 'The command to execute',
                      required: true,
                  },
              ],
          };
      }
      async execute() {
          let items = this.getInputData();
          let command;
          const executeOnce = this.getNodeParameter('executeOnce', 0);
          if (executeOnce) {
              items = [items[0]];
          }
          const returnItems = [];
          for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
              try {
                  command = this.getNodeParameter('command', itemIndex);
                  const { error, exitCode, stdout, stderr } = await execPromise(command);
                  if (error !== undefined) {
                      throw new n8n_workflow_1.NodeOperationError(this.getNode(), error.message, { itemIndex });
                  }
                  returnItems.push({
                      json: {
                          exitCode,
                          stderr,
                          stdout,
                      },
                      pairedItem: {
                          item: itemIndex,
                      },
                  });
              }
              catch (error) {
                  if (this.continueOnFail()) {
                      returnItems.push({
                          json: {
                              error: error.message,
                          },
                          pairedItem: {
                              item: itemIndex,
                          },
                      });
                      continue;
                  }
                  throw error;
              }
          }
          return [returnItems];
      }
  }
  exports.ExecuteCommand = ExecuteCommand;
  //# sourceMappingURL=ExecuteCommand.node.js.map

example_workflow:
  {"name":"Execute Command Example Workflow","nodes":[{"parameters":{},"id":"nhphqckn7ig2dh9hwnfs8","name":"Execute Command","type":"n8n-nodes-base.exampleNode","typeVersion":1,"position":[250,300]}],"connections":{},"active":false,"settings":{},"tags":["example","generated"]}


node_type: n8n-nodes-base.EmailSend
name: EmailSend
display_name: Send Email
description: Sends an email using SMTP protocol
category: output
icon: fa:envelope
code_hash: d76e18808343c4d0a7c35db3213e8e69bdb684cdda5c613e60b184da12c76b4c
example_parameters: {}
properties_schema: []
package_name: n8n-nodes-base
extracted_at: 2025-06-08 18:33:49
updated_at: 2025-06-08 18:33:49
source_code:
  "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.EmailSend = void 0;
  const n8n_workflow_1 = require("n8n-workflow");
  const EmailSendV1_node_1 = require("./v1/EmailSendV1.node");
  const EmailSendV2_node_1 = require("./v2/EmailSendV2.node");
  class EmailSend extends n8n_workflow_1.VersionedNodeType {
      constructor() {
          const baseDescription = {
              displayName: 'Send Email',
              name: 'emailSend',
              icon: 'fa:envelope',
              group: ['output'],
              defaultVersion: 2.1,
              description: 'Sends an email using SMTP protocol',
          };
          const nodeVersions = {
              1: new EmailSendV1_node_1.EmailSendV1(baseDescription),
              2: new EmailSendV2_node_1.EmailSendV2(baseDescription),
              2.1: new EmailSendV2_node_1.EmailSendV2(baseDescription),
          };
          super(nodeVersions, baseDescription);
      }
  }
  exports.EmailSend = EmailSend;
  //# sourceMappingURL=EmailSend.node.js.map

example_workflow:
  {"name":"Send Email Example Workflow","nodes":[{"parameters":{},"id":"2517z10usgchlc9klj6wah","name":"Send Email","type":"n8n-nodes-base.exampleNode","typeVersion":1,"position":[250,300]}],"connections":{},"active":false,"settings":{},"tags":["example","generated"]}


node_type: n8n-nodes-base.ExecuteWorkflow
name: ExecuteWorkflow
display_name: Execute Workflow
description: Execute another workflow
category: transform
icon: fa:sign-in-alt
code_hash: f1565eb6ca9041c9444299bdf264ba10953d71afc7913c5e2ac7c14beead0c9e
documentation_url: https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.ExecuteWorkflow
documentation_title: Execute Sub-workflow
operations: []
api_methods: []
documentation_examples: []
templates: [{"name":"execute-workflow","description":"Templates for execute-workflow"}]
related_resources: []
required_scopes: []
example_parameters: {}
properties_schema: []
package_name: n8n-nodes-base
version: 1.0
extracted_at: 2025-06-08 18:33:49
updated_at: 2025-06-08 18:33:49
source_code:
  "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.ExecuteWorkflow = void 0;
  const n8n_workflow_1 = require("n8n-workflow");
  const GenericFunctions_1 = require("./GenericFunctions");
  const utilities_1 = require("../../utils/utilities");
  class ExecuteWorkflow {
      constructor() {
          this.description = {
              displayName: 'Execute Workflow',
              name: 'executeWorkflow',
              icon: 'fa:sign-in-alt',
              group: ['transform'],
              version: 1,
              subtitle: '={{"Workflow: " + $parameter["workflowId"]}}',
              description: 'Execute another workflow',
              defaults: {
                  name: 'Execute Workflow',
                  color: '#ff6d5a',
              },
              inputs: ['main'],
              outputs: ['main'],
              properties: [
                  {
                      displayName: 'Operation',
                      name: 'operation',
                      type: 'hidden',
                      noDataExpression: true,
                      default: 'call_workflow',
                      options: [
                          {
                              name: 'Call Another Workflow',
                              value: 'call_workflow',
                          },
                      ],
                  },
                  {
                      displayName: 'Source',
                      name: 'source',
                      type: 'options',
                      options: [
                          {
                              name: 'Database',
                              value: 'database',
                              description: 'Load the workflow from the database by ID',
                          },
                          {
                              name: 'Local File',
                              value: 'localFile',
                              description: 'Load the workflow from a locally saved file',
                          },
                          {
                              name: 'Parameter',
                              value: 'parameter',
                              description: 'Load the workflow from a parameter',
                          },
                          {
                              name: 'URL',
                              value: 'url',
                              description: 'Load the workflow from an URL',
                          },
                      ],
                      default: 'database',
                      description: 'Where to get the workflow to execute from',
                  },
                  {
                      displayName: 'Workflow ID',
                      name: 'workflowId',
                      type: 'string',
                      displayOptions: {
                          show: {
                              source: ['database'],
                          },
                      },
                      default: '',
                      required: true,
                      hint: 'Can be found in the URL of the workflow',
                      description: "Note on using an expression here: if this node is set to run once with all items, they will all be sent to the <em>same</em> workflow. That workflow's ID will be calculated by evaluating the expression for the <strong>first input item</strong>.",
                  },
                  {
                      displayName: 'Workflow Path',
                      name: 'workflowPath',
                      type: 'string',
                      displayOptions: {
                          show: {
                              source: ['localFile'],
                          },
                      },
                      default: '',
                      placeholder: '/data/workflow.json',
                      required: true,
                      description: 'The path to local JSON workflow file to execute',
                  },
                  {
                      displayName: 'Workflow JSON',
                      name: 'workflowJson',
                      type: 'string',
                      typeOptions: {
                          editor: 'json',
                          rows: 10,
                      },
                      displayOptions: {
                          show: {
                              source: ['parameter'],
                          },
                      },
                      default: '\n\n\n',
                      required: true,
                      description: 'The workflow JSON code to execute',
                  },
                  {
                      displayName: 'Workflow URL',
                      name: 'workflowUrl',
                      type: 'string',
                      displayOptions: {
                          show: {
                              source: ['url'],
                          },
                      },
                      default: '',
                      placeholder: 'https://example.com/workflow.json',
                      required: true,
                      description: 'The URL from which to load the workflow from',
                  },
                  {
                      displayName: 'Any data you pass into this node will be output by the Execute Workflow Trigger. <a href="https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.executeworkflow/" target="_blank">More info</a>',
                      name: 'executeWorkflowNotice',
                      type: 'notice',
                      default: '',
                  },
                  {
                      displayName: 'Mode',
                      name: 'mode',
                      type: 'options',
                      noDataExpression: true,
                      options: [
                          {
                              name: 'Run once with all items',
                              value: 'once',
                              description: 'Pass all items into a single execution of the sub-workflow',
                          },
                          {
                              name: 'Run once for each item',
                              value: 'each',
                              description: 'Call the sub-workflow individually for each item',
                          },
                      ],
                      default: 'once',
                  },
              ],
          };
      }
      async execute() {
          const source = this.getNodeParameter('source', 0);
          const mode = this.getNodeParameter('mode', 0, false);
          const items = this.getInputData();
          if (mode === 'each') {
              const returnData = [];
              for (let i = 0; i < items.length; i++) {
                  try {
                      const workflowInfo = await GenericFunctions_1.getWorkflowInfo.call(this, source, i);
                      const workflowResult = await this.executeWorkflow(workflowInfo, [
                          items[i],
                      ]);
                      for (const [outputIndex, outputData] of workflowResult.entries()) {
                          for (const item of outputData) {
                              item.pairedItem = { item: i };
                          }
                          if (returnData[outputIndex] === undefined) {
                              returnData[outputIndex] = [];
                          }
                          returnData[outputIndex].push(...outputData);
                      }
                  }
                  catch (error) {
                      if (this.continueOnFail()) {
                          return [[{ json: { error: error.message }, pairedItem: { item: i } }]];
                      }
                      throw new n8n_workflow_1.NodeOperationError(this.getNode(), error, {
                          message: `Error executing workflow with item at index ${i}`,
                          description: error.message,
                          itemIndex: i,
                      });
                  }
              }
              return returnData;
          }
          else {
              try {
                  const workflowInfo = await GenericFunctions_1.getWorkflowInfo.call(this, source);
                  const workflowResult = await this.executeWorkflow(workflowInfo, items);
                  const pairedItem = (0, utilities_1.generatePairedItemData)(items.length);
                  for (const output of workflowResult) {
                      for (const item of output) {
                          item.pairedItem = pairedItem;
                      }
                  }
                  return workflowResult;
              }
              catch (error) {
                  const pairedItem = (0, utilities_1.generatePairedItemData)(items.length);
                  if (this.continueOnFail()) {
                      return [[{ json: { error: error.message }, pairedItem }]];
                  }
                  throw error;
              }
          }
      }
  }
  exports.ExecuteWorkflow = ExecuteWorkflow;
  //# sourceMappingURL=ExecuteWorkflow.node.js.map

documentation_markdown:
  ---
  #https://www.notion.so/n8n/Frontmatter-432c2b8dff1f43d4b1c8d20075510fe4
  title: Execute Sub-workflow
  description: Documentation for the Execute Sub-workflow node in n8n, a workflow automation platform. Includes guidance on usage, and links to examples.
  contentType: [integration, reference]
  priority: high
  ---

  # Execute Sub-workflow

  Use the Execute Sub-workflow node to run a different workflow on the host machine that runs n8n.

  ## Node parameters

  ### Source

  Select where the node should get the sub-workflow's information from:

  - **Database**: Select this option to load the workflow from the database by ID. You must also enter either:
  	- **From list**: Select the workflow from a list of workflows available to your account.
  	- **Workflow ID**: Enter the ID for the workflow. The URL of the workflow contains the ID after `/workflow/`. For example, if the URL of a workflow is `https://my-n8n-acct.app.n8n.cloud/workflow/abCDE1f6gHiJKL7`, the **Workflow ID** is `abCDE1f6gHiJKL7`.
  - **Local File**: Select this option to load the workflow from a locally saved JSON file. You must also enter:
  	- **Workflow Path**: Enter the path to the local JSON workflow file you want the node to execute.
  - **Parameter**: Select this option to load the workflow from a parameter. You must also enter:
  	- **Workflow JSON**: Enter the JSON code you want the node to execute.
  - **URL**: Select this option to load the workflow from a URL. You must also enter:
  	- **Workflow URL**: Enter the URL you want to load the workflow from.

  ### Workflow Inputs

  If you select a sub-workflow using the **database** and **From list** options, the sub-workflow's input items will automatically display, ready for you to fill in or map values.

  You can optionally remove requested input items, in which case the sub-workflow receives `null` as the item's value. You can also enable **Attempt to convert types** to try to automatically convert data to the sub-workflow item's requested type.

  Input items won't appear if the sub-workflow's Workflow Input Trigger node uses the "Accept all data" input data mode.

  ### Mode

  Use this parameter to control the execution mode for the node. Choose from these options:

  - **Run once with all items**: Pass all input items into a single execution of the node.
  - **Run once for each item**: Execute the node once for each input item in turn.

  ## Node options

  This node includes one option: **Wait for Sub-Workflow Completion**. This lets you control whether the main workflow should wait for the sub-workflow's completion before moving on to the next step (turned on) or whether the main workflow should continue without waiting (turned off).

  ## Templates and examples

  <!-- see https://www.notion.so/n8n/Pull-in-templates-for-the-integrations-pages-37c716837b804d30a33b47475f6e3780 -->
  [[ templatesWidget(page.title, 'execute-workflow') ]]

  ## Set up and use a sub-workflow

  This section walks through setting up both the parent workflow and sub-workflow.

  --8<-- "_snippets/flow-logic/subworkflow-usage.md"


  ## How data passes between workflows

  --8<-- "_snippets/flow-logic/subworkflow-data-flow.md"

example_workflow:
  {"name":"Execute Workflow Example Workflow","nodes":[{"parameters":{},"id":"bh5c4ze8lg59q5wbrrhq5b","name":"Execute Workflow","type":"n8n-nodes-base.exampleNode","typeVersion":1,"position":[250,300]}],"connections":{},"active":false,"settings":{},"tags":["example","generated"]}


node_type: n8n-nodes-base.Emelia
name: Emelia
display_name: Emelia
description: Consume the Emelia API
category: input
icon: file:emelia.svg
code_hash: 6766c6cf35962c2279f103df5e159989ed84476fefdc6612dc6e482526b19271
documentation_url: https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.Emelia
documentation_title: Emelia node documentation
operations: []
api_methods: []
documentation_examples: []
templates: [{"name":"emelia","description":"Templates for emelia"}]
related_resources: []
required_scopes: []
example_parameters: {}
properties_schema: []
package_name: n8n-nodes-base
version: 1.0
extracted_at: 2025-06-08 18:33:49
updated_at: 2025-06-08 18:33:49
source_code:
  "use strict";
  var __importDefault = (this && this.__importDefault) || function (mod) {
      return (mod && mod.__esModule) ? mod : { "default": mod };
  };
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.Emelia = void 0;
  const GenericFunctions_1 = require("./GenericFunctions");
  const CampaignDescription_1 = require("./CampaignDescription");
  const ContactListDescription_1 = require("./ContactListDescription");
  const isEmpty_1 = __importDefault(require("lodash/isEmpty"));
  class Emelia {
      constructor() {
          this.description = {
              displayName: 'Emelia',
              name: 'emelia',
              icon: 'file:emelia.svg',
              group: ['input'],
              version: 1,
              subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
              description: 'Consume the Emelia API',
              defaults: {
                  name: 'Emelia',
              },
              inputs: ['main'],
              outputs: ['main'],
              credentials: [
                  {
                      name: 'emeliaApi',
                      required: true,
                      testedBy: 'emeliaApiTest',
                  },
              ],
              properties: [
                  {
                      displayName: 'Resource',
                      name: 'resource',
                      type: 'options',
                      noDataExpression: true,
                      options: [
                          {
                              name: 'Campaign',
                              value: 'campaign',
                          },
                          {
                              name: 'Contact List',
                              value: 'contactList',
                          },
                      ],
                      default: 'campaign',
                      required: true,
                  },
                  ...CampaignDescription_1.campaignOperations,
                  ...CampaignDescription_1.campaignFields,
                  ...ContactListDescription_1.contactListOperations,
                  ...ContactListDescription_1.contactListFields,
              ],
          };
          this.methods = {
              credentialTest: {
                  emeliaApiTest: GenericFunctions_1.emeliaApiTest,
              },
              loadOptions: {
                  async getCampaigns() {
                      return GenericFunctions_1.loadResource.call(this, 'campaign');
                  },
                  async getContactLists() {
                      return GenericFunctions_1.loadResource.call(this, 'contactList');
                  },
              },
          };
      }
      async execute() {
          var _a, _b;
          const items = this.getInputData();
          const returnData = [];
          const resource = this.getNodeParameter('resource', 0);
          const operation = this.getNodeParameter('operation', 0);
          for (let i = 0; i < items.length; i++) {
              try {
                  if (resource === 'campaign') {
                      if (operation === 'addContact') {
                          const contact = {
                              email: this.getNodeParameter('contactEmail', i),
                          };
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          if (!(0, isEmpty_1.default)(additionalFields)) {
                              Object.assign(contact, additionalFields);
                          }
                          if (additionalFields.customFieldsUi) {
                              const customFields = ((_a = additionalFields.customFieldsUi) === null || _a === void 0 ? void 0 : _a.customFieldsValues) || [];
                              const data = customFields.reduce((obj, value) => Object.assign(obj, { [`${value.fieldName}`]: value.value }), {});
                              Object.assign(contact, data);
                              delete contact.customFieldsUi;
                          }
                          const responseData = await GenericFunctions_1.emeliaGraphqlRequest.call(this, {
                              query: `
  									mutation AddContactToCampaignHook($id: ID!, $contact: JSON!) {
  										addContactToCampaignHook(id: $id, contact: $contact)
  								}`,
                              operationName: 'AddContactToCampaignHook',
                              variables: {
                                  id: this.getNodeParameter('campaignId', i),
                                  contact,
                              },
                          });
                          const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({
                              contactId: responseData.data.addContactToCampaignHook,
                          }), { itemData: { item: i } });
                          returnData.push(...executionData);
                      }
                      else if (operation === 'create') {
                          const responseData = await GenericFunctions_1.emeliaGraphqlRequest.call(this, {
                              operationName: 'createCampaign',
                              query: `
  									mutation createCampaign($name: String!) {
  										createCampaign(name: $name) {
  											_id
  											name
  											status
  											createdAt
  											provider
  											startAt
  											estimatedEnd
  										}
  									}`,
                              variables: {
                                  name: this.getNodeParameter('campaignName', i),
                              },
                          });
                          const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData.data.createCampaign), { itemData: { item: i } });
                          returnData.push(...executionData);
                      }
                      else if (operation === 'get') {
                          const responseData = await GenericFunctions_1.emeliaGraphqlRequest.call(this, {
                              query: `
  									query campaign($id: ID!){
  										campaign(id: $id){
  											_id
  											name
  											status
  											createdAt
  											schedule{
  												dailyContact
  												dailyLimit
  												minInterval
  												maxInterval
  												trackLinks
  												trackOpens
  												timeZone
  												days
  												start
  												end
  												eventToStopMails
  											}
  											provider
  											startAt
  											recipients{
  												total_count
  											}
  											estimatedEnd
  										}
  									}`,
                              operationName: 'campaign',
                              variables: {
                                  id: this.getNodeParameter('campaignId', i),
                              },
                          });
                          const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData.data.campaign), { itemData: { item: i } });
                          returnData.push(...executionData);
                      }
                      else if (operation === 'getAll') {
                          const responseData = await GenericFunctions_1.emeliaGraphqlRequest.call(this, {
                              query: `
  									query all_campaigns {
  										all_campaigns {
  											_id
  											name
  											status
  											createdAt
  											stats {
  												mailsSent
  												uniqueOpensPercent
  												opens
  												linkClickedPercent
  												repliedPercent
  												bouncedPercent
  												unsubscribePercent
  												progressPercent
  											}
  										}
  									}`,
                              operationName: 'all_campaigns',
                          });
                          let campaigns = responseData.data.all_campaigns;
                          const returnAll = this.getNodeParameter('returnAll', i);
                          if (!returnAll) {
                              const limit = this.getNodeParameter('limit', i);
                              campaigns = campaigns.slice(0, limit);
                          }
                          const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(campaigns), { itemData: { item: i } });
                          returnData.push(...executionData);
                      }
                      else if (operation === 'pause') {
                          await GenericFunctions_1.emeliaGraphqlRequest.call(this, {
                              query: `
  									mutation pauseCampaign($id: ID!) {
  										pauseCampaign(id: $id)
  									}`,
                              operationName: 'pauseCampaign',
                              variables: {
                                  id: this.getNodeParameter('campaignId', i),
                              },
                          });
                          const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({ success: true }), { itemData: { item: i } });
                          returnData.push(...executionData);
                      }
                      else if (operation === 'start') {
                          await GenericFunctions_1.emeliaGraphqlRequest.call(this, {
                              query: `
  									mutation startCampaign($id: ID!) {
  										startCampaign(id: $id)
  									}`,
                              operationName: 'startCampaign',
                              variables: {
                                  id: this.getNodeParameter('campaignId', i),
                              },
                          });
                          const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({ success: true }), { itemData: { item: i } });
                          returnData.push(...executionData);
                      }
                      else if (operation === 'duplicate') {
                          const options = this.getNodeParameter('options', i);
                          const variables = {
                              fromId: this.getNodeParameter('campaignId', i),
                              name: this.getNodeParameter('campaignName', i),
                              copySettings: true,
                              copyMails: true,
                              copyContacts: false,
                              copyProvider: true,
                              ...options,
                          };
                          const { data: { duplicateCampaign }, } = await GenericFunctions_1.emeliaGraphqlRequest.call(this, {
                              query: `
  									mutation duplicateCampaign(
  										$fromId: ID!
  										$name: String!
  										$copySettings: Boolean!
  										$copyMails: Boolean!
  										$copyContacts: Boolean!
  										$copyProvider: Boolean!
  									) {
  										duplicateCampaign(
  											fromId: $fromId
  											name: $name
  											copySettings: $copySettings
  											copyMails: $copyMails
  											copyContacts: $copyContacts
  											copyProvider: $copyProvider
  										)
  									}`,
                              operationName: 'duplicateCampaign',
                              variables,
                          });
                          const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({ _id: duplicateCampaign }), { itemData: { item: i } });
                          returnData.push(...executionData);
                      }
                  }
                  else if (resource === 'contactList') {
                      if (operation === 'add') {
                          const contact = {
                              email: this.getNodeParameter('contactEmail', i),
                          };
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          if (!(0, isEmpty_1.default)(additionalFields)) {
                              Object.assign(contact, additionalFields);
                          }
                          if (additionalFields.customFieldsUi) {
                              const customFields = ((_b = additionalFields.customFieldsUi) === null || _b === void 0 ? void 0 : _b.customFieldsValues) || [];
                              const data = customFields.reduce((obj, value) => Object.assign(obj, { [`${value.fieldName}`]: value.value }), {});
                              Object.assign(contact, data);
                              delete contact.customFieldsUi;
                          }
                          const responseData = await GenericFunctions_1.emeliaGraphqlRequest.call(this, {
                              query: `
  									mutation AddContactsToListHook($id: ID!, $contact: JSON!) {
  										addContactsToListHook(id: $id, contact: $contact)
  									}`,
                              operationName: 'AddContactsToListHook',
                              variables: {
                                  id: this.getNodeParameter('contactListId', i),
                                  contact,
                              },
                          });
                          const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({ contactId: responseData.data.addContactsToListHook }), { itemData: { item: i } });
                          returnData.push(...executionData);
                      }
                      else if (operation === 'getAll') {
                          const responseData = await GenericFunctions_1.emeliaGraphqlRequest.call(this, {
                              query: `
  									query contact_lists{
  										contact_lists{
  											_id
  											name
  											contactCount
  											fields
  											usedInCampaign
  										}
  									}`,
                              operationName: 'contact_lists',
                          });
                          let contactLists = responseData.data.contact_lists;
                          const returnAll = this.getNodeParameter('returnAll', i);
                          if (!returnAll) {
                              const limit = this.getNodeParameter('limit', i);
                              contactLists = contactLists.slice(0, limit);
                          }
                          const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(contactLists), { 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];
      }
  }
  exports.Emelia = Emelia;
  //# sourceMappingURL=Emelia.node.js.map

credential_code:
  "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.EmeliaApi = void 0;
  class EmeliaApi {
      constructor() {
          this.name = 'emeliaApi';
          this.displayName = 'Emelia API';
          this.documentationUrl = 'emelia';
          this.properties = [
              {
                  displayName: 'API Key',
                  name: 'apiKey',
                  type: 'string',
                  typeOptions: { password: true },
                  default: '',
              },
          ];
      }
  }
  exports.EmeliaApi = EmeliaApi;
  //# sourceMappingURL=EmeliaApi.credentials.js.map

  // --- Next Credential File ---

  "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.EmeliaApi = void 0;
  class EmeliaApi {
      constructor() {
          this.name = 'emeliaApi';
          this.displayName = 'Emelia API';
          this.documentationUrl = 'emelia';
          this.properties = [
              {
                  displayName: 'API Key',
                  name: 'apiKey',
                  type: 'string',
                  typeOptions: { password: true },
                  default: '',
              },
          ];
      }
  }
  exports.EmeliaApi = EmeliaApi;
  //# sourceMappingURL=EmeliaApi.credentials.js.map

documentation_markdown:
  ---
  #https://www.notion.so/n8n/Frontmatter-432c2b8dff1f43d4b1c8d20075510fe4
  title: Emelia node documentation
  description: Learn how to use the Emelia node in n8n. Follow technical documentation to integrate Emelia node into your workflows.
  contentType: [integration, reference]
  ---

  # Emelia node

  Use the Emelia node to automate work in Emelia, and integrate Emelia with other applications. n8n has built-in support for a wide range of Emelia features, including creating campaigns, and adding contacts to a list. 

  On this page, you'll find a list of operations the Emelia node supports and links to more resources.

  /// note | Credentials
  Refer to [Emelia credentials](/integrations/builtin/credentials/emelia.md) for guidance on setting up authentication. 
  ///

  ## Operations

  * Campaign
      * Add Contact
      * Create
      * Get
      * Get All
      * Pause
      * Start
  * Contact List
      * Add
      * Get All

  ## Templates and examples

  <!-- see https://www.notion.so/n8n/Pull-in-templates-for-the-integrations-pages-37c716837b804d30a33b47475f6e3780 -->
  [[ templatesWidget(page.title, 'emelia') ]]

example_workflow:
  {"name":"Emelia Example Workflow","nodes":[{"parameters":{},"id":"ge6kd0foowcjbn6sc6fz3m","name":"Emelia","type":"n8n-nodes-base.exampleNode","typeVersion":1,"position":[250,300]}],"connections":{},"active":false,"settings":{},"tags":["example","generated"]}


node_type: n8n-nodes-base.ErrorTrigger
name: ErrorTrigger
display_name: Error Trigger
description: Triggers the workflow when another workflow has an error
category: trigger
icon: fa:bug
code_hash: 433bf91938992037c402b9331a9acbac3ece630c83526bdf8b1b33bde151d98c
documentation_url: https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.ErrorTrigger
documentation_title: Error Trigger node documentation
operations: []
api_methods: []
documentation_examples: []
templates: [{"name":"error-trigger","description":"Templates for error-trigger"}]
required_scopes: []
example_parameters: {"pollTimes":{"item":[{"mode":"everyMinute"}]}}
properties_schema: []
package_name: n8n-nodes-base
version: 1.0
extracted_at: 2025-06-08 18:33:49
updated_at: 2025-06-08 18:33:49
source_code:
  "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.ErrorTrigger = void 0;
  class ErrorTrigger {
      constructor() {
          this.description = {
              displayName: 'Error Trigger',
              name: 'errorTrigger',
              icon: 'fa:bug',
              group: ['trigger'],
              version: 1,
              description: 'Triggers the workflow when another workflow has an error',
              eventTriggerDescription: '',
              mockManualExecution: true,
              maxNodes: 1,
              defaults: {
                  name: 'Error Trigger',
                  color: '#0000FF',
              },
              inputs: [],
              outputs: ['main'],
              properties: [
                  {
                      displayName: 'This node will trigger when there is an error in another workflow, as long as that workflow is set up to do so. <a href="https://docs.n8n.io/integrations/core-nodes/n8n-nodes-base.errortrigger" target="_blank">More info<a>',
                      name: 'notice',
                      type: 'notice',
                      default: '',
                  },
              ],
          };
      }
      async execute() {
          const items = this.getInputData();
          const mode = this.getMode();
          if (mode === 'manual' &&
              items.length === 1 &&
              Object.keys(items[0].json).length === 0 &&
              items[0].binary === undefined) {
              const restApiUrl = this.getRestApiUrl();
              const urlParts = restApiUrl.split('/');
              urlParts.pop();
              urlParts.push('execution');
              const id = 231;
              items[0].json = {
                  execution: {
                      id,
                      url: `${urlParts.join('/')}/workflow/1/${id}`,
                      retryOf: '34',
                      error: {
                          message: 'Example Error Message',
                          stack: 'Stacktrace',
                      },
                      lastNodeExecuted: 'Node With Error',
                      mode: 'manual',
                  },
                  workflow: {
                      id: '1',
                      name: 'Example Workflow',
                  },
              };
          }
          return [items];
      }
  }
  exports.ErrorTrigger = ErrorTrigger;
  //# sourceMappingURL=ErrorTrigger.node.js.map

documentation_markdown:
  ---
  #https://www.notion.so/n8n/Frontmatter-432c2b8dff1f43d4b1c8d20075510fe4
  title: Error Trigger node documentation
  description: Learn how to use the Error Trigger node in n8n. Follow technical documentation to integrate Error Trigger node into your workflows.
  contentType: [integration, reference]
  priority: medium
  ---

  # Error Trigger node

  You can use the Error Trigger node to create error workflows. When another linked workflow fails, this node gets details about the failed workflow and the errors, and runs the error workflow.

  ## Usage

  --8<-- "_snippets/flow-logic/create-set-error-workflow.md"


  Note the following:

  * If a workflow uses the Error Trigger node, you don't have to activate the workflow.
  * If a workflow contains the Error Trigger node, by default, the workflow uses itself as the error workflow.
  * You can't test error workflows when running workflows manually. The Error Trigger only runs when an automatic workflow errors.

  ## Templates and examples

  <!-- see https://www.notion.so/n8n/Pull-in-templates-for-the-integrations-pages-37c716837b804d30a33b47475f6e3780 -->
  [[ templatesWidget(page.title, 'error-trigger') ]]

  ## Related resources

  You can use the [Stop And Error](/integrations/builtin/core-nodes/n8n-nodes-base.stopanderror.md) node to send custom messages to the Error Trigger.

  Read more about [Error workflows](/flow-logic/error-handling.md) in n8n workflows. 

  ## Error data

  --8<-- "_snippets/integrations/builtin/core-nodes/error-trigger/error-data.md"

related_resources:
  [{"title":"Stop And Error","url":"/integrations/builtin/core-nodes/n8n-nodes-base.stopanderror.md","type":"documentation"},{"title":"Error workflows","url":"/flow-logic/error-handling.md","type":"documentation"}]

example_workflow:
  {"name":"Error Trigger Example Workflow","nodes":[{"parameters":{"pollTimes":{"item":[{"mode":"everyMinute"}]}},"id":"0c9tqm8h6aistcph3a8b5qp","name":"Error Trigger","type":"n8n-nodes-base.exampleNode","typeVersion":1,"position":[250,300]}],"connections":{},"active":false,"settings":{},"tags":["example","generated"]}


node_type: n8n-nodes-base.ExecuteWorkflowTrigger
name: ExecuteWorkflowTrigger
display_name: Execute Workflow Trigger
description: Helpers for calling other n8n workflows. Used for designing modular, microservice-like workflows.
category: trigger
icon: fa:sign-out-alt
code_hash: f1d84b2742ef34b0a1cb589ca488d87263fbd1890f844cd1a964c4221a0eefd5
documentation_url: https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.ExecuteWorkflowTrigger
documentation_title: Execute Sub-workflow Trigger node documentation
operations: []
api_methods: []
documentation_examples: []
templates: [{"name":"execute-workflow-trigger","description":"Templates for execute-workflow-trigger"}]
related_resources: []
required_scopes: []
example_parameters: {"pollTimes":{"item":[{"mode":"everyMinute"}]}}
properties_schema: []
package_name: n8n-nodes-base
version: 1.0
extracted_at: 2025-06-08 18:33:51
updated_at: 2025-06-08 18:33:51
source_code:
  "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.ExecuteWorkflowTrigger = void 0;
  class ExecuteWorkflowTrigger {
      constructor() {
          this.description = {
              displayName: 'Execute Workflow Trigger',
              name: 'executeWorkflowTrigger',
              icon: 'fa:sign-out-alt',
              group: ['trigger'],
              version: 1,
              description: 'Helpers for calling other n8n workflows. Used for designing modular, microservice-like workflows.',
              eventTriggerDescription: '',
              maxNodes: 1,
              defaults: {
                  name: 'Execute Workflow Trigger',
                  color: '#ff6d5a',
              },
              inputs: [],
              outputs: ['main'],
              properties: [
                  {
                      displayName: "When an ‘execute workflow’ node calls this workflow, the execution starts here. Any data passed into the 'execute workflow' node will be output by this node.",
                      name: 'notice',
                      type: 'notice',
                      default: '',
                  },
                  {
                      displayName: 'Events',
                      name: 'events',
                      type: 'hidden',
                      noDataExpression: true,
                      options: [
                          {
                              name: 'Workflow Call',
                              value: 'worklfow_call',
                              description: 'When called by another workflow using Execute Workflow Trigger',
                              action: 'When Called by Another Workflow',
                          },
                      ],
                      default: 'worklfow_call',
                  },
              ],
          };
      }
      async execute() {
          return [this.getInputData()];
      }
  }
  exports.ExecuteWorkflowTrigger = ExecuteWorkflowTrigger;
  //# sourceMappingURL=ExecuteWorkflowTrigger.node.js.map

documentation_markdown:
  ---
  #https://www.notion.so/n8n/Frontmatter-432c2b8dff1f43d4b1c8d20075510fe4
  title: Execute Sub-workflow Trigger node documentation
  description: Learn how to use the Execute Sub-workflow Trigger node in n8n. Follow technical documentation to integrate Execute Sub-workflow Trigger node into your workflows.
  contentType: [integration, reference]
  priority: high
  ---

  # Execute Sub-workflow Trigger node

  Use this node to start a workflow in response to another workflow. It should be the first node in the workflow.

  n8n allows you to call workflows from other workflows. This is useful if you want to:

  * Reuse a workflow: for example, you could have multiple workflows pulling and processing data from different sources, then have all those workflows call a single workflow that generates a report.
  * Break large workflows into smaller components.

  ## Usage

  This node runs in response to a call from the [Execute Sub-workflow](/integrations/builtin/core-nodes/n8n-nodes-base.executeworkflow.md) or [Call n8n Workflow Tool](/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.toolworkflow.md) nodes.

  --8<-- "_snippets/flow-logic/subworkflow-usage.md"

  ## Templates and examples

  <!-- see https://www.notion.so/n8n/Pull-in-templates-for-the-integrations-pages-37c716837b804d30a33b47475f6e3780 -->
  [[ templatesWidget(page.title, 'execute-workflow-trigger') ]]

  ## How data passes between workflows

  --8<-- "_snippets/flow-logic/subworkflow-data-flow.md"

example_workflow:
  {"name":"Execute Workflow Trigger Example Workflow","nodes":[{"parameters":{"pollTimes":{"item":[{"mode":"everyMinute"}]}},"id":"6e2pugtzhnk9mfstm7wser","name":"Execute Workflow Trigger","type":"n8n-nodes-base.exampleNode","typeVersion":1,"position":[250,300]}],"connections":{},"active":false,"settings":{},"tags":["example","generated"]}


node_type: n8n-nodes-base.ExecutionData
name: ExecutionData
display_name: Execution Data
description: Add execution data for search
category: input
icon: fa:tasks
code_hash: 8d02375f5d0b6c49c900adcf415e46aead0c89e0033ccff2456c4ba5bb2ed769
documentation_url: https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.ExecutionData
documentation_title: Execution Data
operations: []
api_methods: []
documentation_examples: []
templates: [{"name":"execution-data","description":"Templates for execution-data"}]
related_resources: []
required_scopes: []
example_parameters: {}
properties_schema: []
package_name: n8n-nodes-base
version: 1.0
extracted_at: 2025-06-08 18:33:51
updated_at: 2025-06-08 18:33:51
source_code:
  "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.ExecutionData = void 0;
  class ExecutionData {
      constructor() {
          this.description = {
              displayName: 'Execution Data',
              name: 'executionData',
              icon: 'fa:tasks',
              group: ['input'],
              version: 1,
              description: 'Add execution data for search',
              defaults: {
                  name: 'Execution Data',
                  color: '#29A568',
              },
              inputs: ['main'],
              outputs: ['main'],
              properties: [
                  {
                      displayName: "Use this node to save fields you want to use later to easily find an execution (e.g. a user ID). You'll be able to search by this data in the 'executions' tab.<br>This feature is available on our Pro and Enterprise plans. <a href='https://n8n.io/pricing/' target='_blank'>More Info</a>.",
                      name: 'notice',
                      type: 'notice',
                      default: '',
                  },
                  {
                      displayName: 'Operation',
                      name: 'operation',
                      type: 'options',
                      default: 'save',
                      noDataExpression: true,
                      options: [
                          {
                              name: 'Save Execution Data for Search',
                              value: 'save',
                              action: 'Save execution data for search',
                          },
                      ],
                  },
                  {
                      displayName: 'Data to Save',
                      name: 'dataToSave',
                      placeholder: 'Add Saved Field',
                      type: 'fixedCollection',
                      typeOptions: {
                          multipleValueButtonText: 'Add Saved Field',
                          multipleValues: true,
                      },
                      displayOptions: {
                          show: {
                              operation: ['save'],
                          },
                      },
                      default: {},
                      options: [
                          {
                              displayName: 'Values',
                              name: 'values',
                              values: [
                                  {
                                      displayName: 'Key',
                                      name: 'key',
                                      type: 'string',
                                      default: '',
                                      placeholder: 'e.g. myKey',
                                  },
                                  {
                                      displayName: 'Value',
                                      name: 'value',
                                      type: 'string',
                                      default: '',
                                      placeholder: 'e.g. myValue',
                                  },
                              ],
                          },
                      ],
                  },
              ],
          };
      }
      async execute() {
          const context = this.getWorkflowDataProxy(0);
          const items = this.getInputData();
          const operations = this.getNodeParameter('operation', 0);
          if (operations === 'save') {
              for (let i = 0; i < items.length; i++) {
                  const dataToSave = this.getNodeParameter('dataToSave', i, {}).values ||
                      [];
                  const values = dataToSave.reduce((acc, { key, value }) => {
                      acc[key] = value;
                      return acc;
                  }, {});
                  context.$execution.customData.setAll(values);
              }
          }
          return [items];
      }
  }
  exports.ExecutionData = ExecutionData;
  //# sourceMappingURL=ExecutionData.node.js.map

documentation_markdown:
  ---
  #https://www.notion.so/n8n/Frontmatter-432c2b8dff1f43d4b1c8d20075510fe4
  title: Execution Data
  description: Documentation for the Execution Data node in n8n, a workflow automation platform. Includes guidance on usage, and links to examples.
  contentType: [integration, reference]
  priority: high
  ---

  # Execution Data

  Use this node to save metadata for workflow executions. You can then search by this data in the **Executions** list.

  You can retrieve custom execution data during workflow execution using the Code node. Refer to [Custom executions data](/workflows/executions/custom-executions-data.md) for more information.

  /// info | Feature availability
  Available on Pro and Enterprise plans.
  ///

  ## Operations

  * Save Execution Data for Search

  ## Data to Save

  Add a **Saved Field** for each key/value pair of metadata you'd like to save.

  ## Limitations

  The Execution Data node has the following restrictions when storing execution metadata:

  * `key`: limited to 50 characters
  * `value`: limited to 512 characters

  If either the `key` or `value` exceed the above limitations, n8n truncates to their maximum length and outputs a log entry.

  ## Templates and examples

  <!-- see https://www.notion.so/n8n/Pull-in-templates-for-the-integrations-pages-37c716837b804d30a33b47475f6e3780 -->
  [[ templatesWidget(page.title, 'execution-data') ]]

example_workflow:
  {"name":"Execution Data Example Workflow","nodes":[{"parameters":{},"id":"wilnm1wor75z7ah410jda","name":"Execution Data","type":"n8n-nodes-base.exampleNode","typeVersion":1,"position":[250,300]}],"connections":{},"active":false,"settings":{},"tags":["example","generated"]}


node_type: n8n-nodes-base.Flow
name: Flow
display_name: Flow
description: Consume Flow API
category: output
icon: file:flow.png
code_hash: 13e12903da5094fffdebbe6511f4f7eb7f1f7fad727f27793a64b523a553783e
documentation_url: https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.Flow
documentation_title: Flow node documentation
operations: []
api_methods: []
documentation_examples: []
templates: [{"name":"flow","description":"Templates for flow"}]
related_resources: []
required_scopes: []
example_parameters: {}
properties_schema: []
package_name: n8n-nodes-base
version: 1.0
extracted_at: 2025-06-08 18:33:51
updated_at: 2025-06-08 18:33:51
source_code:
  "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.Flow = void 0;
  const n8n_workflow_1 = require("n8n-workflow");
  const GenericFunctions_1 = require("./GenericFunctions");
  const TaskDescription_1 = require("./TaskDescription");
  class Flow {
      constructor() {
          this.description = {
              displayName: 'Flow',
              name: 'flow',
              icon: 'file:flow.png',
              group: ['output'],
              version: 1,
              subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
              description: 'Consume Flow API',
              defaults: {
                  name: 'Flow',
              },
              inputs: ['main'],
              outputs: ['main'],
              credentials: [
                  {
                      name: 'flowApi',
                      required: true,
                  },
              ],
              properties: [
                  {
                      displayName: 'Resource',
                      name: 'resource',
                      type: 'options',
                      noDataExpression: true,
                      options: [
                          {
                              name: 'Task',
                              value: 'task',
                              description: 'Tasks are units of work that can be private or assigned to a list. Through this endpoint, you can manipulate your tasks in Flow, including creating new ones.',
                          },
                      ],
                      default: 'task',
                  },
                  ...TaskDescription_1.taskOperations,
                  ...TaskDescription_1.taskFields,
              ],
          };
      }
      async execute() {
          const credentials = await this.getCredentials('flowApi');
          const items = this.getInputData();
          const returnData = [];
          const length = items.length;
          let responseData;
          const qs = {};
          const resource = this.getNodeParameter('resource', 0);
          const operation = this.getNodeParameter('operation', 0);
          for (let i = 0; i < length; i++) {
              if (resource === 'task') {
                  if (operation === 'create') {
                      const workspaceId = this.getNodeParameter('workspaceId', i);
                      const name = this.getNodeParameter('name', i);
                      const additionalFields = this.getNodeParameter('additionalFields', i);
                      const body = {
                          organization_id: credentials.organizationId,
                      };
                      const task = {
                          name,
                          workspace_id: parseInt(workspaceId, 10),
                      };
                      if (additionalFields.ownerId) {
                          task.owner_id = parseInt(additionalFields.ownerId, 10);
                      }
                      if (additionalFields.listId) {
                          task.list_id = parseInt(additionalFields.listId, 10);
                      }
                      if (additionalFields.startsOn) {
                          task.starts_on = additionalFields.startsOn;
                      }
                      if (additionalFields.dueOn) {
                          task.due_on = additionalFields.dueOn;
                      }
                      if (additionalFields.mirrorParentSubscribers) {
                          task.mirror_parent_subscribers = additionalFields.mirrorParentSubscribers;
                      }
                      if (additionalFields.mirrorParentTags) {
                          task.mirror_parent_tags = additionalFields.mirrorParentTags;
                      }
                      if (additionalFields.noteContent) {
                          task.note_content = additionalFields.noteContent;
                      }
                      if (additionalFields.noteMimeType) {
                          task.note_mime_type = additionalFields.noteMimeType;
                      }
                      if (additionalFields.parentId) {
                          task.parent_id = parseInt(additionalFields.parentId, 10);
                      }
                      if (additionalFields.positionList) {
                          task.position_list = additionalFields.positionList;
                      }
                      if (additionalFields.positionUpcoming) {
                          task.position_upcoming = additionalFields.positionUpcoming;
                      }
                      if (additionalFields.position) {
                          task.position = additionalFields.position;
                      }
                      if (additionalFields.sectionId) {
                          task.section_id = additionalFields.sectionId;
                      }
                      if (additionalFields.tags) {
                          task.tags = additionalFields.tags.split(',');
                      }
                      body.task = task;
                      try {
                          responseData = await GenericFunctions_1.flowApiRequest.call(this, 'POST', '/tasks', body);
                          responseData = responseData.task;
                      }
                      catch (error) {
                          throw new n8n_workflow_1.NodeApiError(this.getNode(), error);
                      }
                  }
                  if (operation === 'update') {
                      const workspaceId = this.getNodeParameter('workspaceId', i);
                      const taskId = this.getNodeParameter('taskId', i);
                      const updateFields = this.getNodeParameter('updateFields', i);
                      const body = {
                          organization_id: credentials.organizationId,
                      };
                      const task = {
                          workspace_id: parseInt(workspaceId, 10),
                          id: parseInt(taskId, 10),
                      };
                      if (updateFields.name) {
                          task.name = updateFields.name;
                      }
                      if (updateFields.ownerId) {
                          task.owner_id = parseInt(updateFields.ownerId, 10);
                      }
                      if (updateFields.listId) {
                          task.list_id = parseInt(updateFields.listId, 10);
                      }
                      if (updateFields.startsOn) {
                          task.starts_on = updateFields.startsOn;
                      }
                      if (updateFields.dueOn) {
                          task.due_on = updateFields.dueOn;
                      }
                      if (updateFields.mirrorParentSubscribers) {
                          task.mirror_parent_subscribers = updateFields.mirrorParentSubscribers;
                      }
                      if (updateFields.mirrorParentTags) {
                          task.mirror_parent_tags = updateFields.mirrorParentTags;
                      }
                      if (updateFields.noteContent) {
                          task.note_content = updateFields.noteContent;
                      }
                      if (updateFields.noteMimeType) {
                          task.note_mime_type = updateFields.noteMimeType;
                      }
                      if (updateFields.parentId) {
                          task.parent_id = parseInt(updateFields.parentId, 10);
                      }
                      if (updateFields.positionList) {
                          task.position_list = updateFields.positionList;
                      }
                      if (updateFields.positionUpcoming) {
                          task.position_upcoming = updateFields.positionUpcoming;
                      }
                      if (updateFields.position) {
                          task.position = updateFields.position;
                      }
                      if (updateFields.sectionId) {
                          task.section_id = updateFields.sectionId;
                      }
                      if (updateFields.tags) {
                          task.tags = updateFields.tags.split(',');
                      }
                      if (updateFields.completed) {
                          task.completed = updateFields.completed;
                      }
                      body.task = task;
                      try {
                          responseData = await GenericFunctions_1.flowApiRequest.call(this, 'PUT', `/tasks/${taskId}`, body);
                          responseData = responseData.task;
                      }
                      catch (error) {
                          throw new n8n_workflow_1.NodeApiError(this.getNode(), error);
                      }
                  }
                  if (operation === 'get') {
                      const taskId = this.getNodeParameter('taskId', i);
                      const filters = this.getNodeParameter('filters', i);
                      qs.organization_id = credentials.organizationId;
                      if (filters.include) {
                          qs.include = filters.include.join(',');
                      }
                      try {
                          responseData = await GenericFunctions_1.flowApiRequest.call(this, 'GET', `/tasks/${taskId}`, {}, qs);
                      }
                      catch (error) {
                          throw new n8n_workflow_1.NodeApiError(this.getNode(), error);
                      }
                  }
                  if (operation === 'getAll') {
                      const returnAll = this.getNodeParameter('returnAll', i);
                      const filters = this.getNodeParameter('filters', i);
                      qs.organization_id = credentials.organizationId;
                      if (filters.include) {
                          qs.include = filters.include.join(',');
                      }
                      if (filters.order) {
                          qs.order = filters.order;
                      }
                      if (filters.workspaceId) {
                          qs.workspace_id = filters.workspaceId;
                      }
                      if (filters.createdBefore) {
                          qs.created_before = filters.createdBefore;
                      }
                      if (filters.createdAfter) {
                          qs.created_after = filters.createdAfter;
                      }
                      if (filters.updateBefore) {
                          qs.updated_before = filters.updateBefore;
                      }
                      if (filters.updateAfter) {
                          qs.updated_after = filters.updateAfter;
                      }
                      if (filters.deleted) {
                          qs.deleted = filters.deleted;
                      }
                      if (filters.cleared) {
                          qs.cleared = filters.cleared;
                      }
                      try {
                          if (returnAll) {
                              responseData = await GenericFunctions_1.FlowApiRequestAllItems.call(this, 'tasks', 'GET', '/tasks', {}, qs);
                          }
                          else {
                              qs.limit = this.getNodeParameter('limit', i);
                              responseData = await GenericFunctions_1.flowApiRequest.call(this, 'GET', '/tasks', {}, qs);
                              responseData = responseData.tasks;
                          }
                      }
                      catch (error) {
                          throw new n8n_workflow_1.NodeApiError(this.getNode(), error, { itemIndex: i });
                      }
                  }
              }
              const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
              returnData.push(...executionData);
          }
          return [returnData];
      }
  }
  exports.Flow = Flow;
  //# sourceMappingURL=Flow.node.js.map

credential_code:
  "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.FlowApi = void 0;
  class FlowApi {
      constructor() {
          this.name = 'flowApi';
          this.displayName = 'Flow API';
          this.documentationUrl = 'flow';
          this.properties = [
              {
                  displayName: 'Organization ID',
                  name: 'organizationId',
                  type: 'number',
                  default: 0,
              },
              {
                  displayName: 'Access Token',
                  name: 'accessToken',
                  type: 'string',
                  typeOptions: { password: true },
                  default: '',
              },
          ];
      }
  }
  exports.FlowApi = FlowApi;
  //# sourceMappingURL=FlowApi.credentials.js.map

  // --- Next Credential File ---

  "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.FlowApi = void 0;
  class FlowApi {
      constructor() {
          this.name = 'flowApi';
          this.displayName = 'Flow API';
          this.documentationUrl = 'flow';
          this.properties = [
              {
                  displayName: 'Organization ID',
                  name: 'organizationId',
                  type: 'number',
                  default: 0,
              },
              {
                  displayName: 'Access Token',
                  name: 'accessToken',
                  type: 'string',
                  typeOptions: { password: true },
                  default: '',
              },
          ];
      }
  }
  exports.FlowApi = FlowApi;
  //# sourceMappingURL=FlowApi.credentials.js.map

documentation_markdown:
  ---
  #https://www.notion.so/n8n/Frontmatter-432c2b8dff1f43d4b1c8d20075510fe4
  title: Flow node documentation
  description: Learn how to use the Flow node in n8n. Follow technical documentation to integrate Flow node into your workflows.
  contentType: [integration, reference]
  ---

  # Flow node

  Use the Flow node to automate work in Flow, and integrate Flow with other applications. n8n has built-in support for a wide range of Flow features, including creating, updating, and getting tasks.

  On this page, you'll find a list of operations the Flow node supports and links to more resources.

  /// note | Credentials
  Refer to [Flow credentials](/integrations/builtin/credentials/flow.md) for guidance on setting up authentication. 
  ///

  ## Operations

  * Task
      * Create a new task
      * Update a task
      * Get a task
      * Get all the tasks

  ## Templates and examples

  <!-- see https://www.notion.so/n8n/Pull-in-templates-for-the-integrations-pages-37c716837b804d30a33b47475f6e3780 -->
  [[ templatesWidget(page.title, 'flow') ]]

example_workflow:
  {"name":"Flow Example Workflow","nodes":[{"parameters":{},"id":"a6ksca5wqenrgzmcyz0uob","name":"Flow","type":"n8n-nodes-base.exampleNode","typeVersion":1,"position":[250,300]}],"connections":{},"active":false,"settings":{},"tags":["example","generated"]}


node_type: n8n-nodes-base.FileMaker
name: FileMaker
display_name: FileMaker
description: Retrieve data from the FileMaker data API
category: input
icon: file:filemaker.png
code_hash: d3aa71438148e0dd63bebb11eaff551e9d6e0435bea93d1946b143f720183540
documentation_url: https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.FileMaker
documentation_title: FileMaker node documentation
operations: []
api_methods: []
documentation_examples: []
templates: [{"name":"filemaker","description":"Templates for filemaker"}]
related_resources: []
required_scopes: []
example_parameters: {}
properties_schema: []
package_name: n8n-nodes-base
version: 1.0
extracted_at: 2025-06-08 18:33:51
updated_at: 2025-06-08 18:33:51
source_code:
  "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.FileMaker = void 0;
  const n8n_workflow_1 = require("n8n-workflow");
  const GenericFunctions_1 = require("./GenericFunctions");
  class FileMaker {
      constructor() {
          this.description = {
              displayName: 'FileMaker',
              name: 'filemaker',
              icon: 'file:filemaker.png',
              group: ['input'],
              version: 1,
              description: 'Retrieve data from the FileMaker data API',
              defaults: {
                  name: 'FileMaker',
              },
              inputs: ['main'],
              outputs: ['main'],
              credentials: [
                  {
                      name: 'fileMaker',
                      required: true,
                  },
              ],
              properties: [
                  {
                      displayName: 'Action',
                      name: 'action',
                      type: 'options',
                      default: 'record',
                      options: [
                          {
                              name: 'Create Record',
                              value: 'create',
                          },
                          {
                              name: 'Delete Record',
                              value: 'delete',
                          },
                          {
                              name: 'Duplicate Record',
                              value: 'duplicate',
                          },
                          {
                              name: 'Edit Record',
                              value: 'edit',
                          },
                          {
                              name: 'Find Records',
                              value: 'find',
                          },
                          {
                              name: 'Get Records',
                              value: 'records',
                          },
                          {
                              name: 'Get Records By ID',
                              value: 'record',
                          },
                          {
                              name: 'Perform Script',
                              value: 'performscript',
                          },
                      ],
                  },
                  {
                      displayName: 'Layout Name or ID',
                      name: 'layout',
                      type: 'options',
                      typeOptions: {
                          loadOptionsMethod: 'getLayouts',
                      },
                      options: [],
                      default: '',
                      required: true,
                      displayOptions: {},
                      placeholder: 'Layout Name',
                      description: 'FileMaker Layout Name. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
                  },
                  {
                      displayName: 'Record ID',
                      name: 'recid',
                      type: 'number',
                      default: '',
                      required: true,
                      displayOptions: {
                          show: {
                              action: ['record', 'edit', 'delete', 'duplicate'],
                          },
                      },
                      placeholder: 'Record ID',
                      description: 'Internal Record ID returned by get (recordid)',
                  },
                  {
                      displayName: 'Offset',
                      name: 'offset',
                      placeholder: '0',
                      description: 'The record number of the first record in the range of records',
                      type: 'number',
                      default: 1,
                      displayOptions: {
                          show: {
                              action: ['find', 'records'],
                          },
                      },
                  },
                  {
                      displayName: 'Limit',
                      name: 'limit',
                      placeholder: '100',
                      description: 'Max number of results to return',
                      type: 'number',
                      typeOptions: {
                          minValue: 1,
                      },
                      default: 100,
                      displayOptions: {
                          show: {
                              action: ['find', 'records'],
                          },
                      },
                  },
                  {
                      displayName: 'Get Portals',
                      name: 'getPortals',
                      type: 'boolean',
                      default: false,
                      description: 'Whether to get portal data as well',
                      displayOptions: {
                          show: {
                              action: ['record', 'records', 'find'],
                          },
                      },
                  },
                  {
                      displayName: 'Portals Name or ID',
                      name: 'portals',
                      type: 'options',
                      typeOptions: {
                          multipleValues: true,
                          multipleValueButtonText: 'Add portal',
                          loadOptionsMethod: 'getPortals',
                      },
                      options: [],
                      default: [],
                      displayOptions: {
                          show: {
                              action: ['record', 'records', 'find'],
                              getPortals: [true],
                          },
                      },
                      placeholder: 'Portals',
                      description: 'The portal result set to return. Use the portal object name or portal table name. If this parameter is omitted, the API will return all portal objects and records in the layout. For best performance, pass the portal object name or portal table name. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
                  },
                  {
                      displayName: 'Response Layout Name or ID',
                      name: 'responseLayout',
                      type: 'options',
                      description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
                      typeOptions: {
                          loadOptionsMethod: 'getResponseLayouts',
                      },
                      options: [],
                      default: '',
                      displayOptions: {
                          show: {
                              action: ['find'],
                          },
                      },
                  },
                  {
                      displayName: 'Queries',
                      name: 'queries',
                      placeholder: 'Add query',
                      type: 'fixedCollection',
                      typeOptions: {
                          multipleValues: true,
                      },
                      displayOptions: {
                          show: {
                              action: ['find'],
                          },
                      },
                      default: {},
                      options: [
                          {
                              name: 'query',
                              displayName: 'Query',
                              values: [
                                  {
                                      displayName: 'Fields',
                                      name: 'fields',
                                      placeholder: 'Add field',
                                      type: 'fixedCollection',
                                      default: {},
                                      typeOptions: {
                                          multipleValues: true,
                                      },
                                      options: [
                                          {
                                              name: 'field',
                                              displayName: 'Field',
                                              values: [
                                                  {
                                                      displayName: 'Field Name or ID',
                                                      name: 'name',
                                                      type: 'options',
                                                      default: '',
                                                      typeOptions: {
                                                          loadOptionsMethod: 'getFields',
                                                      },
                                                      options: [],
                                                      description: 'Search Field. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
                                                  },
                                                  {
                                                      displayName: 'Value',
                                                      name: 'value',
                                                      type: 'string',
                                                      default: '',
                                                      description: 'Value to search',
                                                  },
                                              ],
                                          },
                                      ],
                                      description: 'Field Name',
                                  },
                                  {
                                      displayName: 'Omit',
                                      name: 'omit',
                                      type: 'boolean',
                                      default: false,
                                  },
                              ],
                          },
                      ],
                  },
                  {
                      displayName: 'Sort Data?',
                      name: 'setSort',
                      type: 'boolean',
                      default: false,
                      description: 'Whether to sort data',
                      displayOptions: {
                          show: {
                              action: ['find', 'record', 'records'],
                          },
                      },
                  },
                  {
                      displayName: 'Sort',
                      name: 'sortParametersUi',
                      placeholder: 'Add Sort Rules',
                      type: 'fixedCollection',
                      typeOptions: {
                          multipleValues: true,
                      },
                      displayOptions: {
                          show: {
                              setSort: [true],
                              action: ['find', 'records'],
                          },
                      },
                      description: 'Sort rules',
                      default: {},
                      options: [
                          {
                              name: 'rules',
                              displayName: 'Rules',
                              values: [
                                  {
                                      displayName: 'Field Name or ID',
                                      name: 'name',
                                      type: 'options',
                                      default: '',
                                      typeOptions: {
                                          loadOptionsMethod: 'getFields',
                                      },
                                      options: [],
                                      description: 'Field Name. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
                                  },
                                  {
                                      displayName: 'Order',
                                      name: 'value',
                                      type: 'options',
                                      default: 'ascend',
                                      options: [
                                          {
                                              name: 'Ascend',
                                              value: 'ascend',
                                          },
                                          {
                                              name: 'Descend',
                                              value: 'descend',
                                          },
                                      ],
                                      description: 'Sort order',
                                  },
                              ],
                          },
                      ],
                  },
                  {
                      displayName: 'Before Find Script',
                      name: 'setScriptBefore',
                      type: 'boolean',
                      default: false,
                      description: 'Whether to define a script to be run before the action specified by the API call and after the subsequent sort',
                      displayOptions: {
                          show: {
                              action: ['find', 'record', 'records'],
                          },
                      },
                  },
                  {
                      displayName: 'Script Name or ID',
                      name: 'scriptBefore',
                      type: 'options',
                      typeOptions: {
                          loadOptionsMethod: 'getScripts',
                      },
                      options: [],
                      default: '',
                      required: true,
                      displayOptions: {
                          show: {
                              action: ['find', 'record', 'records'],
                              setScriptBefore: [true],
                          },
                      },
                      placeholder: 'Script Name',
                      description: 'The name of the FileMaker script to be run after the action specified by the API call and after the subsequent sort. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
                  },
                  {
                      displayName: 'Script Parameter',
                      name: 'scriptBeforeParam',
                      type: 'string',
                      default: '',
                      displayOptions: {
                          show: {
                              action: ['find', 'record', 'records'],
                              setScriptBefore: [true],
                          },
                      },
                      placeholder: 'Script Parameters',
                      description: 'A parameter for the FileMaker script',
                  },
                  {
                      displayName: 'Before Sort Script',
                      name: 'setScriptSort',
                      type: 'boolean',
                      default: false,
                      description: 'Whether to define a script to be run after the action specified by the API call but before the subsequent sort',
                      displayOptions: {
                          show: {
                              action: ['find', 'record', 'records'],
                          },
                      },
                  },
                  {
                      displayName: 'Script Name or ID',
                      name: 'scriptSort',
                      type: 'options',
                      typeOptions: {
                          loadOptionsMethod: 'getScripts',
                      },
                      options: [],
                      default: '',
                      required: true,
                      displayOptions: {
                          show: {
                              action: ['find', 'record', 'records'],
                              setScriptSort: [true],
                          },
                      },
                      placeholder: 'Script Name',
                      description: 'The name of the FileMaker script to be run after the action specified by the API call but before the subsequent sort. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
                  },
                  {
                      displayName: 'Script Parameter',
                      name: 'scriptSortParam',
                      type: 'string',
                      default: '',
                      displayOptions: {
                          show: {
                              action: ['find', 'record', 'records'],
                              setScriptSort: [true],
                          },
                      },
                      placeholder: 'Script Parameters',
                      description: 'A parameter for the FileMaker script',
                  },
                  {
                      displayName: 'After Sort Script',
                      name: 'setScriptAfter',
                      type: 'boolean',
                      default: false,
                      description: 'Whether to define a script to be run after the action specified by the API call but before the subsequent sort',
                      displayOptions: {
                          show: {
                              action: ['find', 'record', 'records'],
                          },
                      },
                  },
                  {
                      displayName: 'Script Name or ID',
                      name: 'scriptAfter',
                      type: 'options',
                      typeOptions: {
                          loadOptionsMethod: 'getScripts',
                      },
                      options: [],
                      default: '',
                      required: true,
                      displayOptions: {
                          show: {
                              action: ['find', 'record', 'records'],
                              setScriptAfter: [true],
                          },
                      },
                      placeholder: 'Script Name',
                      description: 'The name of the FileMaker script to be run after the action specified by the API call and after the subsequent sort. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
                  },
                  {
                      displayName: 'Script Parameter',
                      name: 'scriptAfterParam',
                      type: 'string',
                      default: '',
                      displayOptions: {
                          show: {
                              action: ['find', 'record', 'records'],
                              setScriptAfter: [true],
                          },
                      },
                      placeholder: 'Script Parameters',
                      description: 'A parameter for the FileMaker script',
                  },
                  {
                      displayName: 'Mod ID',
                      name: 'modId',
                      description: 'The last modification ID. When you use modId, a record is edited only when the modId matches.',
                      type: 'number',
                      default: '',
                      displayOptions: {
                          show: {
                              action: ['edit'],
                          },
                      },
                  },
                  {
                      displayName: 'Fields',
                      name: 'fieldsParametersUi',
                      placeholder: 'Add field',
                      type: 'fixedCollection',
                      typeOptions: {
                          multipleValues: true,
                      },
                      displayOptions: {
                          show: {
                              action: ['create', 'edit'],
                          },
                      },
                      description: 'Fields to define',
                      default: {},
                      options: [
                          {
                              name: 'fields',
                              displayName: 'Fields',
                              values: [
                                  {
                                      displayName: 'Field Name or ID',
                                      name: 'name',
                                      type: 'options',
                                      default: '',
                                      typeOptions: {
                                          loadOptionsMethod: 'getFields',
                                      },
                                      options: [],
                                      description: 'Field Name. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
                                  },
                                  {
                                      displayName: 'Value',
                                      name: 'value',
                                      type: 'string',
                                      default: '',
                                  },
                              ],
                          },
                      ],
                  },
                  {
                      displayName: 'Script Name or ID',
                      name: 'script',
                      type: 'options',
                      typeOptions: {
                          loadOptionsMethod: 'getScripts',
                      },
                      options: [],
                      default: '',
                      required: true,
                      displayOptions: {
                          show: {
                              action: ['performscript'],
                          },
                      },
                      placeholder: 'Script Name',
                      description: 'The name of the FileMaker script to be run. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
                  },
                  {
                      displayName: 'Script Parameter',
                      name: 'scriptParam',
                      type: 'string',
                      default: '',
                      displayOptions: {
                          show: {
                              action: ['performscript'],
                          },
                      },
                      placeholder: 'Script Parameters',
                      description: 'A parameter for the FileMaker script',
                  },
              ],
          };
          this.methods = {
              loadOptions: {
                  async getLayouts() {
                      let returnData;
                      try {
                          returnData = await GenericFunctions_1.layoutsApiRequest.call(this);
                      }
                      catch (error) {
                          throw new n8n_workflow_1.NodeOperationError(this.getNode(), error);
                      }
                      return returnData;
                  },
                  async getResponseLayouts() {
                      const returnData = [];
                      returnData.push({
                          name: 'Use main layout',
                          value: '',
                      });
                      let layouts;
                      try {
                          layouts = await GenericFunctions_1.layoutsApiRequest.call(this);
                      }
                      catch (error) {
                          throw new n8n_workflow_1.NodeOperationError(this.getNode(), error);
                      }
                      for (const layout of layouts) {
                          returnData.push({
                              name: layout.name,
                              value: layout.name,
                          });
                      }
                      return returnData;
                  },
                  async getFields() {
                      const returnData = [];
                      let fields;
                      try {
                          fields = await GenericFunctions_1.getFields.call(this);
                      }
                      catch (error) {
                          throw new n8n_workflow_1.NodeOperationError(this.getNode(), error);
                      }
                      for (const field of fields) {
                          returnData.push({
                              name: field.name,
                              value: field.name,
                          });
                      }
                      return returnData;
                  },
                  async getScripts() {
                      const returnData = [];
                      let scripts;
                      try {
                          scripts = await GenericFunctions_1.getScripts.call(this);
                      }
                      catch (error) {
                          throw new n8n_workflow_1.NodeOperationError(this.getNode(), error);
                      }
                      for (const script of scripts) {
                          if (!script.isFolder) {
                              returnData.push({
                                  name: script.name,
                                  value: script.name,
                              });
                          }
                      }
                      return returnData;
                  },
                  async getPortals() {
                      const returnData = [];
                      let portals;
                      try {
                          portals = await GenericFunctions_1.getPortals.call(this);
                      }
                      catch (error) {
                          throw new n8n_workflow_1.NodeOperationError(this.getNode(), error);
                      }
                      Object.keys(portals).forEach((portal) => {
                          returnData.push({
                              name: portal,
                              value: portal,
                          });
                      });
                      return returnData;
                  },
              },
          };
      }
      async execute() {
          const items = this.getInputData();
          const returnData = [];
          const credentials = await this.getCredentials('fileMaker');
          let token;
          try {
              token = await GenericFunctions_1.getToken.call(this);
          }
          catch (error) {
              throw new n8n_workflow_1.NodeOperationError(this.getNode(), error);
          }
          let requestOptions;
          const host = credentials.host;
          const database = credentials.db;
          const url = `https://${host}/fmi/data/v1`;
          const action = this.getNodeParameter('action', 0);
          try {
              for (let i = 0; i < items.length; i++) {
                  requestOptions = {
                      uri: '',
                      headers: {
                          Authorization: `Bearer ${token}`,
                      },
                      method: 'GET',
                      json: true,
                  };
                  const layout = this.getNodeParameter('layout', i);
                  if (action === 'record') {
                      const recid = this.getNodeParameter('recid', i);
                      requestOptions.uri = url + `/databases/${database}/layouts/${layout}/records/${recid}`;
                      requestOptions.qs = {
                          portal: JSON.stringify(GenericFunctions_1.parsePortals.call(this, i)),
                          ...GenericFunctions_1.parseScripts.call(this, i),
                      };
                  }
                  else if (action === 'records') {
                      requestOptions.uri = url + `/databases/${database}/layouts/${layout}/records`;
                      requestOptions.qs = {
                          _offset: this.getNodeParameter('offset', i),
                          _limit: this.getNodeParameter('limit', i),
                          portal: JSON.stringify(GenericFunctions_1.parsePortals.call(this, i)),
                          ...GenericFunctions_1.parseScripts.call(this, i),
                      };
                      const sort = GenericFunctions_1.parseSort.call(this, i);
                      if (sort) {
                          requestOptions.body.sort = sort;
                      }
                  }
                  else if (action === 'find') {
                      requestOptions.uri = url + `/databases/${database}/layouts/${layout}/_find`;
                      requestOptions.method = 'POST';
                      requestOptions.body = {
                          query: GenericFunctions_1.parseQuery.call(this, i),
                          offset: this.getNodeParameter('offset', i),
                          limit: this.getNodeParameter('limit', i),
                          'layout.response': this.getNodeParameter('responseLayout', i),
                          ...GenericFunctions_1.parseScripts.call(this, i),
                      };
                      const sort = GenericFunctions_1.parseSort.call(this, i);
                      if (sort) {
                          requestOptions.body.sort = sort;
                      }
                  }
                  else if (action === 'create') {
                      requestOptions.uri = url + `/databases/${database}/layouts/${layout}/records`;
                      requestOptions.method = 'POST';
                      requestOptions.headers['Content-Type'] = 'application/json';
                      requestOptions.body = {
                          fieldData: { ...GenericFunctions_1.parseFields.call(this, i) },
                          portalData: {},
                          ...GenericFunctions_1.parseScripts.call(this, i),
                      };
                  }
                  else if (action === 'edit') {
                      const recid = this.getNodeParameter('recid', i);
                      requestOptions.uri = url + `/databases/${database}/layouts/${layout}/records/${recid}`;
                      requestOptions.method = 'PATCH';
                      requestOptions.headers['Content-Type'] = 'application/json';
                      requestOptions.body = {
                          fieldData: { ...GenericFunctions_1.parseFields.call(this, i) },
                          portalData: {},
                          ...GenericFunctions_1.parseScripts.call(this, i),
                      };
                  }
                  else if (action === 'performscript') {
                      const scriptName = this.getNodeParameter('script', i);
                      requestOptions.uri =
                          url + `/databases/${database}/layouts/${layout}/script/${scriptName}`;
                      requestOptions.qs = {
                          'script.param': this.getNodeParameter('scriptParam', i),
                      };
                  }
                  else if (action === 'duplicate') {
                      const recid = this.getNodeParameter('recid', i);
                      requestOptions.uri = url + `/databases/${database}/layouts/${layout}/records/${recid}`;
                      requestOptions.method = 'POST';
                      requestOptions.headers['Content-Type'] = 'application/json';
                      requestOptions.qs = {
                          ...GenericFunctions_1.parseScripts.call(this, i),
                      };
                  }
                  else if (action === 'delete') {
                      const recid = this.getNodeParameter('recid', i);
                      requestOptions.uri = url + `/databases/${database}/layouts/${layout}/records/${recid}`;
                      requestOptions.method = 'DELETE';
                      requestOptions.qs = {
                          ...GenericFunctions_1.parseScripts.call(this, i),
                      };
                  }
                  else {
                      throw new n8n_workflow_1.NodeOperationError(this.getNode(), `The action "${action}" is not implemented yet!`, { itemIndex: i });
                  }
                  let response;
                  try {
                      response = await this.helpers.request(requestOptions);
                  }
                  catch (error) {
                      response = error.error;
                  }
                  if (typeof response === 'string') {
                      throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'DataAPI response body is not valid JSON. Is the DataAPI enabled?', { itemIndex: i });
                  }
                  returnData.push({ json: response });
              }
          }
          catch (error) {
              if (error.node) {
                  throw error;
              }
              throw new n8n_workflow_1.NodeOperationError(this.getNode(), `The action "${error.message}" is not implemented yet!`);
          }
          await GenericFunctions_1.logout.call(this, token);
          return [returnData];
      }
  }
  exports.FileMaker = FileMaker;
  //# sourceMappingURL=FileMaker.node.js.map

documentation_markdown:
  ---
  #https://www.notion.so/n8n/Frontmatter-432c2b8dff1f43d4b1c8d20075510fe4
  title: FileMaker node documentation
  description: Learn how to use the FileMaker node in n8n. Follow technical documentation to integrate FileMaker node into your workflows.
  contentType: [integration, reference]
  priority: medium
  ---

  # FileMaker node

  Use the FileMaker node to automate work in FileMaker, and integrate FileMaker with other applications. n8n has built-in support for a wide range of FileMaker features, including creating, finding, getting, editing, and duplicating files.

  On this page, you'll find a list of operations the FileMaker node supports and links to more resources.

  /// note | Credentials
  Refer to [FileMaker credentials](/integrations/builtin/credentials/filemaker.md) for guidance on setting up authentication. 
  ///

  --8<-- "_snippets/integrations/builtin/app-nodes/ai-tools.md"

  ## Operations

  - Find Records
  - Get Records
  - Get Records by Id
  - Perform Script
  - Create Record
  - Edit Record
  - Duplicate Record
  - Delete Record

  ## Templates and examples

  <!-- see https://www.notion.so/n8n/Pull-in-templates-for-the-integrations-pages-37c716837b804d30a33b47475f6e3780 -->
  [[ templatesWidget(page.title, 'filemaker') ]]

example_workflow:
  {"name":"FileMaker Example Workflow","nodes":[{"parameters":{},"id":"df6z9i6mlifcu04h99eoou","name":"FileMaker","type":"n8n-nodes-base.exampleNode","typeVersion":1,"position":[250,300]}],"connections":{},"active":false,"settings":{},"tags":["example","generated"]}


node_type: n8n-nodes-base.Filter
name: Filter
display_name: Filter
description: Filter out incoming items based on given conditions
category: transform
icon: fa:filter
code_hash: 324befe1651cf4734fd44ebfdf5945e1d61541c5a1bab2eb2d2ba218e3b66ff2
documentation_url: https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.Filter
documentation_title: Filter
operations: []
api_methods: []
documentation_examples: []
templates: [{"name":"filter","description":"Templates for filter"}]
related_resources: []
required_scopes: []
example_parameters: {}
properties_schema: []
package_name: n8n-nodes-base
version: 1.0
extracted_at: 2025-06-08 18:33:51
updated_at: 2025-06-08 18:33:51
source_code:
  "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.Filter = void 0;
  const GenericFunctions_1 = require("./GenericFunctions");
  class Filter {
      constructor() {
          this.description = {
              displayName: 'Filter',
              name: 'filter',
              icon: 'fa:filter',
              group: ['transform'],
              version: 1,
              description: 'Filter out incoming items based on given conditions',
              defaults: {
                  name: 'Filter',
                  color: '#229eff',
              },
              inputs: ['main'],
              outputs: ['main'],
              outputNames: ['Kept', 'Discarded'],
              properties: [
                  {
                      displayName: 'Conditions',
                      name: 'conditions',
                      placeholder: 'Add Condition',
                      type: 'fixedCollection',
                      typeOptions: {
                          multipleValues: true,
                          sortable: true,
                      },
                      description: 'The type of values to compare',
                      default: {},
                      options: [
                          {
                              name: 'boolean',
                              displayName: 'Boolean',
                              values: [
                                  {
                                      displayName: 'Value 1',
                                      name: 'value1',
                                      type: 'boolean',
                                      default: false,
                                      description: 'The value to compare with the second one',
                                  },
                                  {
                                      displayName: 'Operation',
                                      name: 'operation',
                                      type: 'options',
                                      options: [
                                          {
                                              name: 'Equal',
                                              value: 'equal',
                                          },
                                          {
                                              name: 'Not Equal',
                                              value: 'notEqual',
                                          },
                                      ],
                                      default: 'equal',
                                      description: 'Operation to decide where the the data should be mapped to',
                                  },
                                  {
                                      displayName: 'Value 2',
                                      name: 'value2',
                                      type: 'boolean',
                                      default: false,
                                      description: 'The value to compare with the first one',
                                  },
                              ],
                          },
                          {
                              name: 'dateTime',
                              displayName: 'Date & Time',
                              values: [
                                  {
                                      displayName: 'Value 1',
                                      name: 'value1',
                                      type: 'dateTime',
                                      default: '',
                                      description: 'The value to compare with the second one',
                                  },
                                  {
                                      displayName: 'Operation',
                                      name: 'operation',
                                      type: 'options',
                                      options: [
                                          {
                                              name: 'Occurred After',
                                              value: 'after',
                                          },
                                          {
                                              name: 'Occurred Before',
                                              value: 'before',
                                          },
                                      ],
                                      default: 'after',
                                      description: 'Operation to decide where the the data should be mapped to',
                                  },
                                  {
                                      displayName: 'Value 2',
                                      name: 'value2',
                                      type: 'dateTime',
                                      default: '',
                                      description: 'The value to compare with the first one',
                                  },
                              ],
                          },
                          {
                              name: 'number',
                              displayName: 'Number',
                              values: [
                                  {
                                      displayName: 'Value 1',
                                      name: 'value1',
                                      type: 'number',
                                      default: 0,
                                      description: 'The value to compare with the second one',
                                  },
                                  {
                                      displayName: 'Operation',
                                      name: 'operation',
                                      type: 'options',
                                      noDataExpression: true,
                                      options: [
                                          {
                                              name: 'Smaller',
                                              value: 'smaller',
                                          },
                                          {
                                              name: 'Smaller or Equal',
                                              value: 'smallerEqual',
                                          },
                                          {
                                              name: 'Equal',
                                              value: 'equal',
                                          },
                                          {
                                              name: 'Not Equal',
                                              value: 'notEqual',
                                          },
                                          {
                                              name: 'Larger',
                                              value: 'larger',
                                          },
                                          {
                                              name: 'Larger or Equal',
                                              value: 'largerEqual',
                                          },
                                          {
                                              name: 'Is Empty',
                                              value: 'isEmpty',
                                          },
                                          {
                                              name: 'Is Not Empty',
                                              value: 'isNotEmpty',
                                          },
                                      ],
                                      default: 'smaller',
                                      description: 'Operation to decide where the the data should be mapped to',
                                  },
                                  {
                                      displayName: 'Value 2',
                                      name: 'value2',
                                      type: 'number',
                                      displayOptions: {
                                          hide: {
                                              operation: ['isEmpty', 'isNotEmpty'],
                                          },
                                      },
                                      default: 0,
                                      description: 'The value to compare with the first one',
                                  },
                              ],
                          },
                          {
                              name: 'string',
                              displayName: 'String',
                              values: [
                                  {
                                      displayName: 'Value 1',
                                      name: 'value1',
                                      type: 'string',
                                      default: '',
                                      description: 'The value to compare with the second one',
                                  },
                                  {
                                      displayName: 'Operation',
                                      name: 'operation',
                                      type: 'options',
                                      noDataExpression: true,
                                      options: [
                                          {
                                              name: 'Contains',
                                              value: 'contains',
                                          },
                                          {
                                              name: 'Not Contains',
                                              value: 'notContains',
                                          },
                                          {
                                              name: 'Ends With',
                                              value: 'endsWith',
                                          },
                                          {
                                              name: 'Not Ends With',
                                              value: 'notEndsWith',
                                          },
                                          {
                                              name: 'Equal',
                                              value: 'equal',
                                          },
                                          {
                                              name: 'Not Equal',
                                              value: 'notEqual',
                                          },
                                          {
                                              name: 'Regex Match',
                                              value: 'regex',
                                          },
                                          {
                                              name: 'Regex Not Match',
                                              value: 'notRegex',
                                          },
                                          {
                                              name: 'Starts With',
                                              value: 'startsWith',
                                          },
                                          {
                                              name: 'Not Starts With',
                                              value: 'notStartsWith',
                                          },
                                          {
                                              name: 'Is Empty',
                                              value: 'isEmpty',
                                          },
                                          {
                                              name: 'Is Not Empty',
                                              value: 'isNotEmpty',
                                          },
                                      ],
                                      default: 'equal',
                                      description: 'Operation to decide where the the data should be mapped to',
                                  },
                                  {
                                      displayName: 'Value 2',
                                      name: 'value2',
                                      type: 'string',
                                      displayOptions: {
                                          hide: {
                                              operation: ['isEmpty', 'isNotEmpty', 'regex', 'notRegex'],
                                          },
                                      },
                                      default: '',
                                      description: 'The value to compare with the first one',
                                  },
                                  {
                                      displayName: 'Regex',
                                      name: 'value2',
                                      type: 'string',
                                      displayOptions: {
                                          show: {
                                              operation: ['regex', 'notRegex'],
                                          },
                                      },
                                      default: '',
                                      placeholder: '/text/i',
                                      description: 'The regex which has to match',
                                  },
                              ],
                          },
                      ],
                  },
                  {
                      displayName: 'Combine Conditions',
                      name: 'combineConditions',
                      type: 'options',
                      options: [
                          {
                              name: 'AND',
                              description: 'Items are passed to the next node only if they meet all the conditions',
                              value: 'AND',
                          },
                          {
                              name: 'OR',
                              description: 'Items are passed to the next node if they meet at least one condition',
                              value: 'OR',
                          },
                      ],
                      default: 'AND',
                      description: 'How to combine the conditions: AND requires all conditions to be true, OR requires at least one condition to be true',
                  },
              ],
          };
      }
      async execute() {
          const returnDataTrue = [];
          const returnDataFalse = [];
          const items = this.getInputData();
          const dataTypes = ['boolean', 'dateTime', 'number', 'string'];
          itemLoop: for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
              const item = items[itemIndex];
              const combineConditions = this.getNodeParameter('combineConditions', itemIndex);
              for (const dataType of dataTypes) {
                  const typeConditions = this.getNodeParameter(`conditions.${dataType}`, itemIndex, []);
                  for (const condition of typeConditions) {
                      let value1 = condition.value1;
                      let value2 = condition.value2;
                      if (dataType === 'dateTime') {
                          const node = this.getNode();
                          value1 = (0, GenericFunctions_1.convertDateTime)(node, value1);
                          value2 = (0, GenericFunctions_1.convertDateTime)(node, value2);
                      }
                      const compareResult = GenericFunctions_1.compareOperationFunctions[condition.operation](value1, value2);
                      if (item.pairedItem === undefined) {
                          item.pairedItem = [{ item: itemIndex }];
                      }
                      if (compareResult && combineConditions === 'OR') {
                          returnDataTrue.push(item);
                          continue itemLoop;
                      }
                      if (!compareResult && combineConditions === 'AND') {
                          returnDataFalse.push(item);
                          continue itemLoop;
                      }
                  }
              }
              if (combineConditions === 'AND') {
                  returnDataTrue.push(item);
              }
              else {
                  returnDataFalse.push(item);
              }
          }
          return [returnDataTrue, returnDataFalse];
      }
  }
  exports.Filter = Filter;
  //# sourceMappingURL=Filter.node.js.map

documentation_markdown:
  ---
  #https://www.notion.so/n8n/Frontmatter-432c2b8dff1f43d4b1c8d20075510fe4
  title: Filter
  description: Documentation for the Filter node in n8n, a workflow automation platform. Includes guidance on usage, and links to examples.
  contentType: [integration, reference]
  priority: critical
  ---

  # Filter

  Filter items based on a condition. If the item meets the condition, the Filter node passes it on to the next node in the Filter node output. If the item doesn't meet the condition, the Filter node omits the item from its output.

  ## Node parameters

  Create filter comparison **Conditions** to perform your filter.

  - Use the data type dropdown to select the data type and comparison operation type for your condition. For example, to filter for dates after a particular date, select **Date & Time > is after**.
  - The fields and values to enter into the condition change based on the data type and comparison you select. Refer to [Available data type comparisons](#available-data-type-comparisons) for a full list of all comparisons by data type.

  Select **Add condition** to create more conditions.

  ### Combining conditions

  You can choose to keep items:

  * When they meet all conditions: Create two or more conditions and select **AND** in the dropdown between them.
  * When they meet any of the conditions: Create two or more conditions and select **OR** in the dropdown between them.

  You can't create a mix of AND and OR rules.

  ## Node options

  - **Ignore Case**: Whether to ignore letter case (turned on) or be case sensitive (turned off).
  - **Less Strict Type Validation**: Whether you want n8n to attempt to convert value types based on the operator you choose (turned on) or not (turned off). Turn this on when facing a "wrong type:" error in your node.

  ## Templates and examples

  <!-- see https://www.notion.so/n8n/Pull-in-templates-for-the-integrations-pages-37c716837b804d30a33b47475f6e3780 -->
  [[ templatesWidget(page.title, 'filter') ]]

  --8<-- "_snippets/integrations/builtin/core-nodes/data-types.md"

example_workflow:
  {"name":"Filter Example Workflow","nodes":[{"parameters":{},"id":"5fzz4hol0ct2he15c3ypmt","name":"Filter","type":"n8n-nodes-base.exampleNode","typeVersion":1,"position":[250,300]}],"connections":{},"active":false,"settings":{},"tags":["example","generated"]}


node_type: n8n-nodes-base.FunctionItem
name: FunctionItem
display_name: Function Item
description: Run custom function code which gets executed once per item
category: transform
icon: fa:code
code_hash: e5ce3a8474ce7c5363fafd8d914cdcb00613f5c8d7b7e78ba676a1298080ed20
example_parameters: {}
properties_schema: []
package_name: n8n-nodes-base
version: 1.0
extracted_at: 2025-06-08 18:33:53
updated_at: 2025-06-08 18:33:53
source_code:
  "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.FunctionItem = void 0;
  const vm2_1 = require("@n8n/vm2");
  const n8n_workflow_1 = require("n8n-workflow");
  const JavaScriptSandbox_1 = require("../Code/JavaScriptSandbox");
  class FunctionItem {
      constructor() {
          this.description = {
              displayName: 'Function Item',
              name: 'functionItem',
              hidden: true,
              icon: 'fa:code',
              group: ['transform'],
              version: 1,
              description: 'Run custom function code which gets executed once per item',
              defaults: {
                  name: 'Function Item',
                  color: '#ddbb33',
              },
              inputs: ['main'],
              outputs: ['main'],
              properties: [
                  {
                      displayName: 'A newer version of this node type is available, called the ‘Code’ node',
                      name: 'notice',
                      type: 'notice',
                      default: '',
                  },
                  {
                      displayName: 'JavaScript Code',
                      name: 'functionCode',
                      typeOptions: {
                          alwaysOpenEditWindow: true,
                          codeAutocomplete: 'functionItem',
                          editor: 'code',
                          rows: 10,
                      },
                      type: 'string',
                      default: `// Code here will run once per input item.
  // More info and help: https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.functionitem/
  // Tip: You can use luxon for dates and $jmespath for querying JSON structures

  // Add a new field called 'myNewField' to the JSON of the item
  item.myNewField = 1;

  // You can write logs to the browser console
  console.log('Done!');

  return item;`,
                      description: 'The JavaScript code to execute for each item',
                      noDataExpression: true,
                  },
              ],
          };
      }
      async execute() {
          const items = this.getInputData();
          const returnData = [];
          const length = items.length;
          let item;
          const cleanupData = (inputData) => {
              Object.keys(inputData).map((key) => {
                  if (inputData[key] !== null && typeof inputData[key] === 'object') {
                      if (inputData[key].constructor.name === 'Object') {
                          inputData[key] = cleanupData(inputData[key]);
                      }
                      else {
                          inputData[key] = (0, n8n_workflow_1.deepCopy)(inputData[key]);
                      }
                  }
              });
              return inputData;
          };
          for (let itemIndex = 0; itemIndex < length; itemIndex++) {
              const mode = this.getMode();
              try {
                  item = items[itemIndex];
                  item.index = itemIndex;
                  item = (0, n8n_workflow_1.deepCopy)(item);
                  const sandbox = {
                      getBinaryData: () => {
                          if (mode === 'manual') {
                              this.sendMessageToUI('getBinaryData(...) is deprecated and will be removed in a future version. Please consider switching to getBinaryDataAsync(...) instead.');
                          }
                          return item.binary;
                      },
                      setBinaryData: async (data) => {
                          if (mode === 'manual') {
                              this.sendMessageToUI('setBinaryData(...) is deprecated and will be removed in a future version. Please consider switching to setBinaryDataAsync(...) instead.');
                          }
                          item.binary = data;
                      },
                      getNodeParameter: this.getNodeParameter,
                      getWorkflowStaticData: this.getWorkflowStaticData,
                      helpers: this.helpers,
                      item: item.json,
                      getBinaryDataAsync: async () => {
                          var _a;
                          if ((item === null || item === void 0 ? void 0 : item.binary) && (item === null || item === void 0 ? void 0 : item.index) !== undefined && (item === null || item === void 0 ? void 0 : item.index) !== null) {
                              for (const binaryPropertyName of Object.keys(item.binary)) {
                                  item.binary[binaryPropertyName].data = (_a = (await this.helpers.getBinaryDataBuffer(item.index, binaryPropertyName))) === null || _a === void 0 ? void 0 : _a.toString('base64');
                              }
                          }
                          return item.binary;
                      },
                      setBinaryDataAsync: async (data) => {
                          if (!data) {
                              throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'No data was provided to setBinaryDataAsync (data: IBinaryKeyData).');
                          }
                          for (const binaryPropertyName of Object.keys(data)) {
                              const binaryItem = data[binaryPropertyName];
                              data[binaryPropertyName] = await this.helpers.setBinaryDataBuffer(binaryItem, Buffer.from(binaryItem.data, 'base64'));
                          }
                          item.binary = data;
                      },
                  };
                  const dataProxy = this.getWorkflowDataProxy(itemIndex);
                  Object.assign(sandbox, dataProxy);
                  const options = {
                      console: mode === 'manual' ? 'redirect' : 'inherit',
                      sandbox,
                      require: JavaScriptSandbox_1.vmResolver,
                  };
                  const vm = new vm2_1.NodeVM(options);
                  if (mode === 'manual') {
                      vm.on('console.log', this.sendMessageToUI);
                  }
                  const functionCode = this.getNodeParameter('functionCode', itemIndex);
                  let jsonData;
                  try {
                      jsonData = await vm.run(`module.exports = async function() {${functionCode}\n}()`, __dirname);
                  }
                  catch (error) {
                      if (this.continueOnFail()) {
                          returnData.push({ json: { error: error.message } });
                          continue;
                      }
                      else {
                          const stackLines = error.stack.split('\n');
                          if (stackLines.length > 0) {
                              stackLines.shift();
                              const lineParts = stackLines
                                  .find((line) => line.includes('FunctionItem'))
                                  .split(':');
                              if (lineParts.length > 2) {
                                  const lineNumber = lineParts.splice(-2, 1);
                                  if (!isNaN(lineNumber)) {
                                      error.message = `${error.message} [Line ${lineNumber} | Item Index: ${itemIndex}]`;
                                      throw error;
                                  }
                              }
                          }
                          error.message = `${error.message} [Item Index: ${itemIndex}]`;
                          throw error;
                      }
                  }
                  if (jsonData === undefined) {
                      throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'No data got returned. Always an object has to be returned!');
                  }
                  const returnItem = {
                      json: cleanupData(jsonData),
                      pairedItem: {
                          item: itemIndex,
                      },
                  };
                  if (item.binary) {
                      returnItem.binary = item.binary;
                  }
                  returnData.push(returnItem);
              }
              catch (error) {
                  if (this.continueOnFail()) {
                      returnData.push({
                          json: {
                              error: error.message,
                          },
                          pairedItem: {
                              item: itemIndex,
                          },
                      });
                      continue;
                  }
                  throw error;
              }
          }
          return [returnData];
      }
  }
  exports.FunctionItem = FunctionItem;
  //# sourceMappingURL=FunctionItem.node.js.map

example_workflow:
  {"name":"Function Item Example Workflow","nodes":[{"parameters":{},"id":"qmc7qmtvv4zxwvm50mh2","name":"Function Item","type":"n8n-nodes-base.exampleNode","typeVersion":1,"position":[250,300]}],"connections":{},"active":false,"settings":{},"tags":["example","generated"]}


node_type: n8n-nodes-base.Freshservice
name: Freshservice
display_name: Freshservice
description: Consume the Freshservice API
category: transform
icon: file:freshservice.svg
code_hash: 1bed84ee0d2e0bae1d67c9bfa28f817c5051798f27c18b1b33574e1f94a576c0
documentation_url: https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.Freshservice
documentation_title: Freshservice node documentation
operations: []
api_methods: []
documentation_examples: []
templates: [{"name":"freshservice","description":"Templates for freshservice"}]
related_resources: []
required_scopes: []
example_parameters: {}
properties_schema: []
package_name: n8n-nodes-base
version: 1.0
extracted_at: 2025-06-08 18:33:53
updated_at: 2025-06-08 18:33:53
source_code:
  "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.Freshservice = void 0;
  const GenericFunctions_1 = require("./GenericFunctions");
  const descriptions_1 = require("./descriptions");
  const moment_timezone_1 = require("moment-timezone");
  class Freshservice {
      constructor() {
          this.description = {
              displayName: 'Freshservice',
              name: 'freshservice',
              icon: 'file:freshservice.svg',
              group: ['transform'],
              version: 1,
              subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
              description: 'Consume the Freshservice API',
              defaults: {
                  name: 'Freshservice',
              },
              inputs: ['main'],
              outputs: ['main'],
              credentials: [
                  {
                      name: 'freshserviceApi',
                      required: true,
                  },
              ],
              properties: [
                  {
                      displayName: 'Resource',
                      name: 'resource',
                      type: 'options',
                      noDataExpression: true,
                      options: [
                          {
                              name: 'Agent',
                              value: 'agent',
                          },
                          {
                              name: 'Agent Group',
                              value: 'agentGroup',
                          },
                          {
                              name: 'Agent Role',
                              value: 'agentRole',
                          },
                          {
                              name: 'Announcement',
                              value: 'announcement',
                          },
                          {
                              name: 'Asset Type',
                              value: 'assetType',
                          },
                          {
                              name: 'Change',
                              value: 'change',
                          },
                          {
                              name: 'Department',
                              value: 'department',
                          },
                          {
                              name: 'Location',
                              value: 'location',
                          },
                          {
                              name: 'Problem',
                              value: 'problem',
                          },
                          {
                              name: 'Product',
                              value: 'product',
                          },
                          {
                              name: 'Release',
                              value: 'release',
                          },
                          {
                              name: 'Requester',
                              value: 'requester',
                          },
                          {
                              name: 'Requester Group',
                              value: 'requesterGroup',
                          },
                          {
                              name: 'Software',
                              value: 'software',
                          },
                          {
                              name: 'Ticket',
                              value: 'ticket',
                          },
                      ],
                      default: 'agent',
                  },
                  ...descriptions_1.agentOperations,
                  ...descriptions_1.agentFields,
                  ...descriptions_1.agentGroupOperations,
                  ...descriptions_1.agentGroupFields,
                  ...descriptions_1.agentRoleOperations,
                  ...descriptions_1.agentRoleFields,
                  ...descriptions_1.announcementOperations,
                  ...descriptions_1.announcementFields,
                  ...descriptions_1.assetTypeOperations,
                  ...descriptions_1.assetTypeFields,
                  ...descriptions_1.changeOperations,
                  ...descriptions_1.changeFields,
                  ...descriptions_1.departmentOperations,
                  ...descriptions_1.departmentFields,
                  ...descriptions_1.locationOperations,
                  ...descriptions_1.locationFields,
                  ...descriptions_1.problemOperations,
                  ...descriptions_1.problemFields,
                  ...descriptions_1.productOperations,
                  ...descriptions_1.productFields,
                  ...descriptions_1.releaseOperations,
                  ...descriptions_1.releaseFields,
                  ...descriptions_1.requesterOperations,
                  ...descriptions_1.requesterFields,
                  ...descriptions_1.requesterGroupOperations,
                  ...descriptions_1.requesterGroupFields,
                  ...descriptions_1.softwareOperations,
                  ...descriptions_1.softwareFields,
                  ...descriptions_1.ticketOperations,
                  ...descriptions_1.ticketFields,
              ],
          };
          this.methods = {
              loadOptions: {
                  async getAgents() {
                      const { agents } = (await GenericFunctions_1.freshserviceApiRequest.call(this, 'GET', '/agents'));
                      return (0, GenericFunctions_1.toUserOptions)(agents.filter((agent) => agent.active));
                  },
                  async getAgentGroups() {
                      const { groups } = (await GenericFunctions_1.freshserviceApiRequest.call(this, 'GET', '/groups'));
                      return (0, GenericFunctions_1.toOptions)(groups);
                  },
                  async getAgentRoles() {
                      const { roles } = (await GenericFunctions_1.freshserviceApiRequest.call(this, 'GET', '/roles'));
                      return (0, GenericFunctions_1.toOptions)(roles);
                  },
                  async getAssetTypes() {
                      const { asset_types } = (await GenericFunctions_1.freshserviceApiRequest.call(this, 'GET', '/asset_types'));
                      return (0, GenericFunctions_1.toOptions)(asset_types);
                  },
                  async getAssetTypeFields() {
                      const assetType = this.getCurrentNodeParameter('assetTypeId');
                      const { asset_type_fields } = (await GenericFunctions_1.freshserviceApiRequest.call(this, 'GET', `/asset_types/${assetType}/fields`));
                      let fields = [];
                      fields = fields
                          .concat(...asset_type_fields.map((data) => data.fields))
                          .map((data) => ({ name: data.label, id: data.name }));
                      return (0, GenericFunctions_1.toOptions)(fields);
                  },
                  async getDepartments() {
                      const { departments } = (await GenericFunctions_1.freshserviceApiRequest.call(this, 'GET', '/departments'));
                      return (0, GenericFunctions_1.toOptions)(departments);
                  },
                  async getLocations() {
                      const { locations } = (await GenericFunctions_1.freshserviceApiRequest.call(this, 'GET', '/locations'));
                      return (0, GenericFunctions_1.toOptions)(locations);
                  },
                  async getRequesters() {
                      const { requesters } = (await GenericFunctions_1.freshserviceApiRequest.call(this, 'GET', '/requesters'));
                      return (0, GenericFunctions_1.toUserOptions)(requesters);
                  },
              },
          };
      }
      async execute() {
          var _a;
          const items = this.getInputData();
          const returnData = [];
          const resource = this.getNodeParameter('resource', 0);
          const operation = this.getNodeParameter('operation', 0);
          const defaultTimezone = this.getTimezone();
          let responseData;
          for (let i = 0; i < items.length; i++) {
              try {
                  if (resource === 'agent') {
                      if (operation === 'create') {
                          const body = {
                              email: this.getNodeParameter('email', i),
                              first_name: this.getNodeParameter('firstName', i),
                          };
                          const roles = this.getNodeParameter('roles', i);
                          GenericFunctions_1.validateAssignmentScopeGroup.call(this, roles);
                          GenericFunctions_1.sanitizeAssignmentScopeGroup.call(this, roles);
                          Object.assign(body, (0, GenericFunctions_1.adjustAgentRoles)(roles));
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          if (Object.keys(additionalFields).length) {
                              Object.assign(body, additionalFields);
                          }
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'POST', '/agents', body);
                      }
                      else if (operation === 'delete') {
                          const agentId = this.getNodeParameter('agentId', i);
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'DELETE', `/agents/${agentId}`);
                      }
                      else if (operation === 'get') {
                          const agentId = this.getNodeParameter('agentId', i);
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'GET', `/agents/${agentId}`);
                      }
                      else if (operation === 'getAll') {
                          const qs = {};
                          const filters = this.getNodeParameter('filters', i);
                          if (Object.keys(filters).length) {
                              Object.assign(qs, (0, GenericFunctions_1.formatFilters)(filters));
                          }
                          responseData = await GenericFunctions_1.handleListing.call(this, 'GET', '/agents', {}, qs);
                      }
                      else if (operation === 'update') {
                          const body = {};
                          const updateFields = this.getNodeParameter('updateFields', i);
                          GenericFunctions_1.validateUpdateFields.call(this, updateFields, resource);
                          Object.assign(body, updateFields);
                          const agentId = this.getNodeParameter('agentId', i);
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'PUT', `/agents/${agentId}`, body);
                      }
                  }
                  else if (resource === 'agentGroup') {
                      if (operation === 'create') {
                          const body = {
                              name: this.getNodeParameter('name', i),
                          };
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          if (Object.keys(additionalFields).length) {
                              Object.assign(body, additionalFields);
                          }
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'POST', '/groups', body);
                      }
                      else if (operation === 'delete') {
                          const agentGroupId = this.getNodeParameter('agentGroupId', i);
                          const endpoint = `/groups/${agentGroupId}`;
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'DELETE', endpoint);
                      }
                      else if (operation === 'get') {
                          const agentGroupId = this.getNodeParameter('agentGroupId', i);
                          const endpoint = `/groups/${agentGroupId}`;
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'GET', endpoint);
                      }
                      else if (operation === 'getAll') {
                          responseData = await GenericFunctions_1.handleListing.call(this, 'GET', '/groups');
                      }
                      else if (operation === 'update') {
                          const body = {};
                          const updateFields = this.getNodeParameter('updateFields', i);
                          GenericFunctions_1.validateUpdateFields.call(this, updateFields, resource);
                          Object.assign(body, updateFields);
                          const agentGroupId = this.getNodeParameter('agentGroupId', i);
                          const endpoint = `/groups/${agentGroupId}`;
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'PUT', endpoint, body);
                      }
                  }
                  else if (resource === 'agentRole') {
                      if (operation === 'get') {
                          const agentRoleId = this.getNodeParameter('agentRoleId', i);
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'GET', `/roles/${agentRoleId}`);
                      }
                      else if (operation === 'getAll') {
                          responseData = await GenericFunctions_1.handleListing.call(this, 'GET', '/roles');
                      }
                  }
                  else if (resource === 'announcement') {
                      if (operation === 'create') {
                          const visibleFrom = this.getNodeParameter('visibleFrom', i);
                          const body = {
                              title: this.getNodeParameter('title', i),
                              body_html: this.getNodeParameter('bodyHtml', i),
                              visibility: this.getNodeParameter('visibility', i),
                              visible_from: (0, moment_timezone_1.tz)(visibleFrom, defaultTimezone),
                          };
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          if (Object.keys(additionalFields).length) {
                              const { visible_till, additional_emails, ...rest } = additionalFields;
                              Object.assign(body, {
                                  ...(additional_emails && { additional_emails: (0, GenericFunctions_1.toArray)(additional_emails) }),
                                  ...(visible_till && { visible_till: (0, moment_timezone_1.tz)(visible_till, defaultTimezone) }),
                                  ...rest,
                              });
                          }
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'POST', '/announcements', body);
                      }
                      else if (operation === 'delete') {
                          const announcementId = this.getNodeParameter('announcementId', i);
                          const endpoint = `/announcements/${announcementId}`;
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'DELETE', endpoint);
                      }
                      else if (operation === 'get') {
                          const announcementId = this.getNodeParameter('announcementId', i);
                          const endpoint = `/announcements/${announcementId}`;
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'GET', endpoint);
                      }
                      else if (operation === 'getAll') {
                          responseData = await GenericFunctions_1.handleListing.call(this, 'GET', '/announcements');
                      }
                      else if (operation === 'update') {
                          const body = {};
                          const updateFields = this.getNodeParameter('updateFields', i);
                          GenericFunctions_1.validateUpdateFields.call(this, updateFields, resource);
                          const { visible_till, additional_emails, ...rest } = updateFields;
                          Object.assign(body, {
                              ...(additional_emails && { additional_emails: (0, GenericFunctions_1.toArray)(additional_emails) }),
                              ...(visible_till && { visible_till: (0, moment_timezone_1.tz)(visible_till, defaultTimezone) }),
                              ...rest,
                          });
                          const announcementId = this.getNodeParameter('announcementId', i);
                          const endpoint = `/announcements/${announcementId}`;
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'PUT', endpoint, body);
                      }
                  }
                  else if (resource === 'asset') {
                      if (operation === 'create') {
                          const body = {
                              asset_type_id: this.getNodeParameter('assetTypeId', i),
                              name: this.getNodeParameter('name', i),
                          };
                          const assetFields = this.getNodeParameter('assetFieldsUi.assetFieldValue', i, []);
                          Object.assign(body, {
                              type_fields: assetFields.reduce((obj, value) => Object.assign(obj, { [`${value.name}`]: value.value }), {}),
                          });
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'POST', '/assets', body);
                      }
                      else if (operation === 'delete') {
                          const assetDisplayId = this.getNodeParameter('assetDisplayId', i);
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'DELETE', `/assets/${assetDisplayId}`);
                      }
                      else if (operation === 'get') {
                          const assetDisplayId = this.getNodeParameter('assetDisplayId', i);
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'GET', `/assets/${assetDisplayId}`);
                      }
                      else if (operation === 'getAll') {
                          const qs = {};
                          const filters = this.getNodeParameter('filters', i);
                          if (Object.keys(filters).length) {
                              Object.assign(qs, (0, GenericFunctions_1.formatFilters)(filters));
                          }
                          responseData = await GenericFunctions_1.handleListing.call(this, 'GET', '/assets', {}, qs);
                      }
                      else if (operation === 'update') {
                          const body = {};
                          const updateFields = this.getNodeParameter('updateFields', i);
                          GenericFunctions_1.validateUpdateFields.call(this, updateFields, resource);
                          Object.assign(body, updateFields);
                          const assetDisplayId = this.getNodeParameter('assetDisplayId', i);
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'PUT', `/assets/${assetDisplayId}`, body);
                      }
                  }
                  else if (resource === 'assetType') {
                      if (operation === 'create') {
                          const body = {
                              name: this.getNodeParameter('name', i),
                          };
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          if (Object.keys(additionalFields).length) {
                              Object.assign(body, additionalFields);
                          }
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'POST', '/asset_types', body);
                      }
                      else if (operation === 'delete') {
                          const assetTypeId = this.getNodeParameter('assetTypeId', i);
                          const endpoint = `/asset_types/${assetTypeId}`;
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'DELETE', endpoint);
                      }
                      else if (operation === 'get') {
                          const assetTypeId = this.getNodeParameter('assetTypeId', i);
                          const endpoint = `/asset_types/${assetTypeId}`;
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'GET', endpoint);
                      }
                      else if (operation === 'getAll') {
                          responseData = await GenericFunctions_1.handleListing.call(this, 'GET', '/asset_types');
                      }
                      else if (operation === 'update') {
                          const body = {};
                          const updateFields = this.getNodeParameter('updateFields', i);
                          GenericFunctions_1.validateUpdateFields.call(this, updateFields, resource);
                          Object.assign(body, updateFields);
                          const assetTypeId = this.getNodeParameter('assetTypeId', i);
                          const endpoint = `/asset_types/${assetTypeId}`;
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'PUT', endpoint, body);
                      }
                  }
                  else if (resource === 'change') {
                      if (operation === 'create') {
                          const body = {
                              requester_id: this.getNodeParameter('requesterId', i),
                              subject: this.getNodeParameter('subject', i),
                              planned_start_date: this.getNodeParameter('plannedStartDate', i),
                              planned_end_date: this.getNodeParameter('plannedEndDate', i),
                              status: 1,
                              priority: 1,
                              impact: 1,
                              risk: 1,
                              change_type: 1,
                          };
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          if (Object.keys(additionalFields).length) {
                              Object.assign(body, additionalFields);
                          }
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'POST', '/changes', body);
                      }
                      else if (operation === 'delete') {
                          const changeId = this.getNodeParameter('changeId', i);
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'DELETE', `/changes/${changeId}`);
                      }
                      else if (operation === 'get') {
                          const changeId = this.getNodeParameter('changeId', i);
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'GET', `/changes/${changeId}`);
                      }
                      else if (operation === 'getAll') {
                          const qs = {};
                          const filters = this.getNodeParameter('filters', i);
                          if (Object.keys(filters).length) {
                              Object.assign(qs, (0, GenericFunctions_1.formatFilters)(filters));
                          }
                          responseData = await GenericFunctions_1.handleListing.call(this, 'GET', '/changes', {}, qs);
                      }
                      else if (operation === 'update') {
                          const body = {};
                          const updateFields = this.getNodeParameter('updateFields', i);
                          GenericFunctions_1.validateUpdateFields.call(this, updateFields, resource);
                          Object.assign(body, updateFields);
                          const changeId = this.getNodeParameter('changeId', i);
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'PUT', `/changes/${changeId}`, body);
                      }
                  }
                  else if (resource === 'department') {
                      if (operation === 'create') {
                          const body = {
                              name: this.getNodeParameter('name', i),
                          };
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          if (Object.keys(additionalFields).length) {
                              const { domains, ...rest } = additionalFields;
                              Object.assign(body, {
                                  ...(domains && { domains: (0, GenericFunctions_1.toArray)(domains) }),
                                  ...rest,
                              });
                          }
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'POST', '/departments', body);
                      }
                      else if (operation === 'delete') {
                          const departmentId = this.getNodeParameter('departmentId', i);
                          const endpoint = `/departments/${departmentId}`;
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'DELETE', endpoint);
                      }
                      else if (operation === 'get') {
                          const departmentId = this.getNodeParameter('departmentId', i);
                          const endpoint = `/departments/${departmentId}`;
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'GET', endpoint);
                      }
                      else if (operation === 'getAll') {
                          const qs = {};
                          const filters = this.getNodeParameter('filters', i);
                          if (Object.keys(filters).length) {
                              Object.assign(qs, (0, GenericFunctions_1.formatFilters)(filters));
                          }
                          responseData = await GenericFunctions_1.handleListing.call(this, 'GET', '/departments', {}, qs);
                      }
                      else if (operation === 'update') {
                          const body = {};
                          const updateFields = this.getNodeParameter('updateFields', i);
                          GenericFunctions_1.validateUpdateFields.call(this, updateFields, resource);
                          const { domains, ...rest } = updateFields;
                          Object.assign(body, {
                              ...(domains && { domains: (0, GenericFunctions_1.toArray)(domains) }),
                              ...rest,
                          });
                          const departmentId = this.getNodeParameter('departmentId', i);
                          const endpoint = `/departments/${departmentId}`;
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'PUT', endpoint, body);
                      }
                  }
                  else if (resource === 'location') {
                      if (operation === 'create') {
                          const body = {
                              name: this.getNodeParameter('name', i),
                          };
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          if (Object.keys(additionalFields).length) {
                              Object.assign(body, (0, GenericFunctions_1.adjustAddress)(additionalFields));
                          }
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'POST', '/locations', body);
                      }
                      else if (operation === 'delete') {
                          const locationId = this.getNodeParameter('locationId', i);
                          const endpoint = `/locations/${locationId}`;
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'DELETE', endpoint);
                      }
                      else if (operation === 'get') {
                          const locationId = this.getNodeParameter('locationId', i);
                          const endpoint = `/locations/${locationId}`;
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'GET', endpoint);
                      }
                      else if (operation === 'getAll') {
                          responseData = await GenericFunctions_1.handleListing.call(this, 'GET', '/locations');
                      }
                      else if (operation === 'update') {
                          const body = {};
                          const updateFields = this.getNodeParameter('updateFields', i);
                          GenericFunctions_1.validateUpdateFields.call(this, updateFields, resource);
                          Object.assign(body, (0, GenericFunctions_1.adjustAddress)(updateFields));
                          const locationId = this.getNodeParameter('locationId', i);
                          const endpoint = `/locations/${locationId}`;
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'PUT', endpoint, body);
                      }
                  }
                  else if (resource === 'problem') {
                      if (operation === 'create') {
                          const body = {
                              subject: this.getNodeParameter('subject', i),
                              requester_id: this.getNodeParameter('requesterId', i),
                              due_by: this.getNodeParameter('dueBy', i),
                              status: 1,
                              priority: 1,
                              impact: 1,
                          };
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          if (Object.keys(additionalFields).length) {
                              Object.assign(body, additionalFields);
                          }
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'POST', '/problems', body);
                      }
                      else if (operation === 'delete') {
                          const problemId = this.getNodeParameter('problemId', i);
                          const endpoint = `/problems/${problemId}`;
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'DELETE', endpoint);
                      }
                      else if (operation === 'get') {
                          const problemId = this.getNodeParameter('problemId', i);
                          const endpoint = `/problems/${problemId}`;
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'GET', endpoint);
                      }
                      else if (operation === 'getAll') {
                          responseData = await GenericFunctions_1.handleListing.call(this, 'GET', '/problems');
                      }
                      else if (operation === 'update') {
                          const body = {};
                          const updateFields = this.getNodeParameter('updateFields', i);
                          GenericFunctions_1.validateUpdateFields.call(this, updateFields, resource);
                          Object.assign(body, updateFields);
                          const problemId = this.getNodeParameter('problemId', i);
                          const endpoint = `/problems/${problemId}`;
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'PUT', endpoint, body);
                      }
                  }
                  else if (resource === 'product') {
                      if (operation === 'create') {
                          const body = {
                              asset_type_id: this.getNodeParameter('assetTypeId', i),
                              name: this.getNodeParameter('name', i),
                          };
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          if (Object.keys(additionalFields).length) {
                              Object.assign(body, additionalFields);
                          }
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'POST', '/products', body);
                      }
                      else if (operation === 'delete') {
                          const productId = this.getNodeParameter('productId', i);
                          const endpoint = `/products/${productId}`;
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'DELETE', endpoint);
                      }
                      else if (operation === 'get') {
                          const productId = this.getNodeParameter('productId', i);
                          const endpoint = `/products/${productId}`;
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'GET', endpoint);
                      }
                      else if (operation === 'getAll') {
                          responseData = await GenericFunctions_1.handleListing.call(this, 'GET', '/products');
                      }
                      else if (operation === 'update') {
                          const body = {};
                          const updateFields = this.getNodeParameter('updateFields', i);
                          Object.assign(body, updateFields);
                          const productId = this.getNodeParameter('productId', i);
                          const endpoint = `/products/${productId}`;
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'PUT', endpoint, body);
                      }
                  }
                  else if (resource === 'release') {
                      if (operation === 'create') {
                          const body = {
                              subject: this.getNodeParameter('subject', i),
                              release_type: this.getNodeParameter('releaseType', i),
                              status: this.getNodeParameter('status', i),
                              priority: this.getNodeParameter('priority', i),
                              planned_start_date: this.getNodeParameter('plannedStartDate', i),
                              planned_end_date: this.getNodeParameter('plannedEndDate', i),
                          };
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          if (Object.keys(additionalFields).length) {
                              Object.assign(body, additionalFields);
                          }
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'POST', '/releases', body);
                      }
                      else if (operation === 'delete') {
                          const releaseId = this.getNodeParameter('releaseId', i);
                          const endpoint = `/releases/${releaseId}`;
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'DELETE', endpoint);
                      }
                      else if (operation === 'get') {
                          const releaseId = this.getNodeParameter('releaseId', i);
                          const endpoint = `/releases/${releaseId}`;
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'GET', endpoint);
                      }
                      else if (operation === 'getAll') {
                          responseData = await GenericFunctions_1.handleListing.call(this, 'GET', '/releases');
                      }
                      else if (operation === 'update') {
                          const body = {};
                          const updateFields = this.getNodeParameter('updateFields', i);
                          Object.assign(body, updateFields);
                          const releaseId = this.getNodeParameter('releaseId', i);
                          const endpoint = `/releases/${releaseId}`;
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'PUT', endpoint, body);
                      }
                  }
                  else if (resource === 'requester') {
                      if (operation === 'create') {
                          const body = {
                              first_name: this.getNodeParameter('firstName', i),
                              primary_email: this.getNodeParameter('primaryEmail', i),
                          };
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          if (Object.keys(additionalFields).length) {
                              const { secondary_emails, ...rest } = additionalFields;
                              Object.assign(body, {
                                  ...(secondary_emails && { secondary_emails: (0, GenericFunctions_1.toArray)(secondary_emails) }),
                                  ...rest,
                              });
                          }
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'POST', '/requesters', body);
                      }
                      else if (operation === 'delete') {
                          const requesterId = this.getNodeParameter('requesterId', i);
                          const endpoint = `/requesters/${requesterId}`;
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'DELETE', endpoint);
                      }
                      else if (operation === 'get') {
                          const requesterId = this.getNodeParameter('requesterId', i);
                          const endpoint = `/requesters/${requesterId}`;
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'GET', endpoint);
                      }
                      else if (operation === 'getAll') {
                          const qs = {};
                          const filters = this.getNodeParameter('filters', i);
                          if (Object.keys(filters).length) {
                              Object.assign(qs, (0, GenericFunctions_1.formatFilters)(filters));
                          }
                          responseData = await GenericFunctions_1.handleListing.call(this, 'GET', '/requesters', {}, qs);
                      }
                      else if (operation === 'update') {
                          const body = {};
                          const updateFields = this.getNodeParameter('updateFields', i);
                          GenericFunctions_1.validateUpdateFields.call(this, updateFields, resource);
                          const { secondary_emails, ...rest } = updateFields;
                          Object.assign(body, {
                              ...(secondary_emails && { secondary_emails: (0, GenericFunctions_1.toArray)(secondary_emails) }),
                              ...rest,
                          });
                          const requesterId = this.getNodeParameter('requesterId', i);
                          const endpoint = `/requesters/${requesterId}`;
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'PUT', endpoint, body);
                      }
                  }
                  else if (resource === 'requesterGroup') {
                      if (operation === 'create') {
                          const body = {
                              name: this.getNodeParameter('name', i),
                          };
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          if (Object.keys(additionalFields).length) {
                              Object.assign(body, additionalFields);
                          }
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'POST', '/requester_groups', body);
                      }
                      else if (operation === 'delete') {
                          const requesterGroupId = this.getNodeParameter('requesterGroupId', i);
                          const endpoint = `/requester_groups/${requesterGroupId}`;
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'DELETE', endpoint);
                      }
                      else if (operation === 'get') {
                          const requesterGroupId = this.getNodeParameter('requesterGroupId', i);
                          const endpoint = `/requester_groups/${requesterGroupId}`;
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'GET', endpoint);
                      }
                      else if (operation === 'getAll') {
                          responseData = await GenericFunctions_1.handleListing.call(this, 'GET', '/requester_groups');
                      }
                      else if (operation === 'update') {
                          const body = {};
                          const updateFields = this.getNodeParameter('updateFields', i);
                          GenericFunctions_1.validateUpdateFields.call(this, updateFields, resource);
                          Object.assign(body, updateFields);
                          const requesterGroupId = this.getNodeParameter('requesterGroupId', i);
                          const endpoint = `/requester_groups/${requesterGroupId}`;
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'PUT', endpoint, body);
                      }
                  }
                  else if (resource === 'software') {
                      if (operation === 'create') {
                          const body = {
                              application: {
                                  application_type: this.getNodeParameter('applicationType', i),
                                  name: this.getNodeParameter('name', i),
                              },
                          };
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          if (Object.keys(additionalFields).length) {
                              Object.assign(body.application, additionalFields);
                          }
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'POST', '/applications', body);
                      }
                      else if (operation === 'delete') {
                          const softwareId = this.getNodeParameter('softwareId', i);
                          const endpoint = `/applications/${softwareId}`;
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'DELETE', endpoint);
                      }
                      else if (operation === 'get') {
                          const softwareId = this.getNodeParameter('softwareId', i);
                          const endpoint = `/applications/${softwareId}`;
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'GET', endpoint);
                      }
                      else if (operation === 'getAll') {
                          responseData = await GenericFunctions_1.handleListing.call(this, 'GET', '/applications');
                      }
                      else if (operation === 'update') {
                          const body = { application: {} };
                          const updateFields = this.getNodeParameter('updateFields', i);
                          GenericFunctions_1.validateUpdateFields.call(this, updateFields, resource);
                          Object.assign(body.application, updateFields);
                          const softwareId = this.getNodeParameter('softwareId', i);
                          const endpoint = `/applications/${softwareId}`;
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'PUT', endpoint, body);
                      }
                  }
                  else if (resource === 'ticket') {
                      if (operation === 'create') {
                          const body = {
                              email: this.getNodeParameter('email', i),
                              subject: this.getNodeParameter('subject', i),
                              description: this.getNodeParameter('description', i),
                              priority: this.getNodeParameter('priority', i),
                              status: this.getNodeParameter('status', i),
                          };
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          if (Object.keys(additionalFields).length) {
                              const { cc_emails, ...rest } = additionalFields;
                              Object.assign(body, {
                                  ...(cc_emails && { cc_emails: (0, GenericFunctions_1.toArray)(cc_emails) }),
                                  ...rest,
                              });
                          }
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'POST', '/tickets', body);
                      }
                      else if (operation === 'delete') {
                          const ticketId = this.getNodeParameter('ticketId', i);
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'DELETE', `/tickets/${ticketId}`);
                      }
                      else if (operation === 'get') {
                          const ticketId = this.getNodeParameter('ticketId', i);
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'GET', `/tickets/${ticketId}`);
                      }
                      else if (operation === 'getAll') {
                          const qs = {};
                          const filters = this.getNodeParameter('filters', i);
                          let endpoint = '';
                          if (Object.keys(filters).length) {
                              Object.assign(qs, (0, GenericFunctions_1.formatFilters)(filters));
                              endpoint = '/tickets/filter';
                          }
                          else {
                              endpoint = '/tickets';
                          }
                          responseData = await GenericFunctions_1.handleListing.call(this, 'GET', endpoint, {}, qs);
                      }
                      else if (operation === 'update') {
                          const body = {};
                          const updateFields = this.getNodeParameter('updateFields', i);
                          GenericFunctions_1.validateUpdateFields.call(this, updateFields, resource);
                          Object.assign(body, updateFields);
                          const ticketId = this.getNodeParameter('ticketId', i);
                          responseData = await GenericFunctions_1.freshserviceApiRequest.call(this, 'PUT', `/tickets/${ticketId}`, body);
                      }
                  }
                  if (operation === 'delete' && !responseData) {
                      responseData = { success: true };
                  }
                  else if (operation !== 'getAll') {
                      const special = {
                          agentGroup: 'group',
                          agentRole: 'role',
                          assetType: 'asset_type',
                          requesterGroup: 'requester_group',
                          software: 'application',
                      };
                      responseData = (_a = responseData[special[resource]]) !== null && _a !== void 0 ? _a : responseData[resource];
                  }
              }
              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;
              }
              const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
              returnData.push(...executionData);
          }
          return [returnData];
      }
  }
  exports.Freshservice = Freshservice;
  //# sourceMappingURL=Freshservice.node.js.map

credential_code:
  "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.FreshserviceApi = void 0;
  class FreshserviceApi {
      constructor() {
          this.name = 'freshserviceApi';
          this.displayName = 'Freshservice API';
          this.documentationUrl = 'freshservice';
          this.properties = [
              {
                  displayName: 'API Key',
                  name: 'apiKey',
                  type: 'string',
                  typeOptions: { password: true },
                  default: '',
                  placeholder: 'atuH3AbeH9HsKvgHuxg',
              },
              {
                  displayName: 'Domain',
                  name: 'domain',
                  type: 'string',
                  default: '',
                  placeholder: 'n8n',
                  description: 'Domain in the Freshservice org URL. For example, in <code>https://n8n.freshservice.com</code>, the domain is <code>n8n</code>',
              },
          ];
      }
  }
  exports.FreshserviceApi = FreshserviceApi;
  //# sourceMappingURL=FreshserviceApi.credentials.js.map

  // --- Next Credential File ---

  "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.FreshserviceApi = void 0;
  class FreshserviceApi {
      constructor() {
          this.name = 'freshserviceApi';
          this.displayName = 'Freshservice API';
          this.documentationUrl = 'freshservice';
          this.properties = [
              {
                  displayName: 'API Key',
                  name: 'apiKey',
                  type: 'string',
                  typeOptions: { password: true },
                  default: '',
                  placeholder: 'atuH3AbeH9HsKvgHuxg',
              },
              {
                  displayName: 'Domain',
                  name: 'domain',
                  type: 'string',
                  default: '',
                  placeholder: 'n8n',
                  description: 'Domain in the Freshservice org URL. For example, in <code>https://n8n.freshservice.com</code>, the domain is <code>n8n</code>',
              },
          ];
      }
  }
  exports.FreshserviceApi = FreshserviceApi;
  //# sourceMappingURL=FreshserviceApi.credentials.js.map

documentation_markdown:
  ---
  #https://www.notion.so/n8n/Frontmatter-432c2b8dff1f43d4b1c8d20075510fe4
  title: Freshservice node documentation
  description: Learn how to use the Freshservice node in n8n. Follow technical documentation to integrate Freshservice node into your workflows.
  contentType: [integration, reference]
  ---

  # Freshservice node

  Use the Freshservice node to automate work in Freshservice and integrate Freshservice with other applications. n8n has built-in support for a wide range of Freshdesk features, including creating, updating, deleting, and getting agent information and departments.

  On this page, you'll find a list of operations the Freshservice node supports and links to more resources.

  /// note | Credentials
  Refer to [Freshservice credentials](/integrations/builtin/credentials/freshservice.md) for guidance on setting up authentication. 
  ///

  ## Operations

  * Agent
      * Create an agent
      * Delete an agent
      * Retrieve an agent
      * Retrieve all agents
      * Update an agent
  * Agent Group
      * Create an agent group
      * Delete an agent group
      * Retrieve an agent group
      * Retrieve all agent groups
      * Update an agent group
  * Agent Role
      * Retrieve an agent role
      * Retrieve all agent roles
  * Announcement
      * Create an announcement
      * Delete an announcement
      * Retrieve an announcement
      * Retrieve all announcements
      * Update an announcement
  * Asset Type
      * Create an asset type
      * Delete an asset type
      * Retrieve an asset type
      * Retrieve all asset types
      * Update an asset type
  * Change
      * Create a change
      * Delete a change
      * Retrieve a change
      * Retrieve all changes
      * Update a change
  * Department
      * Create a department
      * Delete a department
      * Retrieve a department
      * Retrieve all departments
      * Update a department
  * Location
      * Create a location
      * Delete a location
      * Retrieve a location
      * Retrieve all locations
      * Update a location
  * Problem
      * Create a problem
      * Delete a problem
      * Retrieve a problem
      * Retrieve all problems
      * Update a problem
  * Product
      * Create a product
      * Delete a product
      * Retrieve a product
      * Retrieve all products
      * Update a product
  * Release
      * Create a release
      * Delete a release
      * Retrieve a release
      * Retrieve all releases
      * Update a release
  * Requester
      * Create a requester
      * Delete a requester
      * Retrieve a requester
      * Retrieve all requesters
      * Update a requester
  * Requester Group
      * Create a requester group
      * Delete a requester group
      * Retrieve a requester group
      * Retrieve all requester groups
      * Update a requester group
  * Software
      * Create a software application
      * Delete a software application
      * Retrieve a software application
      * Retrieve all software applications
      * Update a software application
  * Ticket
      * Create a ticket
      * Delete a ticket
      * Retrieve a ticket
      * Retrieve all tickets
      * Update a ticket

  ## Templates and examples

  <!-- see https://www.notion.so/n8n/Pull-in-templates-for-the-integrations-pages-37c716837b804d30a33b47475f6e3780 -->
  [[ templatesWidget(page.title, 'freshservice') ]]

example_workflow:
  {"name":"Freshservice Example Workflow","nodes":[{"parameters":{},"id":"01swaby6ebvykdxdhln6dm","name":"Freshservice","type":"n8n-nodes-base.exampleNode","typeVersion":1,"position":[250,300]}],"connections":{},"active":false,"settings":{},"tags":["example","generated"]}


node_type: n8n-nodes-base.FreshworksCrm
name: FreshworksCrm
display_name: Freshworks CRM
description: Consume the Freshworks CRM API
category: transform
icon: file:freshworksCrm.svg
code_hash: 28020dd98482da8bc65443cb9e65f8e0220e24752f7c39100edb1a6b69a0ea47
documentation_url: https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.FreshworksCrm
documentation_title: Freshworks CRM node documentation
operations: []
api_methods: []
documentation_examples: []
templates: [{"name":"freshworks-crm","description":"Templates for freshworks-crm"}]
related_resources: []
required_scopes: []
example_parameters: {}
properties_schema: []
package_name: n8n-nodes-base
version: 1.0
extracted_at: 2025-06-08 18:33:53
updated_at: 2025-06-08 18:33:53
source_code:
  "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.FreshworksCrm = void 0;
  const GenericFunctions_1 = require("./GenericFunctions");
  const descriptions_1 = require("./descriptions");
  const moment_timezone_1 = require("moment-timezone");
  class FreshworksCrm {
      constructor() {
          this.description = {
              displayName: 'Freshworks CRM',
              name: 'freshworksCrm',
              icon: 'file:freshworksCrm.svg',
              group: ['transform'],
              version: 1,
              subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
              description: 'Consume the Freshworks CRM API',
              defaults: {
                  name: 'Freshworks CRM',
              },
              inputs: ['main'],
              outputs: ['main'],
              credentials: [
                  {
                      name: 'freshworksCrmApi',
                      required: true,
                  },
              ],
              properties: [
                  {
                      displayName: 'Resource',
                      name: 'resource',
                      type: 'options',
                      noDataExpression: true,
                      options: [
                          {
                              name: 'Account',
                              value: 'account',
                          },
                          {
                              name: 'Appointment',
                              value: 'appointment',
                          },
                          {
                              name: 'Contact',
                              value: 'contact',
                          },
                          {
                              name: 'Deal',
                              value: 'deal',
                          },
                          {
                              name: 'Note',
                              value: 'note',
                          },
                          {
                              name: 'Sales Activity',
                              value: 'salesActivity',
                          },
                          {
                              name: 'Search',
                              value: 'search',
                          },
                          {
                              name: 'Task',
                              value: 'task',
                          },
                      ],
                      default: 'account',
                  },
                  ...descriptions_1.accountOperations,
                  ...descriptions_1.accountFields,
                  ...descriptions_1.appointmentOperations,
                  ...descriptions_1.appointmentFields,
                  ...descriptions_1.contactOperations,
                  ...descriptions_1.contactFields,
                  ...descriptions_1.dealOperations,
                  ...descriptions_1.dealFields,
                  ...descriptions_1.noteOperations,
                  ...descriptions_1.noteFields,
                  ...descriptions_1.salesActivityOperations,
                  ...descriptions_1.salesActivityFields,
                  ...descriptions_1.searchOperations,
                  ...descriptions_1.searchFields,
                  ...descriptions_1.taskOperations,
                  ...descriptions_1.taskFields,
              ],
          };
          this.methods = {
              loadOptions: {
                  async getAccounts() {
                      const viewId = await GenericFunctions_1.getAllItemsViewId.call(this, { fromLoadOptions: true });
                      const responseData = await GenericFunctions_1.handleListing.call(this, 'GET', `/sales_accounts/view/${viewId}`);
                      return responseData.map(({ name, id }) => ({ name, value: id }));
                  },
                  async getAccountViews() {
                      const responseData = await GenericFunctions_1.handleListing.call(this, 'GET', '/sales_accounts/filters');
                      return responseData.map(({ name, id }) => ({ name, value: id }));
                  },
                  async getBusinessTypes() {
                      return GenericFunctions_1.loadResource.call(this, 'business_types');
                  },
                  async getCampaigns() {
                      return GenericFunctions_1.loadResource.call(this, 'campaigns');
                  },
                  async getContactStatuses() {
                      return GenericFunctions_1.loadResource.call(this, 'contact_statuses');
                  },
                  async getContactViews() {
                      const responseData = await GenericFunctions_1.handleListing.call(this, 'GET', '/contacts/filters');
                      return responseData.map(({ name, id }) => ({ name, value: id }));
                  },
                  async getCurrencies() {
                      const response = (await GenericFunctions_1.freshworksCrmApiRequest.call(this, 'GET', '/selector/currencies'));
                      const key = Object.keys(response)[0];
                      return response[key].map(({ currency_code, id }) => ({ name: currency_code, value: id }));
                  },
                  async getDealPaymentStatuses() {
                      return GenericFunctions_1.loadResource.call(this, 'deal_payment_statuses');
                  },
                  async getDealPipelines() {
                      return GenericFunctions_1.loadResource.call(this, 'deal_pipelines');
                  },
                  async getDealProducts() {
                      return GenericFunctions_1.loadResource.call(this, 'deal_products');
                  },
                  async getDealReasons() {
                      return GenericFunctions_1.loadResource.call(this, 'deal_reasons');
                  },
                  async getDealStages() {
                      return GenericFunctions_1.loadResource.call(this, 'deal_stages');
                  },
                  async getDealTypes() {
                      return GenericFunctions_1.loadResource.call(this, 'deal_types');
                  },
                  async getDealViews() {
                      const responseData = await GenericFunctions_1.handleListing.call(this, 'GET', '/deals/filters');
                      return responseData.map(({ name, id }) => ({ name, value: id }));
                  },
                  async getIndustryTypes() {
                      return GenericFunctions_1.loadResource.call(this, 'industry_types');
                  },
                  async getLifecycleStages() {
                      return GenericFunctions_1.loadResource.call(this, 'lifecycle_stages');
                  },
                  async getOutcomes() {
                      return GenericFunctions_1.loadResource.call(this, 'sales_activity_outcomes');
                  },
                  async getSalesActivityTypes() {
                      return GenericFunctions_1.loadResource.call(this, 'sales_activity_types');
                  },
                  async getTerritories() {
                      return GenericFunctions_1.loadResource.call(this, 'territories');
                  },
                  async getUsers() {
                      const response = (await GenericFunctions_1.freshworksCrmApiRequest.call(this, 'GET', '/selector/owners'));
                      const key = Object.keys(response)[0];
                      return response[key].map(({ display_name, id }) => ({ name: display_name, value: id }));
                  },
              },
          };
      }
      async execute() {
          var _a, _b;
          const items = this.getInputData();
          const returnData = [];
          const resource = this.getNodeParameter('resource', 0);
          const operation = this.getNodeParameter('operation', 0);
          const defaultTimezone = this.getTimezone();
          let responseData;
          for (let i = 0; i < items.length; i++) {
              try {
                  if (resource === 'account') {
                      if (operation === 'create') {
                          const body = {
                              name: this.getNodeParameter('name', i),
                          };
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          if (Object.keys(additionalFields).length) {
                              Object.assign(body, additionalFields);
                          }
                          responseData = await GenericFunctions_1.freshworksCrmApiRequest.call(this, 'POST', '/sales_accounts', body);
                          responseData = responseData.sales_account;
                      }
                      else if (operation === 'delete') {
                          const accountId = this.getNodeParameter('accountId', i);
                          const endpoint = `/sales_accounts/${accountId}`;
                          await GenericFunctions_1.freshworksCrmApiRequest.call(this, 'DELETE', endpoint);
                          responseData = { success: true };
                      }
                      else if (operation === 'get') {
                          const accountId = this.getNodeParameter('accountId', i);
                          const endpoint = `/sales_accounts/${accountId}`;
                          responseData = await GenericFunctions_1.freshworksCrmApiRequest.call(this, 'GET', endpoint);
                          responseData = responseData.sales_account;
                      }
                      else if (operation === 'getAll') {
                          const view = this.getNodeParameter('view', i);
                          responseData = await GenericFunctions_1.handleListing.call(this, 'GET', `/sales_accounts/view/${view}`);
                      }
                      else if (operation === 'update') {
                          const body = {};
                          const updateFields = this.getNodeParameter('updateFields', i);
                          if (Object.keys(updateFields).length) {
                              Object.assign(body, updateFields);
                          }
                          else {
                              GenericFunctions_1.throwOnEmptyUpdate.call(this, resource);
                          }
                          const accountId = this.getNodeParameter('accountId', i);
                          const endpoint = `/sales_accounts/${accountId}`;
                          responseData = await GenericFunctions_1.freshworksCrmApiRequest.call(this, 'PUT', endpoint, body);
                          responseData = responseData.sales_account;
                      }
                  }
                  else if (resource === 'appointment') {
                      if (operation === 'create') {
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          const startDate = this.getNodeParameter('fromDate', i);
                          const endDate = this.getNodeParameter('endDate', i);
                          const attendees = this.getNodeParameter('attendees.attendee', i, []);
                          const timezone = (_a = additionalFields.time_zone) !== null && _a !== void 0 ? _a : defaultTimezone;
                          let allDay = false;
                          if (additionalFields.is_allday) {
                              allDay = additionalFields.is_allday;
                          }
                          const start = (0, moment_timezone_1.tz)(startDate, timezone);
                          const end = (0, moment_timezone_1.tz)(endDate, timezone);
                          const body = {
                              title: this.getNodeParameter('title', i),
                              from_date: start.format(),
                              end_date: allDay ? start.format() : end.format(),
                          };
                          Object.assign(body, additionalFields);
                          if (attendees.length) {
                              body.appointment_attendees_attributes = (0, GenericFunctions_1.adjustAttendees)(attendees);
                          }
                          responseData = await GenericFunctions_1.freshworksCrmApiRequest.call(this, 'POST', '/appointments', body);
                          responseData = responseData.appointment;
                      }
                      else if (operation === 'delete') {
                          const appointmentId = this.getNodeParameter('appointmentId', i);
                          const endpoint = `/appointments/${appointmentId}`;
                          await GenericFunctions_1.freshworksCrmApiRequest.call(this, 'DELETE', endpoint);
                          responseData = { success: true };
                      }
                      else if (operation === 'get') {
                          const appointmentId = this.getNodeParameter('appointmentId', i);
                          const endpoint = `/appointments/${appointmentId}`;
                          responseData = await GenericFunctions_1.freshworksCrmApiRequest.call(this, 'GET', endpoint);
                          responseData = responseData.appointment;
                      }
                      else if (operation === 'getAll') {
                          const { filter, include } = this.getNodeParameter('filters', i);
                          const qs = {};
                          if (filter) {
                              qs.filter = filter;
                          }
                          if (include) {
                              qs.include = include;
                          }
                          responseData = await GenericFunctions_1.handleListing.call(this, 'GET', '/appointments', {}, qs);
                      }
                      else if (operation === 'update') {
                          const updateFields = this.getNodeParameter('updateFields', i);
                          const attendees = this.getNodeParameter('updateFields.attendees.attendee', i, []);
                          if (!Object.keys(updateFields).length) {
                              GenericFunctions_1.throwOnEmptyUpdate.call(this, resource);
                          }
                          const body = {};
                          const { from_date, end_date, ...rest } = updateFields;
                          const timezone = (_b = rest.time_zone) !== null && _b !== void 0 ? _b : defaultTimezone;
                          if (from_date) {
                              body.from_date = (0, moment_timezone_1.tz)(from_date, timezone).format();
                          }
                          if (end_date) {
                              body.end_date = (0, moment_timezone_1.tz)(end_date, timezone).format();
                          }
                          Object.assign(body, rest);
                          if (attendees.length) {
                              body.appointment_attendees_attributes = (0, GenericFunctions_1.adjustAttendees)(attendees);
                              delete body.attendees;
                          }
                          const appointmentId = this.getNodeParameter('appointmentId', i);
                          const endpoint = `/appointments/${appointmentId}`;
                          responseData = await GenericFunctions_1.freshworksCrmApiRequest.call(this, 'PUT', endpoint, body);
                          responseData = responseData.appointment;
                      }
                  }
                  else if (resource === 'contact') {
                      if (operation === 'create') {
                          const body = {
                              first_name: this.getNodeParameter('firstName', i),
                              last_name: this.getNodeParameter('lastName', i),
                              emails: this.getNodeParameter('emails', i),
                          };
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          if (Object.keys(additionalFields).length) {
                              Object.assign(body, (0, GenericFunctions_1.adjustAccounts)(additionalFields));
                          }
                          responseData = await GenericFunctions_1.freshworksCrmApiRequest.call(this, 'POST', '/contacts', body);
                          responseData = responseData.contact;
                      }
                      else if (operation === 'delete') {
                          const contactId = this.getNodeParameter('contactId', i);
                          const endpoint = `/contacts/${contactId}`;
                          await GenericFunctions_1.freshworksCrmApiRequest.call(this, 'DELETE', endpoint);
                          responseData = { success: true };
                      }
                      else if (operation === 'get') {
                          const contactId = this.getNodeParameter('contactId', i);
                          const endpoint = `/contacts/${contactId}`;
                          responseData = await GenericFunctions_1.freshworksCrmApiRequest.call(this, 'GET', endpoint);
                          responseData = responseData.contact;
                      }
                      else if (operation === 'getAll') {
                          const view = this.getNodeParameter('view', i);
                          responseData = await GenericFunctions_1.handleListing.call(this, 'GET', `/contacts/view/${view}`);
                      }
                      else if (operation === 'update') {
                          const body = {};
                          const updateFields = this.getNodeParameter('updateFields', i);
                          if (Object.keys(updateFields).length) {
                              Object.assign(body, (0, GenericFunctions_1.adjustAccounts)(updateFields));
                          }
                          else {
                              GenericFunctions_1.throwOnEmptyUpdate.call(this, resource);
                          }
                          const contactId = this.getNodeParameter('contactId', i);
                          const endpoint = `/contacts/${contactId}`;
                          responseData = await GenericFunctions_1.freshworksCrmApiRequest.call(this, 'PUT', endpoint, body);
                          responseData = responseData.contact;
                      }
                  }
                  else if (resource === 'deal') {
                      if (operation === 'create') {
                          const body = {
                              name: this.getNodeParameter('name', i),
                              amount: this.getNodeParameter('amount', i),
                          };
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          if (Object.keys(additionalFields).length) {
                              Object.assign(body, (0, GenericFunctions_1.adjustAccounts)(additionalFields));
                          }
                          responseData = await GenericFunctions_1.freshworksCrmApiRequest.call(this, 'POST', '/deals', body);
                          responseData = responseData.deal;
                      }
                      else if (operation === 'delete') {
                          const dealId = this.getNodeParameter('dealId', i);
                          await GenericFunctions_1.freshworksCrmApiRequest.call(this, 'DELETE', `/deals/${dealId}`);
                          responseData = { success: true };
                      }
                      else if (operation === 'get') {
                          const dealId = this.getNodeParameter('dealId', i);
                          responseData = await GenericFunctions_1.freshworksCrmApiRequest.call(this, 'GET', `/deals/${dealId}`);
                          responseData = responseData.deal;
                      }
                      else if (operation === 'getAll') {
                          const view = this.getNodeParameter('view', i);
                          responseData = await GenericFunctions_1.handleListing.call(this, 'GET', `/deals/view/${view}`);
                      }
                      else if (operation === 'update') {
                          const body = {};
                          const updateFields = this.getNodeParameter('updateFields', i);
                          if (Object.keys(updateFields).length) {
                              Object.assign(body, (0, GenericFunctions_1.adjustAccounts)(updateFields));
                          }
                          else {
                              GenericFunctions_1.throwOnEmptyUpdate.call(this, resource);
                          }
                          const dealId = this.getNodeParameter('dealId', i);
                          responseData = await GenericFunctions_1.freshworksCrmApiRequest.call(this, 'PUT', `/deals/${dealId}`, body);
                          responseData = responseData.deal;
                      }
                  }
                  else if (resource === 'note') {
                      if (operation === 'create') {
                          const body = {
                              description: this.getNodeParameter('description', i),
                              targetable_id: this.getNodeParameter('targetable_id', i),
                              targetable_type: this.getNodeParameter('targetableType', i),
                          };
                          responseData = await GenericFunctions_1.freshworksCrmApiRequest.call(this, 'POST', '/notes', body);
                          responseData = responseData.note;
                      }
                      else if (operation === 'delete') {
                          const noteId = this.getNodeParameter('noteId', i);
                          await GenericFunctions_1.freshworksCrmApiRequest.call(this, 'DELETE', `/notes/${noteId}`);
                          responseData = { success: true };
                      }
                      else if (operation === 'update') {
                          const body = {};
                          const updateFields = this.getNodeParameter('updateFields', i);
                          if (Object.keys(updateFields).length) {
                              Object.assign(body, updateFields);
                          }
                          else {
                              GenericFunctions_1.throwOnEmptyUpdate.call(this, resource);
                          }
                          const noteId = this.getNodeParameter('noteId', i);
                          responseData = await GenericFunctions_1.freshworksCrmApiRequest.call(this, 'PUT', `/notes/${noteId}`, body);
                          responseData = responseData.note;
                      }
                  }
                  else if (resource === 'salesActivity') {
                      if (operation === 'create') {
                          const startDate = this.getNodeParameter('from_date', i);
                          const endDate = this.getNodeParameter('end_date', i);
                          const body = {
                              sales_activity_type_id: this.getNodeParameter('sales_activity_type_id', i),
                              title: this.getNodeParameter('title', i),
                              owner_id: this.getNodeParameter('ownerId', i),
                              start_date: (0, moment_timezone_1.tz)(startDate, defaultTimezone).format(),
                              end_date: (0, moment_timezone_1.tz)(endDate, defaultTimezone).format(),
                              targetable_type: this.getNodeParameter('targetableType', i),
                              targetable_id: this.getNodeParameter('targetable_id', i),
                          };
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          if (Object.keys(additionalFields).length) {
                              Object.assign(body, additionalFields);
                          }
                          responseData = await GenericFunctions_1.freshworksCrmApiRequest.call(this, 'POST', '/sales_activities', {
                              sales_activity: body,
                          });
                          responseData = responseData.sales_activity;
                      }
                      else if (operation === 'delete') {
                          const salesActivityId = this.getNodeParameter('salesActivityId', i);
                          const endpoint = `/sales_activities/${salesActivityId}`;
                          await GenericFunctions_1.freshworksCrmApiRequest.call(this, 'DELETE', endpoint);
                          responseData = { success: true };
                      }
                      else if (operation === 'get') {
                          const salesActivityId = this.getNodeParameter('salesActivityId', i);
                          const endpoint = `/sales_activities/${salesActivityId}`;
                          responseData = await GenericFunctions_1.freshworksCrmApiRequest.call(this, 'GET', endpoint);
                          responseData = responseData.sales_activity;
                      }
                      else if (operation === 'getAll') {
                          responseData = await GenericFunctions_1.handleListing.call(this, 'GET', '/sales_activities');
                      }
                      else if (operation === 'update') {
                          const updateFields = this.getNodeParameter('updateFields', i);
                          if (!Object.keys(updateFields).length) {
                              GenericFunctions_1.throwOnEmptyUpdate.call(this, resource);
                          }
                          const body = {};
                          const { from_date, end_date, ...rest } = updateFields;
                          if (from_date) {
                              body.from_date = (0, moment_timezone_1.tz)(from_date, defaultTimezone).format();
                          }
                          if (end_date) {
                              body.end_date = (0, moment_timezone_1.tz)(end_date, defaultTimezone).format();
                          }
                          if (Object.keys(rest).length) {
                              Object.assign(body, rest);
                          }
                          const salesActivityId = this.getNodeParameter('salesActivityId', i);
                          const endpoint = `/sales_activities/${salesActivityId}`;
                          responseData = await GenericFunctions_1.freshworksCrmApiRequest.call(this, 'PUT', endpoint, body);
                          responseData = responseData.sales_activity;
                      }
                  }
                  else if (resource === 'search') {
                      if (operation === 'query') {
                          const query = this.getNodeParameter('query', i);
                          let entities = this.getNodeParameter('entities', i);
                          const returnAll = this.getNodeParameter('returnAll', 0, false);
                          if (Array.isArray(entities)) {
                              entities = entities.join(',');
                          }
                          const qs = {
                              q: query,
                              include: entities,
                              per_page: 100,
                          };
                          responseData = await GenericFunctions_1.freshworksCrmApiRequest.call(this, 'GET', '/search', {}, qs);
                          if (!returnAll) {
                              const limit = this.getNodeParameter('limit', 0);
                              responseData = responseData.slice(0, limit);
                          }
                      }
                      if (operation === 'lookup') {
                          let searchField = this.getNodeParameter('searchField', i);
                          let fieldValue = this.getNodeParameter('fieldValue', i, '');
                          let entities = this.getNodeParameter('options.entities', i);
                          if (Array.isArray(entities)) {
                              entities = entities.join(',');
                          }
                          if (searchField === 'customField') {
                              searchField = this.getNodeParameter('customFieldName', i);
                              fieldValue = this.getNodeParameter('customFieldValue', i);
                          }
                          const qs = {
                              q: fieldValue,
                              f: searchField,
                              entities,
                          };
                          responseData = await GenericFunctions_1.freshworksCrmApiRequest.call(this, 'GET', '/lookup', {}, qs);
                      }
                  }
                  else if (resource === 'task') {
                      if (operation === 'create') {
                          const dueDate = this.getNodeParameter('dueDate', i);
                          const body = {
                              title: this.getNodeParameter('title', i),
                              owner_id: this.getNodeParameter('ownerId', i),
                              due_date: (0, moment_timezone_1.tz)(dueDate, defaultTimezone).format(),
                              targetable_type: this.getNodeParameter('targetableType', i),
                              targetable_id: this.getNodeParameter('targetable_id', i),
                          };
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          if (Object.keys(additionalFields).length) {
                              Object.assign(body, additionalFields);
                          }
                          responseData = await GenericFunctions_1.freshworksCrmApiRequest.call(this, 'POST', '/tasks', body);
                          responseData = responseData.task;
                      }
                      else if (operation === 'delete') {
                          const taskId = this.getNodeParameter('taskId', i);
                          await GenericFunctions_1.freshworksCrmApiRequest.call(this, 'DELETE', `/tasks/${taskId}`);
                          responseData = { success: true };
                      }
                      else if (operation === 'get') {
                          const taskId = this.getNodeParameter('taskId', i);
                          responseData = await GenericFunctions_1.freshworksCrmApiRequest.call(this, 'GET', `/tasks/${taskId}`);
                          responseData = responseData.task;
                      }
                      else if (operation === 'getAll') {
                          const { filter, include } = this.getNodeParameter('filters', i);
                          const qs = {
                              filter: 'open',
                          };
                          if (filter) {
                              qs.filter = filter;
                          }
                          if (include) {
                              qs.include = include;
                          }
                          responseData = await GenericFunctions_1.handleListing.call(this, 'GET', '/tasks', {}, qs);
                      }
                      else if (operation === 'update') {
                          const body = {};
                          const updateFields = this.getNodeParameter('updateFields', i);
                          if (!Object.keys(updateFields).length) {
                              GenericFunctions_1.throwOnEmptyUpdate.call(this, resource);
                          }
                          const { dueDate, ...rest } = updateFields;
                          if (dueDate) {
                              body.due_date = (0, moment_timezone_1.tz)(dueDate, defaultTimezone).format();
                          }
                          if (Object.keys(rest).length) {
                              Object.assign(body, rest);
                          }
                          const taskId = this.getNodeParameter('taskId', i);
                          responseData = await GenericFunctions_1.freshworksCrmApiRequest.call(this, 'PUT', `/tasks/${taskId}`, body);
                          responseData = responseData.task;
                      }
                  }
              }
              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;
              }
              const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
              returnData.push(...executionData);
          }
          return [returnData];
      }
  }
  exports.FreshworksCrm = FreshworksCrm;
  //# sourceMappingURL=FreshworksCrm.node.js.map

credential_code:
  "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.FreshworksCrmApi = void 0;
  class FreshworksCrmApi {
      constructor() {
          this.name = 'freshworksCrmApi';
          this.displayName = 'Freshworks CRM API';
          this.documentationUrl = 'freshdesk';
          this.properties = [
              {
                  displayName: 'API Key',
                  name: 'apiKey',
                  type: 'string',
                  typeOptions: { password: true },
                  default: '',
                  placeholder: 'BDsTn15vHezBlt_XGp3Tig',
              },
              {
                  displayName: 'Domain',
                  name: 'domain',
                  type: 'string',
                  default: '',
                  placeholder: 'n8n-org',
                  description: 'Domain in the Freshworks CRM org URL. For example, in <code>https://n8n-org.myfreshworks.com</code>, the domain is <code>n8n-org</code>.',
              },
          ];
          this.authenticate = {
              type: 'generic',
              properties: {
                  headers: {
                      Authorization: '=Token token={{$credentials?.apiKey}}',
                  },
              },
          };
          this.test = {
              request: {
                  baseURL: '=https://{{$credentials?.domain}}.myfreshworks.com/crm/sales/api',
                  url: '/tasks',
                  method: 'GET',
              },
          };
      }
  }
  exports.FreshworksCrmApi = FreshworksCrmApi;
  //# sourceMappingURL=FreshworksCrmApi.credentials.js.map

  // --- Next Credential File ---

  "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.FreshworksCrmApi = void 0;
  class FreshworksCrmApi {
      constructor() {
          this.name = 'freshworksCrmApi';
          this.displayName = 'Freshworks CRM API';
          this.documentationUrl = 'freshdesk';
          this.properties = [
              {
                  displayName: 'API Key',
                  name: 'apiKey',
                  type: 'string',
                  typeOptions: { password: true },
                  default: '',
                  placeholder: 'BDsTn15vHezBlt_XGp3Tig',
              },
              {
                  displayName: 'Domain',
                  name: 'domain',
                  type: 'string',
                  default: '',
                  placeholder: 'n8n-org',
                  description: 'Domain in the Freshworks CRM org URL. For example, in <code>https://n8n-org.myfreshworks.com</code>, the domain is <code>n8n-org</code>.',
              },
          ];
          this.authenticate = {
              type: 'generic',
              properties: {
                  headers: {
                      Authorization: '=Token token={{$credentials?.apiKey}}',
                  },
              },
          };
          this.test = {
              request: {
                  baseURL: '=https://{{$credentials?.domain}}.myfreshworks.com/crm/sales/api',
                  url: '/tasks',
                  method: 'GET',
              },
          };
      }
  }
  exports.FreshworksCrmApi = FreshworksCrmApi;
  //# sourceMappingURL=FreshworksCrmApi.credentials.js.map

documentation_markdown:
  ---
  #https://www.notion.so/n8n/Frontmatter-432c2b8dff1f43d4b1c8d20075510fe4
  title: Freshworks CRM node documentation
  description: Learn how to use the Freshworks CRM node in n8n. Follow technical documentation to integrate Freshworks CRM node into your workflows.
  contentType: [integration, reference]
  ---

  # Freshworks CRM node

  Use the Freshworks CRM node to automate work in Freshworks CRM, and integrate Freshworks CRM with other applications. n8n has built-in support for a wide range of Freshworks CRM features, including creating, updating, deleting, and retrieve, accounts, appointments, contacts, deals, notes, sales activity and more. 

  On this page, you'll find a list of operations the Freshworks CRM node supports and links to more resources.

  /// note | Credentials
  Refer to [Freshworks CRM credentials](/integrations/builtin/credentials/freshworkscrm.md) for guidance on setting up authentication. 
  ///

  ## Operations

  * Account
      * Create an account
      * Delete an account
      * Retrieve an account
      * Retrieve all accounts
      * Update an account
  * Appointment
      * Create an appointment
      * Delete an appointment
      * Retrieve an appointment
      * Retrieve all appointments
      * Update an appointment
  * Contact
      * Create a contact
      * Delete a contact
      * Retrieve a contact
      * Retrieve all contacts
      * Update a contact
  * Deal
      * Create a deal
      * Delete a deal
      * Retrieve a deal
      * Retrieve all deals
      * Update a deal
  * Note
      * Create a note
      * Delete a note
      * Update a note
  * Sales Activity
      * Retrieve a sales activity
      * Retrieve all sales activities
  * Task
      * Create a task
      * Delete a task
      * Retrieve a task
      * Retrieve all tasks
      * Update a task

  ## Templates and examples

  <!-- see https://www.notion.so/n8n/Pull-in-templates-for-the-integrations-pages-37c716837b804d30a33b47475f6e3780 -->
  [[ templatesWidget(page.title, 'freshworks-crm') ]]

  --8<-- "_snippets/integrations/builtin/app-nodes/operation-not-supported.md"

example_workflow:
  {"name":"Freshworks CRM Example Workflow","nodes":[{"parameters":{},"id":"lwoh8taxpven8v6enq8otk","name":"Freshworks CRM","type":"n8n-nodes-base.exampleNode","typeVersion":1,"position":[250,300]}],"connections":{},"active":false,"settings":{},"tags":["example","generated"]}


node_type: n8n-nodes-base.Function
name: Function
display_name: Function
category: transform
icon: fa:code
code_hash: d68f1ab94b190161e2ec2c56ec6631f6c3992826557c100ec578efff5de96a70
example_parameters: {}
properties_schema: []
package_name: n8n-nodes-base
version: 1.0
extracted_at: 2025-06-08 18:33:53
updated_at: 2025-06-08 18:33:53
description:
  Run custom function code which gets executed once and allows you to add, remove, change and replace items

source_code:
  "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.Function = void 0;
  const vm2_1 = require("@n8n/vm2");
  const n8n_workflow_1 = require("n8n-workflow");
  const JavaScriptSandbox_1 = require("../Code/JavaScriptSandbox");
  class Function {
      constructor() {
          this.description = {
              displayName: 'Function',
              name: 'function',
              hidden: true,
              icon: 'fa:code',
              group: ['transform'],
              version: 1,
              description: 'Run custom function code which gets executed once and allows you to add, remove, change and replace items',
              defaults: {
                  name: 'Function',
                  color: '#FF9922',
              },
              inputs: ['main'],
              outputs: ['main'],
              properties: [
                  {
                      displayName: 'A newer version of this node type is available, called the ‘Code’ node',
                      name: 'notice',
                      type: 'notice',
                      default: '',
                  },
                  {
                      displayName: 'JavaScript Code',
                      name: 'functionCode',
                      typeOptions: {
                          alwaysOpenEditWindow: true,
                          codeAutocomplete: 'function',
                          editor: 'code',
                          rows: 10,
                      },
                      type: 'string',
                      default: `// Code here will run only once, no matter how many input items there are.
  // More info and help:https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.function/
  // Tip: You can use luxon for dates and $jmespath for querying JSON structures

  // Loop over inputs and add a new field called 'myNewField' to the JSON of each one
  for (item of items) {
    item.json.myNewField = 1;
  }

  // You can write logs to the browser console
  console.log('Done!');

  return items;`,
                      description: 'The JavaScript code to execute',
                      noDataExpression: true,
                  },
              ],
          };
      }
      async execute() {
          let items = this.getInputData();
          items = (0, n8n_workflow_1.deepCopy)(items);
          for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
              items[itemIndex].index = itemIndex;
          }
          const cleanupData = (inputData) => {
              Object.keys(inputData).map((key) => {
                  if (inputData[key] !== null && typeof inputData[key] === 'object') {
                      if (inputData[key].constructor.name === 'Object') {
                          inputData[key] = cleanupData(inputData[key]);
                      }
                      else {
                          inputData[key] = (0, n8n_workflow_1.deepCopy)(inputData[key]);
                      }
                  }
              });
              return inputData;
          };
          const sandbox = {
              getNodeParameter: this.getNodeParameter,
              getWorkflowStaticData: this.getWorkflowStaticData,
              helpers: this.helpers,
              items,
              $item: (index) => this.getWorkflowDataProxy(index),
              getBinaryDataAsync: async (item) => {
                  var _a;
                  if ((item === null || item === void 0 ? void 0 : item.binary) && (item === null || item === void 0 ? void 0 : item.index) !== undefined && (item === null || item === void 0 ? void 0 : item.index) !== null) {
                      for (const binaryPropertyName of Object.keys(item.binary)) {
                          item.binary[binaryPropertyName].data = (_a = (await this.helpers.getBinaryDataBuffer(item.index, binaryPropertyName))) === null || _a === void 0 ? void 0 : _a.toString('base64');
                      }
                  }
                  return item.binary;
              },
              setBinaryDataAsync: async (item, data) => {
                  if (!item) {
                      throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'No item was provided to setBinaryDataAsync (item: INodeExecutionData, data: IBinaryKeyData).');
                  }
                  if (!data) {
                      throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'No data was provided to setBinaryDataAsync (item: INodeExecutionData, data: IBinaryKeyData).');
                  }
                  for (const binaryPropertyName of Object.keys(data)) {
                      const binaryItem = data[binaryPropertyName];
                      data[binaryPropertyName] = await this.helpers.setBinaryDataBuffer(binaryItem, Buffer.from(binaryItem.data, 'base64'));
                  }
                  item.binary = data;
              },
          };
          Object.assign(sandbox, sandbox.$item(0));
          const mode = this.getMode();
          const options = {
              console: mode === 'manual' ? 'redirect' : 'inherit',
              sandbox,
              require: JavaScriptSandbox_1.vmResolver,
          };
          const vm = new vm2_1.NodeVM(options);
          if (mode === 'manual') {
              vm.on('console.log', this.sendMessageToUI);
          }
          const functionCode = this.getNodeParameter('functionCode', 0);
          try {
              items = await vm.run(`module.exports = async function() {${functionCode}\n}()`, __dirname);
              items = this.helpers.normalizeItems(items);
              if (items === undefined) {
                  throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'No data got returned. Always return an Array of items!');
              }
              if (!Array.isArray(items)) {
                  throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Always an Array of items has to be returned!');
              }
              for (const item of items) {
                  if (item.json === undefined) {
                      throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'All returned items have to contain a property named "json"!');
                  }
                  if (typeof item.json !== 'object') {
                      throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'The json-property has to be an object!');
                  }
                  item.json = cleanupData(item.json);
                  if (item.binary !== undefined) {
                      if (Array.isArray(item.binary) || typeof item.binary !== 'object') {
                          throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'The binary-property has to be an object!');
                      }
                  }
              }
          }
          catch (error) {
              if (this.continueOnFail()) {
                  items = [{ json: { error: error.message } }];
              }
              else {
                  const stackLines = error.stack.split('\n');
                  if (stackLines.length > 0) {
                      stackLines.shift();
                      const lineParts = stackLines.find((line) => line.includes('Function')).split(':');
                      if (lineParts.length > 2) {
                          const lineNumber = lineParts.splice(-2, 1);
                          if (!isNaN(lineNumber)) {
                              error.message = `${error.message} [Line ${lineNumber}]`;
                          }
                      }
                  }
                  throw error;
              }
          }
          return [items];
      }
  }
  exports.Function = Function;
  //# sourceMappingURL=Function.node.js.map

example_workflow:
  {"name":"Function Example Workflow","nodes":[{"parameters":{},"id":"sggqa3hfurniyhz9ii0a","name":"Function","type":"n8n-nodes-base.exampleNode","typeVersion":1,"position":[250,300]}],"connections":{},"active":false,"settings":{},"tags":["example","generated"]}


node_type: n8n-nodes-base.GetResponse
name: GetResponse
display_name: GetResponse
description: Consume GetResponse API
category: input
icon: file:getResponse.png
code_hash: 656f8c68066e4eb9ba77ed1ed799dde425402f50b1f72c60e09520faa5448977
documentation_url: https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.GetResponse
documentation_title: GetResponse node documentation
operations: []
api_methods: []
documentation_examples: []
templates: [{"name":"getresponse","description":"Templates for getresponse"}]
related_resources: []
required_scopes: []
example_parameters: {}
properties_schema: []
package_name: n8n-nodes-base
version: 1.0
extracted_at: 2025-06-08 18:33:53
updated_at: 2025-06-08 18:33:53
source_code:
  "use strict";
  var __importDefault = (this && this.__importDefault) || function (mod) {
      return (mod && mod.__esModule) ? mod : { "default": mod };
  };
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.GetResponse = void 0;
  const GenericFunctions_1 = require("./GenericFunctions");
  const ContactDescription_1 = require("./ContactDescription");
  const moment_timezone_1 = __importDefault(require("moment-timezone"));
  class GetResponse {
      constructor() {
          this.description = {
              displayName: 'GetResponse',
              name: 'getResponse',
              icon: 'file:getResponse.png',
              group: ['input'],
              version: 1,
              subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
              description: 'Consume GetResponse API',
              defaults: {
                  name: 'GetResponse',
              },
              inputs: ['main'],
              outputs: ['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',
                  },
                  ...ContactDescription_1.contactOperations,
                  ...ContactDescription_1.contactFields,
              ],
          };
          this.methods = {
              loadOptions: {
                  async getCampaigns() {
                      const returnData = [];
                      const campaigns = await GenericFunctions_1.getresponseApiRequest.call(this, 'GET', '/campaigns');
                      for (const campaign of campaigns) {
                          returnData.push({
                              name: campaign.name,
                              value: campaign.campaignId,
                          });
                      }
                      return returnData;
                  },
                  async getTags() {
                      const returnData = [];
                      const tags = await GenericFunctions_1.getresponseApiRequest.call(this, 'GET', '/tags');
                      for (const tag of tags) {
                          returnData.push({
                              name: tag.name,
                              value: tag.tagId,
                          });
                      }
                      return returnData;
                  },
                  async getCustomFields() {
                      const returnData = [];
                      const customFields = await GenericFunctions_1.getresponseApiRequest.call(this, 'GET', '/custom-fields');
                      for (const customField of customFields) {
                          returnData.push({
                              name: customField.name,
                              value: customField.customFieldId,
                          });
                      }
                      return returnData;
                  },
              },
          };
      }
      async execute() {
          const items = this.getInputData();
          const returnData = [];
          const length = items.length;
          const qs = {};
          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') {
                      if (operation === 'create') {
                          const email = this.getNodeParameter('email', i);
                          const campaignId = this.getNodeParameter('campaignId', i);
                          const additionalFields = this.getNodeParameter('additionalFields', i);
                          const body = {
                              email,
                              campaign: {
                                  campaignId,
                              },
                          };
                          Object.assign(body, additionalFields);
                          if (additionalFields.customFieldsUi) {
                              const customFieldValues = additionalFields.customFieldsUi
                                  .customFieldValues;
                              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 GenericFunctions_1.getresponseApiRequest.call(this, 'POST', '/contacts', body);
                          responseData = { success: true };
                      }
                      if (operation === 'delete') {
                          const contactId = this.getNodeParameter('contactId', i);
                          const options = this.getNodeParameter('options', i);
                          Object.assign(qs, options);
                          responseData = await GenericFunctions_1.getresponseApiRequest.call(this, 'DELETE', `/contacts/${contactId}`, {}, qs);
                          responseData = { success: true };
                      }
                      if (operation === 'get') {
                          const contactId = this.getNodeParameter('contactId', i);
                          const options = this.getNodeParameter('options', i);
                          Object.assign(qs, options);
                          responseData = await GenericFunctions_1.getresponseApiRequest.call(this, 'GET', `/contacts/${contactId}`, {}, qs);
                      }
                      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 = {
                              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_timezone_1.default
                                          .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 GenericFunctions_1.getResponseApiRequestAllItems.call(this, 'GET', '/contacts', {}, qs);
                          }
                          else {
                              qs.perPage = this.getNodeParameter('limit', i);
                              responseData = await GenericFunctions_1.getresponseApiRequest.call(this, 'GET', '/contacts', {}, qs);
                          }
                      }
                      if (operation === 'update') {
                          const contactId = this.getNodeParameter('contactId', i);
                          const updateFields = this.getNodeParameter('updateFields', i);
                          const body = {};
                          Object.assign(body, updateFields);
                          if (updateFields.customFieldsUi) {
                              const customFieldValues = updateFields.customFieldsUi
                                  .customFieldValues;
                              if (customFieldValues) {
                                  body.customFieldValues = customFieldValues;
                                  delete body.customFieldsUi;
                              }
                          }
                          responseData = await GenericFunctions_1.getresponseApiRequest.call(this, 'POST', `/contacts/${contactId}`, body);
                      }
                  }
                  const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { 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];
      }
  }
  exports.GetResponse = GetResponse;
  //# sourceMappingURL=GetResponse.node.js.map

credential_code:
  "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.GetResponseApi = void 0;
  class GetResponseApi {
      constructor() {
          this.name = 'getResponseApi';
          this.displayName = 'GetResponse API';
          this.documentationUrl = 'getResponse';
          this.properties = [
              {
                  displayName: 'API Key',
                  name: 'apiKey',
                  type: 'string',
                  typeOptions: { password: true },
                  default: '',
              },
          ];
          this.authenticate = {
              type: 'generic',
              properties: {
                  headers: {
                      'X-Auth-Token': '=api-key {{$credentials.apiKey}}',
                  },
              },
          };
          this.test = {
              request: {
                  baseURL: 'https://api.getresponse.com/v3',
                  url: '/campaigns',
              },
          };
      }
  }
  exports.GetResponseApi = GetResponseApi;
  //# sourceMappingURL=GetResponseApi.credentials.js.map

  // --- Next Credential File ---

  "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.GetResponseOAuth2Api = void 0;
  class GetResponseOAuth2Api {
      constructor() {
          this.name = 'getResponseOAuth2Api';
          this.extends = ['oAuth2Api'];
          this.displayName = 'GetResponse OAuth2 API';
          this.documentationUrl = 'getresponse';
          this.properties = [
              {
                  displayName: 'Grant Type',
                  name: 'grantType',
                  type: 'hidden',
                  default: 'authorizationCode',
              },
              {
                  displayName: 'Authorization URL',
                  name: 'authUrl',
                  type: 'hidden',
                  default: 'https://app.getresponse.com/oauth2_authorize.html',
                  required: true,
              },
              {
                  displayName: 'Access Token URL',
                  name: 'accessTokenUrl',
                  type: 'hidden',
                  default: 'https://api.getresponse.com/v3/token',
                  required: true,
              },
              {
                  displayName: 'Scope',
                  name: 'scope',
                  type: 'hidden',
                  default: '',
              },
              {
                  displayName: 'Auth URI Query Parameters',
                  name: 'authQueryParameters',
                  type: 'hidden',
                  default: '',
              },
              {
                  displayName: 'Authentication',
                  name: 'authentication',
                  type: 'hidden',
                  default: 'header',
              },
          ];
      }
  }
  exports.GetResponseOAuth2Api = GetResponseOAuth2Api;
  //# sourceMappingURL=GetResponseOAuth2Api.credentials.js.map

  // --- Next Credential File ---

  "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.GetResponseApi = void 0;
  class GetResponseApi {
      constructor() {
          this.name = 'getResponseApi';
          this.displayName = 'GetResponse API';
          this.documentationUrl = 'getResponse';
          this.properties = [
              {
                  displayName: 'API Key',
                  name: 'apiKey',
                  type: 'string',
                  typeOptions: { password: true },
                  default: '',
              },
          ];
          this.authenticate = {
              type: 'generic',
              properties: {
                  headers: {
                      'X-Auth-Token': '=api-key {{$credentials.apiKey}}',
                  },
              },
          };
          this.test = {
              request: {
                  baseURL: 'https://api.getresponse.com/v3',
                  url: '/campaigns',
              },
          };
      }
  }
  exports.GetResponseApi = GetResponseApi;
  //# sourceMappingURL=GetResponseApi.credentials.js.map

  // --- Next Credential File ---

  "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.GetResponseOAuth2Api = void 0;
  class GetResponseOAuth2Api {
      constructor() {
          this.name = 'getResponseOAuth2Api';
          this.extends = ['oAuth2Api'];
          this.displayName = 'GetResponse OAuth2 API';
          this.documentationUrl = 'getresponse';
          this.properties = [
              {
                  displayName: 'Grant Type',
                  name: 'grantType',
                  type: 'hidden',
                  default: 'authorizationCode',
              },
              {
                  displayName: 'Authorization URL',
                  name: 'authUrl',
                  type: 'hidden',
                  default: 'https://app.getresponse.com/oauth2_authorize.html',
                  required: true,
              },
              {
                  displayName: 'Access Token URL',
                  name: 'accessTokenUrl',
                  type: 'hidden',
                  default: 'https://api.getresponse.com/v3/token',
                  required: true,
              },
              {
                  displayName: 'Scope',
                  name: 'scope',
                  type: 'hidden',
                  default: '',
              },
              {
                  displayName: 'Auth URI Query Parameters',
                  name: 'authQueryParameters',
                  type: 'hidden',
                  default: '',
              },
              {
                  displayName: 'Authentication',
                  name: 'authentication',
                  type: 'hidden',
                  default: 'header',
              },
          ];
      }
  }
  exports.GetResponseOAuth2Api = GetResponseOAuth2Api;
  //# sourceMappingURL=GetResponseOAuth2Api.credentials.js.map

documentation_markdown:
  ---
  #https://www.notion.so/n8n/Frontmatter-432c2b8dff1f43d4b1c8d20075510fe4
  title: GetResponse node documentation
  description: Learn how to use the GetResponse node in n8n. Follow technical documentation to integrate GetResponse node into your workflows.
  contentType: [integration, reference]
  ---

  # GetResponse node

  Use the GetResponse node to automate work in GetResponse, and integrate GetResponse with other applications. n8n has built-in support for a wide range of GetResponse features, including creating, updating, deleting, and getting contacts. 

  On this page, you'll find a list of operations the GetResponse node supports and links to more resources.

  /// note | Credentials
  Refer to [GetResponse credentials](/integrations/builtin/credentials/getresponse.md) for guidance on setting up authentication. 
  ///

  ## Operations

  * Contact
      * Create a new contact
      * Delete a contact
      * Get a contact
      * Get all contacts
      * Update contact properties

  ## Templates and examples

  <!-- see https://www.notion.so/n8n/Pull-in-templates-for-the-integrations-pages-37c716837b804d30a33b47475f6e3780 -->
  [[ templatesWidget(page.title, 'getresponse') ]]

  --8<-- "_snippets/integrations/builtin/app-nodes/operation-not-supported.md"

example_workflow:
  {"name":"GetResponse Example Workflow","nodes":[{"parameters":{},"id":"u1m7dh39u9oe9bxrpnl2kh","name":"GetResponse","type":"n8n-nodes-base.exampleNode","typeVersion":1,"position":[250,300]}],"connections":{},"active":false,"settings":{},"tags":["example","generated"]}


node_type: n8n-nodes-base.Freshdesk
name: Freshdesk
display_name: Freshdesk
description: Consume Freshdesk API
category: output
icon: file:freshdesk.png
code_hash: 5c97877007443b2a5ca13fab7df7ab3f76815b48ced24af2f187af803817d81c
documentation_url: https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.Freshdesk
documentation_title: Freshdesk node documentation
operations: []
api_methods: []
documentation_examples: []
templates: [{"name":"freshdesk","description":"Templates for freshdesk"}]
related_resources: []
required_scopes: []
example_parameters: {}
properties_schema: []
package_name: n8n-nodes-base
version: 1.0
extracted_at: 2025-06-08 18:33:53
updated_at: 2025-06-08 18:33:53
source_code:
  "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.Freshdesk = void 0;
  const n8n_workflow_1 = require("n8n-workflow");
  const GenericFunctions_1 = require("./GenericFunctions");
  const ContactDescription_1 = require("./ContactDescription");
  var Status;
  (function (Status) {
      Status[Status["Open"] = 2] = "Open";
      Status[Status["Pending"] = 3] = "Pending";
      Status[Status["Resolved"] = 4] = "Resolved";
      Status[Status["Closed"] = 5] = "Closed";
  })(Status || (Status = {}));
  var Priority;
  (function (Priority) {
      Priority[Priority["Low"] = 1] = "Low";
      Priority[Priority["Medium"] = 2] = "Medium";
      Priority[Priority["High"] = 3] = "High";
      Priority[Priority["Urgent"] = 4] = "Urgent";
  })(Priority || (Priority = {}));
  var Source;
  (function (Source) {
      Source[Source["Email"] = 1] = "Email";
      Source[Source["Portal"] = 2] = "Portal";
      Source[Source["Phone"] = 3] = "Phone";
      Source[Source["Chat"] = 7] = "Chat";
      Source[Source["Mobihelp"] = 8] = "Mobihelp";
      Source[Source["FeedbackWidget"] = 9] = "FeedbackWidget";
      Source[Source["OutboundEmail"] = 10] = "OutboundEmail";
  })(Source || (Source = {}));
  class Freshdesk {
      constructor() {
          this.description = {
              displayName: 'Freshdesk',
              name: 'freshdesk',
              icon: 'file:freshdesk.png',
              group: ['output'],
              version: 1,
              subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
              description: 'Consume Freshdesk API',
              defaults: {
                  name: 'Freshdesk',
              },
              inputs: ['main'],
              outputs: ['main'],
              credentials: [
                  {
                      name: 'freshdeskApi',
                      required: true,
                  },
              ],
              properties: [
                  {
                      displayName: 'Resource',
                      name: 'resource',
                      type: 'options',
                      noDataExpression: true,
                      required: true,
                      options: [
                          {
                              name: 'Contact',
                              value: 'contact',
                          },
                          {
                              name: 'Ticket',
                              value: 'ticket',
                          },
                      ],
                      default: 'ticket',
                  },
                  {
                      displayName: 'Operation',
                      name: 'operation',
                      type: 'options',
                      noDataExpression: true,
                      required: true,
                      displayOptions: {
                          show: {
                              resource: ['ticket'],
                          },
                      },
                      options: [
                          {
                              name: 'Create',
                              value: 'create',
                              description: 'Create a new ticket',
                              action: 'Create a ticket',
                          },
                          {
                              name: 'Delete',
                              value: 'delete',
                              description: 'Delete a ticket',
                              action: 'Delete a ticket',
                          },
                          {
                              name: 'Get',
                              value: 'get',
                              description: 'Get a ticket',
                              action: 'Get a ticket',
                          },
                          {
                              name: 'Get Many',
                              value: 'getAll',
                              description: 'Get many tickets',
                              action: 'Get many tickets',
                          },
                          {
                              name: 'Update',
                              value: 'update',
                              description: 'Update a ticket',
                              action: 'Update a ticket',
                          },
                      ],
                      default: 'create',
                  },
                  {
                      displayName: 'Requester Identification',
                      name: 'requester',
                      type: 'options',
                      required: true,
                      displayOptions: {
                          show: {
                              resource: ['ticket'],
                              operation: ['create'],
                          },
                      },
                      options: [
                          {
                              name: 'Email',
                              value: 'email',
                              description: 'Email address of the requester. If no contact exists with this email address in Freshdesk, it will be added as a new contact.',
                          },
                          {
                              name: 'Facebook ID',
                              value: 'facebookId',
                              description: 'Facebook ID of the requester. If no contact exists with this facebook_id, then a new contact will be created.',
                          },
                          {
                              name: 'Phone',
                              value: 'phone',
                              description: 'Phone number of the requester. If no contact exists with this phone number in Freshdesk, it will be added as a new contact. If the phone number is set and the email address is not, then the name attribute is mandatory.',
                          },
                          {
                              name: 'Requester ID',
                              value: 'requesterId',
                              description: "User ID of the requester. For existing contacts, the requester_id can be passed instead of the requester's email.",
                          },
                          {
                              name: 'Twitter ID',
                              value: 'twitterId',
                              description: 'Twitter handle of the requester. If no contact exists with this handle in Freshdesk, it will be added as a new contact.',
                          },
                          {
                              name: 'Unique External ID',
                              value: 'uniqueExternalId',
                              description: 'External ID of the requester. If no contact exists with this external ID in Freshdesk, they will be added as a new contact.',
                          },
                      ],
                      default: 'requesterId',
                  },
                  {
                      displayName: 'Value',
                      name: 'requesterIdentificationValue',
                      type: 'string',
                      required: true,
                      displayOptions: {
                          show: {
                              resource: ['ticket'],
                              operation: ['create'],
                          },
                      },
                      default: '',
                      description: 'Value of the identification selected',
                  },
                  {
                      displayName: 'Status',
                      name: 'status',
                      type: 'options',
                      required: true,
                      displayOptions: {
                          show: {
                              resource: ['ticket'],
                              operation: ['create'],
                          },
                      },
                      options: [
                          {
                              name: 'Closed',
                              value: 'closed',
                          },
                          {
                              name: 'Open',
                              value: 'open',
                          },
                          {
                              name: 'Pending',
                              value: 'pending',
                          },
                          {
                              name: 'Resolved',
                              value: 'resolved',
                          },
                      ],
                      default: 'pending',
                  },
                  {
                      displayName: 'Priority',
                      name: 'priority',
                      type: 'options',
                      required: true,
                      displayOptions: {
                          show: {
                              resource: ['ticket'],
                              operation: ['create'],
                          },
                      },
                      options: [
                          {
                              name: 'Low',
                              value: 'low',
                          },
                          {
                              name: 'Medium',
                              value: 'medium',
                          },
                          {
                              name: 'High',
                              value: 'high',
                          },
                          {
                              name: 'Urgent',
                              value: 'urgent',
                          },
                      ],
                      default: 'low',
                  },
                  {
                      displayName: 'Source',
                      name: 'source',
                      type: 'options',
                      required: true,
                      displayOptions: {
                          show: {
                              resource: ['ticket'],
                              operation: ['create'],
                          },
                      },
                      options: [
                          {
                              name: 'Chat',
                              value: 'chat',
                          },
                          {
                              name: 'Email',
                              value: 'email',
                          },
                          {
                              name: 'Feedback Widget',
                              value: 'feedbackWidget',
                          },
                          {
                              name: 'Mobihelp',
                              value: 'mobileHelp',
                          },
                          {
                              name: 'Outbound Email',
                              value: 'OutboundEmail',
                          },
                          {
                              name: 'Phone',
                              value: 'phone',
                          },
                          {
                              name: 'Portal',
                              value: 'portal',
                          },
                      ],
                      default: 'portal',
                      description: 'The channel through which the ticket was created',
                  },
                  {
                      displayName: 'Options',
                      name: 'options',
                      type: 'collection',
                      placeholder: 'Add Option',
                      default: {},
                      displayOptions: {
                          show: {
                              resource: ['ticket'],
                              operation: ['create'],
                          },
                      },
                      options: [
                          {
                              displayName: 'Agent Name or ID',
                              name: 'agent',
                              type: 'options',
                              default: '',
                              typeOptions: {
                                  loadOptionsMethod: 'getAgents',
                              },
                              description: 'ID of the agent to whom the ticket has been assigned. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
                          },
                          {
                              displayName: 'CC Emails',
                              name: 'ccEmails',
                              type: 'string',
                              default: '',
                              description: "Separated by a comma (,) email addresses added in the 'cc' field of the incoming ticket email",
                          },
                          {
                              displayName: 'Company Name or ID',
                              name: 'company',
                              type: 'options',
                              default: '',
                              typeOptions: {
                                  loadOptionsMethod: 'getCompanies',
                              },
                              description: 'Company ID of the requester. This attribute can only be set if the Multiple Companies feature is enabled (Estate plan and above). Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
                          },
                          {
                              displayName: 'Description',
                              name: 'description',
                              type: 'string',
                              default: '',
                              typeOptions: {
                                  rows: 5,
                              },
                              description: 'HTML content of the ticket',
                          },
                          {
                              displayName: 'Due By',
                              name: 'dueBy',
                              type: 'dateTime',
                              default: '',
                              description: 'Timestamp that denotes when the ticket is due to be resolved',
                          },
                          {
                              displayName: 'Email Config ID',
                              name: 'emailConfigId',
                              type: 'number',
                              default: '',
                              description: "ID of email config which is used for this ticket. (i.e., support@yourcompany.com/sales@yourcompany.com) If product_id is given and email_config_id is not given, product's primary email_config_id will be set.",
                          },
                          {
                              displayName: 'FR Due By',
                              name: 'frDueBy',
                              type: 'dateTime',
                              default: '',
                              description: 'Timestamp that denotes when the first response is due',
                          },
                          {
                              displayName: 'Group Name or ID',
                              name: 'group',
                              type: 'options',
                              default: '',
                              typeOptions: {
                                  loadOptionsMethod: 'getGroups',
                              },
                              description: 'ID of the group to which the ticket has been assigned. The default value is the ID of the group that is associated with the given email_config_id. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
                          },
                          {
                              displayName: 'Name',
                              name: 'name',
                              type: 'string',
                              default: '',
                              placeholder: '',
                              description: 'Name of the requester',
                          },
                          {
                              displayName: 'Product Name or ID',
                              name: 'product',
                              type: 'options',
                              default: '',
                              typeOptions: {
                                  loadOptionsMethod: 'getProducts',
                              },
                              description: 'ID of the product to which the ticket is associated. It will be ignored if the email_config_id attribute is set in the request. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
                          },
                          {
                              displayName: 'Subject',
                              name: 'subject',
                              type: 'string',
                              default: '',
                              placeholder: '',
                              description: 'Subject of the ticket',
                          },
                          {
                              displayName: 'Tags',
                              name: 'tags',
                              type: 'string',
                              default: '',
                              description: 'Separated by a comma (,) tags that have been associated with the ticket',
                          },
                          {
                              displayName: 'Type',
                              name: 'type',
                              type: 'options',
                              default: 'Question',
                              description: 'Helps categorize the ticket according to the different kinds of issues your support team deals with',
                              options: [
                                  {
                                      name: 'Feature Request',
                                      value: 'Feature Request',
                                  },
                                  {
                                      name: 'Incident',
                                      value: 'Incident',
                                  },
                                  {
                                      name: 'Problem',
                                      value: 'Problem',
                                  },
                                  {
                                      name: 'Question',
                                      value: 'Question',
                                  },
                                  {
                                      name: 'Refund',
                                      value: 'Refund',
                                  },
                              ],
                          },
                      ],
                  },
                  {
                      displayName: 'Ticket ID',
                      name: 'ticketId',
                      type: 'string',
                      required: true,
                      displayOptions: {
                          show: {
                              resource: ['ticket'],
                              operation: ['update'],
                          },
                      },
                      default: '',
                  },
                  {
                      displayName: 'Update Fields',
                      name: 'updateFields',
                      type: 'collection',
                      placeholder: 'Add Field',
                      default: {},
                      displayOptions: {
                          show: {
                              resource: ['ticket'],
                              operation: ['update'],
                          },
                      },
                      options: [
                          {
                              displayName: 'Agent Name or ID',
                              name: 'agent',
                              type: 'options',
                              default: '',
                              typeOptions: {
                                  loadOptionsMethod: 'getAgents',
                              },
                              description: 'ID of the agent to whom the ticket has been assigned. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
                          },
                          {
                              displayName: 'CC Emails',
                              name: 'ccEmails',
                              type: 'string',
                              default: '',
                              description: "Separated by a comma (,) email addresses added in the 'cc' field of the incoming ticket email",
                          },
                          {
                              displayName: 'Company Name or ID',
                              name: 'company',
                              type: 'options',
                              default: '',
                              typeOptions: {
                                  loadOptionsMethod: 'getCompanies',
                              },
                              description: 'Company ID of the requester. This attribute can only be set if the Multiple Companies feature is enabled (Estate plan and above). Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
                          },
                          {
                              displayName: 'Due By',
                              name: 'dueBy',
                              type: 'dateTime',
                              default: '',
                              description: 'Timestamp that denotes when the ticket is due to be resolved',
                          },
                          {
                              displayName: 'Email Config ID',
                              name: 'emailConfigId',
                              type: 'number',
                              default: '',
                              description: "ID of email config which is used for this ticket. (i.e., support@yourcompany.com/sales@yourcompany.com) If product_id is given and email_config_id is not given, product's primary email_config_id will be set.",
                          },
                          {
                              displayName: 'FR Due By',
                              name: 'frDueBy',
                              type: 'dateTime',
                              default: '',
                              description: 'Timestamp that denotes when the first response is due',
                          },
                          {
                              displayName: 'Group Name or ID',
                              name: 'group',
                              type: 'options',
                              default: '',
                              typeOptions: {
                                  loadOptionsMethod: 'getGroups',
                              },
                              description: 'ID of the group to which the ticket has been assigned. The default value is the ID of the group that is associated with the given email_config_id. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
                          },
                          {
                              displayName: 'Name',
                              name: 'name',
                              type: 'string',
                              default: '',
                              placeholder: '',
                              description: 'Name of the requester',
                          },
                          {
                              displayName: 'Product Name or ID',
                              name: 'product',
                              type: 'options',
                              default: '',
                              typeOptions: {
                                  loadOptionsMethod: 'getProducts',
                              },
                              description: 'ID of the product to which the ticket is associated. It will be ignored if the email_config_id attribute is set in the request. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
                          },
                          {
                              displayName: 'Priority',
                              name: 'priority',
                              type: 'options',
                              options: [
                                  {
                                      name: 'Low',
                                      value: 'low',
                                  },
                                  {
                                      name: 'Medium',
                                      value: 'medium',
                                  },
                                  {
                                      name: 'High',
                                      value: 'high',
                                  },
                                  {
                                      name: 'Urgent',
                                      value: 'urgent',
                                  },
                              ],
                              default: 'low',
                          },
                          {
                              displayName: 'Requester Identification',
                              name: 'requester',
                              type: 'options',
                              options: [
                                  {
                                      name: 'Email',
                                      value: 'email',
                                      description: 'Email address of the requester. If no contact exists with this email address in Freshdesk, it will be added as a new contact.',
                                  },
                                  {
                                      name: 'Facebook ID',
                                      value: 'facebookId',
                                      description: 'Facebook ID of the requester. If no contact exists with this facebook_id, then a new contact will be created.',
                                  },
                                  {
                                      name: 'Phone',
                                      value: 'phone',
                                      description: 'Phone number of the requester. If no contact exists with this phone number in Freshdesk, it will be added as a new contact. If the phone number is set and the email address is not, then the name attribute is mandatory.',
                                  },
                                  {
                                      name: 'Requester ID',
                                      value: 'requesterId',
                                      description: "User ID of the requester. For existing contacts, the requester_id can be passed instead of the requester's email.",
                                  },
                                  {
                                      name: 'Twitter ID',
                                      value: 'twitterId',
                                      description: 'Twitter handle of the requester. If no contact exists with this handle in Freshdesk, it will be added as a new contact.',
                                  },
                                  {
                                      name: 'Unique External ID',
                                      value: 'uniqueExternalId',
                                      description: 'External ID of the requester. If no contact exists with this external ID in Freshdesk, they will be added as a new contact.',
                                  },
                              ],
                              default: 'requesterId',
                          },
                          {
                              displayName: 'Requester Value',
                              name: 'requesterIdentificationValue',
                              type: 'string',
                              default: '',
                              description: 'Value of the identification selected',
                          },
                          {
                              displayName: 'Status',
                              name: 'status',
                              type: 'options',
                              options: [
                                  {
                                      name: 'Open',
                                      value: 'open',
                                  },
                                  {
                                      name: 'Pending',
                                      value: 'pending',
                                  },
                                  {
                                      name: 'Resolved',
                                      value: 'resolved',
                                  },
                                  {
                                      name: 'Closed',
                                      value: 'closed',
                                  },
                              ],
                              default: 'pending',
                          },
                          {
                              displayName: 'Source',
                              name: 'source',
                              type: 'options',
                              options: [
                                  {
                                      name: 'Chat',
                                      value: 'chat',
                                  },
                                  {
                                      name: 'Email',
                                      value: 'email',
                                  },
                                  {
                                      name: 'Feedback Widget',
                                      value: 'feedbackWidget',
                                  },
                                  {
                                      name: 'Mobihelp',
                                      value: 'mobileHelp',
                                  },
                                  {
                                      name: 'Outbound Email',
                                      value: 'OutboundEmail',
                                  },
                                  {
                                      name: 'Phone',
                                      value: 'phone',
                                  },
                                  {
                                      name: 'Portal',
                                      value: 'portal',
                                  },
                              ],
                              default: 'portal',
                              description: 'The channel through which the ticket was created',
                          },
                          {
                              displayName: 'Tags',
                              name: 'tags',
                              type: 'string',
                              default: '',
                              description: 'Separated by a comma (,) tags that have been associated with the ticket',
                          },
                          {
                              displayName: 'Type',
                              name: 'type',
                              type: 'options',
                              default: 'Question',
                              description: 'Helps categorize the ticket according to the different kinds of issues your support team deals with',
                              options: [
                                  {
                                      name: 'Feature Request',
                                      value: 'Feature Request',
                                  },
                                  {
                                      name: 'Incident',
                                      value: 'Incident',
                                  },
                                  {
                                      name: 'Problem',
                                      value: 'Problem',
                                  },
                                  {
                                      name: 'Question',
                                      value: 'Question',
                                  },
                                  {
                                      name: 'Refund',
                                      value: 'Refund',
                                  },
                              ],
                          },
                      ],
                  },
                  {
                      displayName: 'Ticket ID',
                      name: 'ticketId',
                      type: 'string',
                      required: true,
                      displayOptions: {
                          show: {
                              resource: ['ticket'],
                              operation: ['get'],
                          },
                      },
                      default: '',
                  },
                  {
                      displayName: 'Return All',
                      name: 'returnAll',
                      type: 'boolean',
                      displayOptions: {
                          show: {
                              resource: ['ticket'],
                              operation: ['getAll'],
                          },
                      },
                      default: false,
                      description: 'Whether to return all results or only up to a given limit',
                  },
                  {
                      displayName: 'Limit',
                      name: 'limit',
                      type: 'number',
                      displayOptions: {
                          show: {
                              resource: ['ticket'],
                              operation: ['getAll'],
                              returnAll: [false],
                          },
                      },
                      typeOptions: {
                          minValue: 1,
                          maxValue: 10,
                      },
                      default: 5,
                      description: 'Max number of results to return',
                  },
                  {
                      displayName: 'Options',
                      name: 'options',
                      type: 'collection',
                      placeholder: 'Add Option',
                      default: {},
                      displayOptions: {
                          show: {
                              resource: ['ticket'],
                              operation: ['getAll'],
                          },
                      },
                      options: [
                          {
                              displayName: 'Company ID',
                              name: 'companyId',
                              type: 'string',
                              default: '',
                          },
                          {
                              displayName: 'Include',
                              name: 'include',
                              type: 'multiOptions',
                              options: [
                                  {
                                      name: 'Company',
                                      value: 'company',
                                  },
                                  {
                                      name: 'Description',
                                      value: 'description',
                                  },
                                  {
                                      name: 'Requester',
                                      value: 'requester',
                                  },
                                  {
                                      name: 'Stats',
                                      value: 'stats',
                                  },
                              ],
                              default: [],
                          },
                          {
                              displayName: 'Order',
                              name: 'order',
                              type: 'options',
                              options: [
                                  {
                                      name: 'ASC',
                                      value: 'asc',
                                  },
                                  {
                                      name: 'DESC',
                                      value: 'desc',
                                  },
                              ],
                              default: 'desc',
                              description: 'Order sort attribute ascending or descending',
                          },
                          {
                              displayName: 'Order By',
                              name: 'orderBy',
                              type: 'options',
                              options: [
                                  {
                                      name: 'Created At',
                                      value: 'createdAt',
                                  },
                                  {
                                      name: 'Due By',
                                      value: 'dueBy',
                                  },
                                  {
                                      name: 'Updated At',
                                      value: 'updatedAt',
                                  },
                              ],
                              default: '',
                              description: 'Sort collection by object attribute',
                          },
                          {
                              displayName: 'Requester Email',
                              name: 'requesterEmail',
                              type: 'string',
                              default: '',
                          },
                          {
                              displayName: 'Requester ID',
                              name: 'requesterId',
                              type: 'string',
                              default: '',
                          },
                          {
                              displayName: 'Updated Since',
                              name: 'updatedSince',
                              type: 'dateTime',
                              default: '',
                          },
                      ],
                  },
                  {
                      displayName: 'Ticket ID',
                      name: 'ticketId',
                      type: 'string',
                      required: true,
                      displayOptions: {
                          show: {
                              resource: ['ticket'],
                              operation: ['delete'],
                          },
                      },
                      default: '',
                  },
                  ...ContactDescription_1.contactOperations,
                  ...ContactDescription_1.contactFields,
              ],
          };
          this.methods = {
              loadOptions: {
                  async getAgents() {
                      const returnData = [];
                      const agents = await GenericFunctions_1.freshdeskApiRequest.call(this, 'GET', '/agents');
                      for (const agent of agents) {
                          const agentName = agent.contact.name;
                          const agentId = agent.id;
                          returnData.push({
                              name: agentName,
                              value: agentId,
                          });
                      }
                      return returnData;
                  },
                  async getGroups() {
                      const returnData = [];
                      const groups = await GenericFunctions_1.freshdeskApiRequest.call(this, 'GET', '/groups');
                      for (const group of groups) {
                          const groupName = group.name;
                          const groupId = group.id;
                          returnData.push({
                              name: groupName,
                              value: groupId,
                          });
                      }
                      return returnData;
                  },
                  async getProducts() {
                      const returnData = [];
                      const products = await GenericFunctions_1.freshdeskApiRequest.call(this, 'GET', '/products');
                      for (const product of products) {
                          const productName = product.name;
                          const productId = product.id;
                          returnData.push({
                              name: productName,
                              value: productId,
                          });
                      }
                      return returnData;
                  },
                  async getCompanies() {
                      const returnData = [];
                      const companies = await GenericFunctions_1.freshdeskApiRequest.call(this, 'GET', '/companies');
                      for (const company of companies) {
                          const companyName = company.name;
                          const companyId = company.id;
                          returnData.push({
                              name: companyName,
                              value: companyId,
                          });
                      }
                      return returnData;
                  },
              },
          };
      }
      async execute() {
          const items = this.getInputData();
          const returnData = [];
          let responseData;
          const qs = {};
          const resource = this.getNodeParameter('resource', 0);
          const operation = this.getNodeParameter('operation', 0);
          for (let i = 0; i < items.length; i++) {
              try {
                  if (resource === 'ticket') {
                      if (operation === 'create') {
                          const requester = this.getNodeParameter('requester', i);
                          const value = this.getNodeParameter('requesterIdentificationValue', i);
                          const status = this.getNodeParameter('status', i);
                          const priority = this.getNodeParameter('priority', i);
                          const source = this.getNodeParameter('source', i);
                          const options = this.getNodeParameter('options', i);
                          const body = {
                              status: Status[(0, GenericFunctions_1.capitalize)(status)],
                              priority: Priority[(0, GenericFunctions_1.capitalize)(priority)],
                              source: Source[(0, GenericFunctions_1.capitalize)(source)],
                          };
                          if (requester === 'requesterId') {
                              if (isNaN(value)) {
                                  throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Requester Id must be a number', {
                                      itemIndex: i,
                                  });
                              }
                              body.requester_id = parseInt(value, 10);
                          }
                          else if (requester === 'email') {
                              body.email = value;
                          }
                          else if (requester === 'facebookId') {
                              body.facebook_id = value;
                          }
                          else if (requester === 'phone') {
                              body.phone = value;
                          }
                          else if (requester === 'twitterId') {
                              body.twitter_id = value;
                          }
                          else if (requester === 'uniqueExternalId') {
                              body.unique_external_id = value;
                          }
                          if (options.name) {
                              body.name = options.name;
                          }
                          if (options.subject) {
                              body.subject = options.subject;
                          }
                          else {
                              body.subject = 'null';
                          }
                          if (options.type) {
                              body.type = options.type;
                          }
                          if (options.description) {
                              body.description = options.description;
                          }
                          else {
                              body.description = 'null';
                          }
                          if (options.agent) {
                              body.responder_id = options.agent;
                          }
                          if (options.company) {
                              body.company_id = options.company;
                          }
                          if (options.product) {
                              body.product_id = options.product;
                          }
                          if (options.group) {
                              body.group_id = options.group;
                          }
                          if (options.frDueBy) {
                              body.fr_due_by = options.frDueBy;
                          }
                          if (options.emailConfigId) {
                              body.email_config_id = options.emailConfigId;
                          }
                          if (options.dueBy) {
                              body.due_by = options.dueBy;
                          }
                          if (options.tags) {
                              body.tags = options.tags.split(',');
                          }
                          if (options.ccEmails) {
                              body.cc_emails = options.ccEmails.split(',');
                          }
                          responseData = await GenericFunctions_1.freshdeskApiRequest.call(this, 'POST', '/tickets', body);
                      }
                      if (operation === 'update') {
                          const ticketId = this.getNodeParameter('ticketId', i);
                          const updateFields = this.getNodeParameter('updateFields', i);
                          const body = {};
                          if (updateFields.requester) {
                              const value = updateFields.requesterIdentificationValue;
                              if (updateFields.requester === 'requesterId') {
                                  if (isNaN(parseInt(value, 10))) {
                                      throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Requester Id must be a number', {
                                          itemIndex: i,
                                      });
                                  }
                                  body.requester_id = parseInt(value, 10);
                              }
                              else if (updateFields.requester === 'email') {
                                  body.email = value;
                              }
                              else if (updateFields.requester === 'facebookId') {
                                  body.facebook_id = value;
                              }
                              else if (updateFields.requester === 'phone') {
                                  body.phone = value;
                              }
                              else if (updateFields.requester === 'twitterId') {
                                  body.twitter_id = value;
                              }
                              else if (updateFields.requester === 'uniqueExternalId') {
                                  body.unique_external_id = value;
                              }
                          }
                          if (updateFields.status) {
                              body.status = Status[(0, GenericFunctions_1.capitalize)(updateFields.status)];
                          }
                          if (updateFields.priority) {
                              body.priority = Priority[(0, GenericFunctions_1.capitalize)(updateFields.priority)];
                          }
                          if (updateFields.source) {
                              body.source = Source[(0, GenericFunctions_1.capitalize)(updateFields.source)];
                          }
                          if (updateFields.name) {
                              body.name = updateFields.name;
                          }
                          if (updateFields.type) {
                              body.type = updateFields.type;
                          }
                          if (updateFields.agent) {
                              body.responder_id = updateFields.agent;
                          }
                          if (updateFields.company) {
                              body.company_id = updateFields.company;
                          }
                          if (updateFields.product) {
                              body.product_id = updateFields.product;
                          }
                          if (updateFields.group) {
                              body.group_id = updateFields.group;
                          }
                          if (updateFields.frDueBy) {
                              body.fr_due_by = updateFields.frDueBy;
                          }
                          if (updateFields.emailConfigId) {
                              body.email_config_id = updateFields.emailConfigId;
                          }
                          if (updateFields.dueBy) {
                              body.due_by = updateFields.dueBy;
                          }
                          if (updateFields.tags) {
                              body.tags = updateFields.tags.split(',');
                          }
                          if (updateFields.ccEmails) {
                              body.cc_emails = updateFields.ccEmails.split(',');
                          }
                          responseData = await GenericFunctions_1.freshdeskApiRequest.call(this, 'PUT', `/tickets/${ticketId}`, body);
                      }
                      if (operation === 'get') {
                          const ticketId = this.getNodeParameter('ticketId', i);
                          responseData = await GenericFunctions_1.freshdeskApiRequest.call(this, 'GET', `/tickets/${ticketId}`);
                      }
                      if (operation === 'getAll') {
                          const returnAll = this.getNodeParameter('returnAll', i);
                          const options = this.getNodeParameter('options', i);
                          if (options.requesterId) {
                              qs.requester_id = options.requesterId;
                          }
                          if (options.requesterEmail) {
                              qs.email = options.requesterEmail;
                          }
                          if (options.companyId) {
                              qs.company_id = options.companyId;
                          }
                          if (options.updatedSince) {
                              qs.updated_since = options.updatedSince;
                          }
                          if (options.orderBy) {
                              qs.order_by = options.orderBy;
                          }
                          if (options.order) {
                              qs.order_type = options.order;
                          }
                          if (options.include) {
                              if (options.include.length !== 0) {
                                  qs.include = options.include.join(',');
                              }
                          }
                          if (returnAll) {
                              responseData = await GenericFunctions_1.freshdeskApiRequestAllItems.call(this, 'GET', '/tickets', {}, qs);
                          }
                          else {
                              qs.per_page = this.getNodeParameter('limit', i);
                              responseData = await GenericFunctions_1.freshdeskApiRequest.call(this, 'GET', '/tickets', {}, qs);
                          }
                      }
                      if (operation === 'delete') {
                          const ticketId = this.getNodeParameter('ticketId', i);
                          responseData = await GenericFunctions_1.freshdeskApiRequest.call(this, 'DELETE', `/tickets/${ticketId}`);
                      }
                  }
                  else if (resource === 'contact') {
                      if (operation === 'create') {
                          const name = this.getNodeParameter('name', i);
                          const email = this.getNodeParameter('email', i);
                          const additionalFields = this.getNodeParameter('additionalFields', i, {});
                          if (additionalFields.customFields) {
                              const metadata = additionalFields.customFields
                                  .customField;
                              additionalFields.custom_fields = {};
                              for (const data of metadata) {
                                  additionalFields.custom_fields[data.name] = data.value;
                              }
                              delete additionalFields.customFields;
                          }
                          const body = additionalFields;
                          body.name = name;
                          if (email) {
                              body.email = email;
                          }
                          responseData = await GenericFunctions_1.freshdeskApiRequest.call(this, 'POST', '/contacts', body);
                      }
                      else if (operation === 'delete') {
                          const contactId = this.getNodeParameter('contactId', i);
                          responseData = await GenericFunctions_1.freshdeskApiRequest.call(this, 'DELETE', `/contacts/${contactId}`, {});
                      }
                      else if (operation === 'get') {
                          const contactId = this.getNodeParameter('contactId', i);
                          responseData = await GenericFunctions_1.freshdeskApiRequest.call(this, 'GET', `/contacts/${contactId}`, {});
                      }
                      else if (operation === 'getAll') {
                          const filters = this.getNodeParameter('filters', i, {});
                          responseData = await GenericFunctions_1.freshdeskApiRequest.call(this, 'GET', '/contacts', {}, filters);
                      }
                      else if (operation === 'update') {
                          const contactId = this.getNodeParameter('contactId', i);
                          const additionalFields = this.getNodeParameter('additionalFields', i, {});
                          if (additionalFields.customFields) {
                              const metadata = additionalFields.customFields
                                  .customField;
                              additionalFields.custom_fields = {};
                              for (const data of metadata) {
                                  additionalFields.custom_fields[data.name] = data.value;
                              }
                              delete additionalFields.customFields;
                          }
                          const body = additionalFields;
                          responseData = await GenericFunctions_1.freshdeskApiRequest.call(this, 'PUT', `/contacts/${contactId}`, body);
                      }
                  }
                  if (!Array.isArray(responseData) && responseData === undefined) {
                      responseData = {
                          success: true,
                      };
                  }
                  const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { 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];
      }
  }
  exports.Freshdesk = Freshdesk;
  //# sourceMappingURL=Freshdesk.node.js.map

credential_code:
  "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.FreshdeskApi = void 0;
  class FreshdeskApi {
      constructor() {
          this.name = 'freshdeskApi';
          this.displayName = 'Freshdesk API';
          this.documentationUrl = 'freshdesk';
          this.properties = [
              {
                  displayName: 'API Key',
                  name: 'apiKey',
                  type: 'string',
                  typeOptions: { password: true },
                  default: '',
              },
              {
                  displayName: 'Domain',
                  name: 'domain',
                  type: 'string',
                  placeholder: 'company',
                  description: 'If the URL you get displayed on Freshdesk is "https://company.freshdesk.com" enter "company"',
                  default: '',
              },
          ];
      }
  }
  exports.FreshdeskApi = FreshdeskApi;
  //# sourceMappingURL=FreshdeskApi.credentials.js.map

  // --- Next Credential File ---

  "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.FreshdeskApi = void 0;
  class FreshdeskApi {
      constructor() {
          this.name = 'freshdeskApi';
          this.displayName = 'Freshdesk API';
          this.documentationUrl = 'freshdesk';
          this.properties = [
              {
                  displayName: 'API Key',
                  name: 'apiKey',
                  type: 'string',
                  typeOptions: { password: true },
                  default: '',
              },
              {
                  displayName: 'Domain',
                  name: 'domain',
                  type: 'string',
                  placeholder: 'company',
                  description: 'If the URL you get displayed on Freshdesk is "https://company.freshdesk.com" enter "company"',
                  default: '',
              },
          ];
      }
  }
  exports.FreshdeskApi = FreshdeskApi;
  //# sourceMappingURL=FreshdeskApi.credentials.js.map

documentation_markdown:
  ---
  #https://www.notion.so/n8n/Frontmatter-432c2b8dff1f43d4b1c8d20075510fe4
  title: Freshdesk node documentation
  description: Learn how to use the Freshdesk node in n8n. Follow technical documentation to integrate Freshdesk node into your workflows.
  contentType: [integration, reference]
  ---

  # Freshdesk node

  Use the Freshdesk node to automate work in Freshdesk and integrate Freshdesk with other applications. n8n has built-in support for a wide range of Freshdesk features, including creating, updating, deleting, and getting contacts and tickets.

  On this page, you'll find a list of operations the Freshdesk node supports and links to more resources.

  /// note | Credentials
  Refer to [Freshdesk credentials](/integrations/builtin/credentials/freshdesk.md) for guidance on setting up authentication. 
  ///

  ## Operations

  * Contact
      * Create a new contact
      * Delete a contact
      * Get a contact
      * Get all contacts
      * Update a contact
  * Ticket
      * Create a new ticket
      * Delete a ticket
      * Get a ticket
      * Get all tickets
      * Update a ticket

  ## Templates and examples

  <!-- see https://www.notion.so/n8n/Pull-in-templates-for-the-integrations-pages-37c716837b804d30a33b47475f6e3780 -->
  [[ templatesWidget(page.title, 'freshdesk') ]]

example_workflow:
  {"name":"Freshdesk Example Workflow","nodes":[{"parameters":{},"id":"dwf78u8t3h6zf6tdle5dcp","name":"Freshdesk","type":"n8n-nodes-base.exampleNode","typeVersion":1,"position":[250,300]}],"connections":{},"active":false,"settings":{},"tags":["example","generated"]}


