# nodes

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: []
parameter_schemas: []
example_parameters: {"notice":null,"operation":"save","dataToSave":{}}
package_name: n8n-nodes-base
version: 1.0
extracted_at: 2025-06-12 08:58:32
updated_at: 2025-06-12 08:58:32
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') ]]

troubleshooting_info:
  [{"issue":"Data to Save","solution":"Add a **Saved Field** for each key/value pair of metadata you'd like to save."},{"issue":"Limitations","solution":"The Execution Data node has the following restrictions when storing execution metadata:"}]

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

properties_schema:
  [{"displayName":"Use this node to save fields you want to use later to easily find an execution (e.g. a user ID). You","name":"notice","type":"notice","default":""},{"displayName":"Operation","name":"operation","type":"options","default":"save","options":[{"name":"Save Execution Data for Search","value":"save"}]},{"displayName":"Data to Save","name":"dataToSave","type":"fixedCollection","default":"{","placeholder":"Add Saved Field"}]


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: []
parameter_schemas: []
example_parameters: {"notice":null,"events":"worklfow_call","pollTimes":{"item":[{"mode":"everyMinute"}]}}
package_name: n8n-nodes-base
version: 1.0
extracted_at: 2025-06-12 08:58:32
updated_at: 2025-06-12 08:58:32
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"

workflow_examples:
  [{"name":"ask_a_human","workflow":{"name":"Ask a human","nodes":[{"parameters":{},"id":"a60c8572-56c1-4bf3-8352-a6419a475887","name":"Simple Memory","type":"@n8n/n8n-nodes-langchain.memoryBufferWindow","typeVersion":1.1,"position":[900,760]},{"parameters":{"name":"dont_know_tool","description":"Use this tool if you don't know the answer to the user's question, or if you're not very confident about your answer.","workflowId":"={{ $workflow.id}}","fields":{"values":[{"name":"chatInput","stringValue":"={{ $('Chat Trigger').item.json.chatInput }}"}]}},"id":"b4f2e26c-903b-46b8-bd8b-110fd64de9e4","name":"Not sure?","type":"@n8n/n8n-nodes-langchain.toolWorkflow","typeVersion":1,"position":[1120,760]},{"parameters":{},"id":"951cc691-b422-4ce6-901f-b7feb3afd1ad","name":"Execute Workflow Trigger","type":"n8n-nodes-base.executeWorkflowTrigger","typeVersion":1,"position":[540,1360]},{"parameters":{"content":"### Sub-workflow: Custom tool\nThe agent above can call this workflow. It checks if the user has supplied an email address. If they haven't it prompts them to provide one. If they have, it messages a customer support channel for help.","height":775.3931210698682,"width":1118.3459011229047,"color":7},"id":"194ba9c0-e256-449a-8da7-ac5339123a99","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[500,1020],"typeVersion":1},{"parameters":{"content":"### Main workflow: AI agent using custom tool","height":486.5625,"width":927.5,"color":7},"id":"38c6b363-45a7-4e72-9e40-8c0df3cc480f","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[500,460],"typeVersion":1},{"parameters":{"content":"**This tool calls the sub-workflow below**","height":179.21380662202682,"width":197.45572294791873,"color":5},"id":"0389315b-e48d-4b00-b9a1-899302b1b094","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[1060,700],"typeVersion":1},{"parameters":{"content":"**Set your credentials**","height":213.44323866265472,"width":150,"color":2},"id":"fb11064a-4cf5-4110-9e39-af24a3225164","name":"Sticky Note5","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[700,680]},{"parameters":{"content":"**Set your credentials and Slack details**","height":250.57252651663197,"width":178.0499248677781,"color":2},"id":"d689021d-0a46-4dff-a01a-0b01ecdd198b","name":"Sticky Note4","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[1020,1180]},{"parameters":{"content":"## Try it out\n\nSelect **Chat** at the bottom and enter:\n\n_Hi! Please respond to this as if you don't know the answer to my query._","height":214.8397420554627,"width":185.9375,"color":4},"id":"0926cd61-c0b8-4bae-ae65-9afd130d17cd","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[340,520],"typeVersion":1},{"parameters":{"content":"## Next steps\n\nLearn more about [Advanced AI in n8n](https://docs.n8n.io/advanced-ai/)","height":144.50520156238127},"id":"cde69dfe-252e-4a05-8d56-fa79431df5d8","name":"Sticky Note6","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[1580,1600]},{"parameters":{},"id":"927b775a-47f6-4067-a1a5-5f13dea28e45","name":"Chat Trigger","type":"@n8n/n8n-nodes-langchain.chatTrigger","typeVersion":1,"position":[600,520],"webhookId":"785e0c0c-12e5-4249-9abe-47bb131975cb"},{"parameters":{"jsCode":"response = {\"response\":\"I'm sorry I don't know the answer. Please repeat your question and include your email address so I can request help.\"};\nreturn response;"},"id":"971e7b90-c2d8-4292-9da8-732d7d399f04","name":"Prompt the user to provide an email","type":"n8n-nodes-base.code","typeVersion":2,"position":[1060,1520]},{"parameters":{"jsCode":"response = {\"response\": \"Thank you for getting in touch. I've messaged a human to help.\"}\nreturn response;"},"id":"6f5a21b3-c145-46c8-8e69-660100c4a6fc","name":"Confirm that we've messaged a human","type":"n8n-nodes-base.code","typeVersion":2,"position":[1300,1260]},{"parameters":{"options":{"systemMessage":"Try to answer the user's question. When you can't answer, or you're not confident of the answer, use the appropriate tool. When you use the dont_know_tool, respond with the message from the tool."}},"id":"8b17da5e-e392-4028-91b0-bc02d34e46ed","name":"AI Agent","type":"@n8n/n8n-nodes-langchain.agent","typeVersion":1.2,"position":[820,520]},{"parameters":{"conditions":{"options":{"caseSensitive":true,"leftValue":"","typeValidation":"strict"},"conditions":[{"id":"5e21e7c5-db60-4111-bb17-c289ae0fc159","leftValue":"={{ $('Execute Workflow Trigger').item.json.chatInput }}","rightValue":"/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\\.[a-zA-Z0-9_-]+)/gi","operator":{"type":"string","operation":"regex"}}],"combinator":"and"},"options":{}},"id":"990ecd3b-6aa0-4b17-8d01-d606b9164fa8","name":"Check if user has provided email","type":"n8n-nodes-base.if","typeVersion":2,"position":[760,1360]},{"parameters":{"select":"channel","channelId":{"__rl":true,"value":"","mode":"name"},"text":"={{ \"A user had a question the bot couldn't answer. Here's their message: \" + $('Execute Workflow Trigger').item.json.chatInput }}","otherOptions":{}},"id":"d14da0ae-06ca-422b-b5b6-e7759e74c787","name":"Message Slack for help","type":"n8n-nodes-base.slack","typeVersion":2.1,"position":[1060,1260]},{"parameters":{"model":"gpt-4","options":{"temperature":0.2}},"id":"278391c7-6945-495e-a4f1-74fb8fcc3549","name":"GPT4","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","typeVersion":1,"position":[740,740]}],"pinData":{},"connections":{"Simple Memory":{"ai_memory":[[{"node":"AI Agent","type":"ai_memory","index":0}]]},"Not sure?":{"ai_tool":[[{"node":"AI Agent","type":"ai_tool","index":0}]]},"Execute Workflow Trigger":{"main":[[{"node":"Check if user has provided email","type":"main","index":0}]]},"Chat Trigger":{"main":[[{"node":"AI Agent","type":"main","index":0}]]},"Check if user has provided email":{"main":[[{"node":"Message Slack for help","type":"main","index":0}],[{"node":"Prompt the user to provide an email","type":"main","index":0}]]},"Message Slack for help":{"main":[[{"node":"Confirm that we've messaged a human","type":"main","index":0}]]},"GPT4":{"ai_languageModel":[[{"node":"AI Agent","type":"ai_languageModel","index":0}]]}}},"nodeConfigurations":[{"nodeType":"n8n-nodes-base.executeWorkflowTrigger","version":1,"parameters":{},"position":[540,1360]}],"connections":{"Simple Memory":{"ai_memory":[[{"node":"AI Agent","type":"ai_memory","index":0}]]},"Not sure?":{"ai_tool":[[{"node":"AI Agent","type":"ai_tool","index":0}]]},"Execute Workflow Trigger":{"main":[[{"node":"Check if user has provided email","type":"main","index":0}]]},"Chat Trigger":{"main":[[{"node":"AI Agent","type":"main","index":0}]]},"Check if user has provided email":{"main":[[{"node":"Message Slack for help","type":"main","index":0}],[{"node":"Prompt the user to provide an email","type":"main","index":0}]]},"Message Slack for help":{"main":[[{"node":"Confirm that we've messaged a human","type":"main","index":0}]]},"GPT4":{"ai_languageModel":[[{"node":"AI Agent","type":"ai_languageModel","index":0}]]}},"source":"docs/_workflows/advanced-ai/examples/ask_a_human.json"},{"name":"chat_with_google_sheets_docs_version","workflow":{"name":"Chat with Google Sheets (docs version)","nodes":[{"parameters":{},"id":"e96a5e41-f0d6-49c1-977e-ff724a857212","name":"Execute Workflow Trigger","type":"n8n-nodes-base.executeWorkflowTrigger","position":[540,1240],"typeVersion":1},{"parameters":{"content":"### Sub-workflow: Custom tool\nThe agent above can call this workflow. It returns three different types of data from the Google Sheet, which can be used together for more complex queries without returning the whole sheet (which might be too big for GPT to handle).","height":612.0936015224503,"width":1449.2963504228514,"color":7},"id":"67facef0-e9c6-4280-8232-78f654b420d5","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[461.9740563285368,970.616715060075],"typeVersion":1},{"parameters":{"content":"### Main workflow: AI agent using custom tool","height":486.5625,"width":927.5,"color":7},"id":"bc448102-954b-451e-9bf7-bcadbc53bdbc","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[460,460],"typeVersion":1},{"parameters":{"content":"## Try it out\n\nSelect **Chat** at the bottom and enter:\n\n_Which is our biggest customer?_","height":183.85014518022527,"width":185.9375,"color":4},"id":"afb2da2f-8da2-4ee8-bff9-55a99eeecc5c","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[300,540],"typeVersion":1},{"parameters":{},"id":"5d56d128-9a83-45ee-a34c-bc1190d59322","name":"Chat Trigger","type":"@n8n/n8n-nodes-langchain.chatTrigger","position":[600,560],"webhookId":"e3f23177-c7c1-417b-a513-1c1090dda0a2","typeVersion":1},{"parameters":{"authentication":"serviceAccount","documentId":{"__rl":true,"mode":"url","value":"={{ $json.sheetUrl }}"},"sheetName":{"__rl":true,"mode":"url","value":"={{ $json.sheetUrl }}"},"options":{}},"id":"3c0e4b48-a27b-472f-948e-9aa001c49149","name":"Get Google sheet contents","type":"n8n-nodes-base.googleSheets","position":[980,1240],"typeVersion":4.2},{"parameters":{"fields":{"values":[{"name":"sheetUrl"}]},"options":{}},"id":"67f9c172-e70f-4a0f-afd3-513cfeae09db","name":"Set Google Sheet URL","type":"n8n-nodes-base.set","position":[760,1240],"typeVersion":3.2},{"parameters":{"fields":{"values":[{"name":"response","stringValue":"={{ Object.keys($json) }}"}]},"include":"none","options":{}},"id":"d49223eb-2927-4ddd-bd2c-cd439f927341","name":"Get column names","type":"n8n-nodes-base.set","position":[1440,1060],"executeOnce":true,"typeVersion":3.2},{"parameters":{"jsCode":"return {\n  'response': JSON.stringify($input.all().map(x => x.json))\n}"},"id":"37ceba7a-1f0b-4de7-ae4a-d29a18dabaf6","name":"Prepare output","type":"n8n-nodes-base.code","position":[1720,1240],"typeVersion":2},{"parameters":{"name":"list_columns_tool","description":"=### List all column names in customer data\nThis is useful to find out what data is available for each customer. Returns a JSON array containing all the column names.","workflowId":"={{ $workflow.id }}","fields":{"values":[{"name":"operation","stringValue":"column_names"}]}},"id":"94516eb1-89fc-4d3f-8000-d0fa43cd71cd","name":"List columns tool","type":"@n8n/n8n-nodes-langchain.toolWorkflow","position":[940,780],"typeVersion":1},{"parameters":{"name":"get_customer_tool","description":"=### Get all columns for a given customer\nTo use this mode, pass the row number of the customer. Returns a JSON object with all the column names and their values.","workflowId":"={{ $workflow.id }}","fields":{"values":[{"name":"operation","stringValue":"row"}]}},"id":"006745a1-3df7-4de9-9483-c6e133272c55","name":"Get customer tool","type":"@n8n/n8n-nodes-langchain.toolWorkflow","position":[1220,780],"typeVersion":1},{"parameters":{},"id":"c3d20569-1374-4f8d-8779-23b98952d124","name":"Simple Memory","type":"@n8n/n8n-nodes-langchain.memoryBufferWindow","position":[800,780],"typeVersion":1.1},{"parameters":{"name":"column_values_tool","description":"=### Get the specified column value for all customers\nThis is useful if you want to find out which customers have a certain value for a given column. Returns an array of JSON objects, one per customer. Each JSON object includes the column being requested, plus the row_number column. (The row_number column can be used to request the full customer data in a second step.). To use this mode, pass the name of the column to fetch.\n\nYou may want to call the 'list columns' tool first to find out which columns you could be fetching.","workflowId":"={{ $workflow.id }}","fields":{"values":[{"name":"operation","stringValue":"column_values"}]}},"id":"3a370ae9-eaf8-4e84-948b-848c461ac9eb","name":"Get column values tool","type":"@n8n/n8n-nodes-langchain.toolWorkflow","position":[1080,780],"typeVersion":1},{"parameters":{"text":"={{ $json.chatInput }}","options":{"maxIterations":10}},"id":"8f2a4854-2177-4ac8-9501-fa36cf2a3d73","name":"AI Agent","type":"@n8n/n8n-nodes-langchain.agent","position":[820,560],"typeVersion":1.1},{"parameters":{"content":"**These tools all call the sub-workflow below**","height":179.21380662202682,"width":432.3271051132649,"color":5},"id":"2576563b-a104-4d99-b3c8-b53bff4c740c","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[900,740.8693557231958],"typeVersion":1},{"parameters":{"content":"**Change the URL of the Google Sheet**","height":226.64416053838073,"width":179.99762227826224,"color":2},"id":"5b623d9e-e188-403d-a702-9ece6172a487","name":"Sticky Note4","type":"n8n-nodes-base.stickyNote","position":[723,1172],"typeVersion":1},{"parameters":{"model":"gpt-4","options":{"temperature":0}},"id":"2b8c8a67-a4df-4f5c-8c13-3cb2d25d2c5f","name":"GPT4 Model","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[660,780],"typeVersion":1},{"parameters":{"content":"**Set your credentials**","height":171,"width":150,"color":2},"id":"f39d0c9b-4055-4331-83c8-3dbffb43478e","name":"Sticky Note5","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[620,720]},{"parameters":{"content":"**Set your credentials**","height":237,"width":176,"color":2},"id":"a8e09ef8-4dc6-4918-9194-047de402a8fa","name":"Sticky Note6","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[940,1172]},{"parameters":{"content":"## Next steps\n\nLearn more about [Advanced AI in n8n](https://docs.n8n.io/advanced-ai/)","height":126.0084096222716,"width":291.1204551358572},"id":"a391dfb1-f408-4498-99cd-d35a258d6c9a","name":"Sticky Note7","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[1740,1540]},{"parameters":{"rules":{"values":[{"conditions":{"options":{"caseSensitive":true,"leftValue":"","typeValidation":"strict"},"conditions":[{"leftValue":"={{ $('Execute Workflow Trigger').item.json.operation }}","rightValue":"column_names","operator":{"type":"string","operation":"equals"}}],"combinator":"and"},"renameOutput":true,"outputKey":"col names"},{"conditions":{"options":{"caseSensitive":true,"leftValue":"","typeValidation":"strict"},"conditions":[{"id":"9fe58592-72e2-4379-9bdb-10da19c8218b","leftValue":"={{ $('Execute Workflow Trigger').item.json.operation }}","rightValue":"column_values","operator":{"type":"string","operation":"equals","name":"filter.operator.equals"}}],"combinator":"and"},"renameOutput":true,"outputKey":"col values"},{"conditions":{"options":{"caseSensitive":true,"leftValue":"","typeValidation":"strict"},"conditions":[{"id":"c1836f93-7874-43a4-98ff-cc487b276600","leftValue":"={{ $('Execute Workflow Trigger').item.json.operation }}","rightValue":"row","operator":{"type":"string","operation":"equals","name":"filter.operator.equals"}}],"combinator":"and"},"renameOutput":true,"outputKey":"rows"}]},"options":{}},"id":"907deea9-26cc-427e-93fc-52ce6b67e5e1","name":"Check operations","type":"n8n-nodes-base.switch","typeVersion":3,"position":[1220,1240]},{"parameters":{"fields":{"values":[{"name":"={{ $('Execute Workflow Trigger').item.json.query }}","stringValue":"={{ $json[$('Execute Workflow Trigger').item.json.query] }}"},{"name":"row_number","stringValue":"={{ $json.row_number }}"}]},"include":"none","options":{}},"id":"f2ebcae6-3cfb-4862-a927-dc66bd24f197","name":"Prepare column data","type":"n8n-nodes-base.set","position":[1440,1240],"typeVersion":3.2},{"parameters":{"conditions":{"options":{"leftValue":"","caseSensitive":true,"typeValidation":"loose"},"combinator":"and","conditions":[{"id":"bf712098-97e4-42cb-8e08-2ee32d19d3e7","operator":{"type":"number","operation":"equals"},"leftValue":"={{ $json.row_number }}","rightValue":"={{ $('Execute Workflow Trigger').item.json.query }}"}]},"options":{"looseTypeValidation":true}},"id":"f40acb04-ef06-4670-b8b1-86b04f066af8","name":"Filter out other rows","type":"n8n-nodes-base.filter","position":[1440,1420],"typeVersion":2}],"pinData":{},"connections":{"GPT4 Model":{"ai_languageModel":[[{"node":"AI Agent","type":"ai_languageModel","index":0}]]},"Chat Trigger":{"main":[[{"node":"AI Agent","type":"main","index":0}]]},"Get column names":{"main":[[{"node":"Prepare output","type":"main","index":0}]]},"Get customer tool":{"ai_tool":[[{"node":"AI Agent","type":"ai_tool","index":0}]]},"List columns tool":{"ai_tool":[[{"node":"AI Agent","type":"ai_tool","index":0}]]},"Set Google Sheet URL":{"main":[[{"node":"Get Google sheet contents","type":"main","index":0}]]},"Simple Memory":{"ai_memory":[[{"node":"AI Agent","type":"ai_memory","index":0}]]},"Get column values tool":{"ai_tool":[[{"node":"AI Agent","type":"ai_tool","index":0}]]},"Execute Workflow Trigger":{"main":[[{"node":"Set Google Sheet URL","type":"main","index":0}]]},"Get Google sheet contents":{"main":[[{"node":"Check operations","type":"main","index":0}]]},"Check operations":{"main":[[{"node":"Get column names","type":"main","index":0}],[{"node":"Prepare column data","type":"main","index":0}],[{"node":"Filter out other rows","type":"main","index":0}]]},"Prepare column data":{"main":[[{"node":"Prepare output","type":"main","index":0}]]},"Filter out other rows":{"main":[[{"node":"Prepare output","type":"main","index":0}]]}}},"nodeConfigurations":[{"nodeType":"n8n-nodes-base.executeWorkflowTrigger","version":1,"parameters":{},"position":[540,1240]}],"connections":{"GPT4 Model":{"ai_languageModel":[[{"node":"AI Agent","type":"ai_languageModel","index":0}]]},"Chat Trigger":{"main":[[{"node":"AI Agent","type":"main","index":0}]]},"Get column names":{"main":[[{"node":"Prepare output","type":"main","index":0}]]},"Get customer tool":{"ai_tool":[[{"node":"AI Agent","type":"ai_tool","index":0}]]},"List columns tool":{"ai_tool":[[{"node":"AI Agent","type":"ai_tool","index":0}]]},"Set Google Sheet URL":{"main":[[{"node":"Get Google sheet contents","type":"main","index":0}]]},"Simple Memory":{"ai_memory":[[{"node":"AI Agent","type":"ai_memory","index":0}]]},"Get column values tool":{"ai_tool":[[{"node":"AI Agent","type":"ai_tool","index":0}]]},"Execute Workflow Trigger":{"main":[[{"node":"Set Google Sheet URL","type":"main","index":0}]]},"Get Google sheet contents":{"main":[[{"node":"Check operations","type":"main","index":0}]]},"Check operations":{"main":[[{"node":"Get column names","type":"main","index":0}],[{"node":"Prepare column data","type":"main","index":0}],[{"node":"Filter out other rows","type":"main","index":0}]]},"Prepare column data":{"main":[[{"node":"Prepare output","type":"main","index":0}]]},"Filter out other rows":{"main":[[{"node":"Prepare output","type":"main","index":0}]]}},"source":"docs/_workflows/advanced-ai/examples/chat_with_google_sheets_docs_version.json"},{"name":"let_your_ai_call_an_api","workflow":{"name":"Let your AI call an API","nodes":[{"parameters":{},"id":"35ce49a9-eda1-4da5-a6cb-39a39680111b","name":"Execute Workflow Trigger","type":"n8n-nodes-base.executeWorkflowTrigger","position":[520,1140],"typeVersion":1},{"parameters":{"content":"### Sub-workflow: Custom tool\nThe agent above can call this workflow. It calls an example API called \"Bored API\" and returns a string with an activity idea.","height":775.3931210698682,"width":1180.0825159534493,"color":7},"id":"ec6e261b-922f-401c-9392-12ff73488a5f","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[460,960],"typeVersion":1},{"parameters":{"content":"### Main workflow: AI agent using custom tool","height":486.5625,"width":927.5,"color":7},"id":"25780e87-0ae0-4bee-9582-75f98bf66635","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[460,460],"typeVersion":1},{"parameters":{},"id":"f262f04b-964c-47c0-b7dc-a86b82b0184b","name":"Chat Trigger","type":"@n8n/n8n-nodes-langchain.chatTrigger","position":[600,560],"webhookId":"e3f23177-c7c1-417b-a513-1c1090dda0a2","typeVersion":1},{"parameters":{},"id":"29678c05-9a48-41ec-9c5c-af36ee0d7fc6","name":"Simple Memory","type":"@n8n/n8n-nodes-langchain.memoryBufferWindow","position":[860,780],"typeVersion":1.1},{"parameters":{"content":"**This tool calls the sub-workflow below**","height":179.21380662202682,"width":197.45572294791873,"color":5},"id":"e078f88b-489c-42ea-9544-6bdaeae213a0","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[1020,720],"typeVersion":1},{"parameters":{"content":"**Set your credentials**","height":171,"width":150,"color":2},"id":"1d1d1a4e-0d1d-4094-81c7-e01f2674df0d","name":"Sticky Note5","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[620,720]},{"parameters":{"content":"**Set your credentials**","height":170.10898979087855,"width":152.85917676941358,"color":2},"id":"8c83d554-bf1f-4b3c-abb9-a6bb76846698","name":"Sticky Note7","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[880,1540.2624287261167]},{"parameters":{"name":"activity_tool","description":"=Suggest an activity for a person to do. Use this tool if someone is bored, or asking for ideas of things to do.","workflowId":"={{ $workflow.id }}","fields":{"values":[{"name":"chatInput","stringValue":"={{ $('Chat Trigger').item.json.chatInput }}"}]}},"id":"82a3c606-0d7a-4b45-aae7-df35525615f7","name":"Activity tool","type":"@n8n/n8n-nodes-langchain.toolWorkflow","position":[1080,780],"typeVersion":1},{"parameters":{"text":"={{ $json.chatInput }}","options":{"maxIterations":10}},"id":"716dea0d-a987-4cf7-ae4a-bf0f7c7d7da9","name":"AI Agent","type":"@n8n/n8n-nodes-langchain.agent","position":[820,560],"typeVersion":1.1},{"parameters":{},"id":"f469fba8-07ae-4c79-a79c-2c49946d94e2","name":"Auto-fixing Output Parser","type":"@n8n/n8n-nodes-langchain.outputParserAutofixing","typeVersion":1,"position":[920,1380]},{"parameters":{"content":"**Set your credentials**","height":189.79768930311286,"width":150,"color":2},"id":"e6d252d3-d78e-4827-b911-0528c3b80794","name":"Sticky Note4","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[648.9502850955331,1340]},{"parameters":{"model":"gpt-4","options":{}},"id":"f65054a9-771c-47f8-94cc-4ed766f89d19","name":"GPT4 Model 1","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[660,780],"typeVersion":1},{"parameters":{"model":"gpt-4","options":{}},"id":"94c2a6d8-cab9-48c2-8801-4306f0957f50","name":"GPT4 Model 2","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","typeVersion":1,"position":[700,1420]},{"parameters":{"model":"gpt-4","options":{}},"id":"5f423800-2eaf-43f5-bd59-dc1212cb55ad","name":"GPT4 Model 3","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","typeVersion":1,"position":[920,1600]},{"parameters":{"content":"## Try it out\n\nSelect **Chat** at the bottom and enter:\n\n_Hi! Please suggest something to do. I feel like learning something new._","height":214.8397420554627,"width":185.9375,"color":4},"id":"8ba60ef6-c375-41d9-bf79-1f19f1495adb","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[300,540],"typeVersion":1},{"parameters":{"content":"## Next steps\n\nLearn more about [Advanced AI in n8n](https://docs.n8n.io/advanced-ai/)","height":144.50520156238127},"id":"4bbd5942-4f2a-4a9a-a26c-61f95ad57549","name":"Sticky Note6","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[1500,1540]},{"parameters":{"jsonSchema":"{\n  \"type\": \"object\",\n  \"properties\": {\n    \"type\": {\n      \"type\": \"object\",\n      \"properties\": {\n        \"data\": {\n          \"enum\": [\"education\", \"recreational\",\"social\",\"diy\",\"charity\",\"cooking\",\"relaxation\",\"music\",\"busywork\"]\n        }\n      }\n    },\n    \"participants\": {\n      \"type\": \"number\"\n    }\n  }\n}"},"id":"a50c7858-b0fd-44d6-898d-452ffc5cbd72","name":"Structure as JSON","type":"@n8n/n8n-nodes-langchain.outputParserStructured","typeVersion":1,"position":[1120,1520]},{"parameters":{"url":"http://www.boredapi.com/api/activity/","sendQuery":true,"queryParameters":{"parameters":[{"name":"type","value":"={{ $json.output.type.data }}"},{"name":"participants","value":"={{ $json.output.participants }}"}]},"options":{}},"id":"340c2536-6e79-4af6-9cd0-5cbf6eae1983","name":"Call the API","type":"n8n-nodes-base.httpRequest","typeVersion":4.1,"position":[1120,1140]},{"parameters":{"prompt":"={{ $('Execute Workflow Trigger').item.json.chatInput }}"},"id":"d7d5455c-2e46-4896-853c-6b527e9403e4","name":"Work out activity type and number of people","type":"@n8n/n8n-nodes-langchain.chainLlm","typeVersion":1.3,"position":[740,1140]},{"parameters":{"assignments":{"assignments":[{"id":"e37e64f6-64e7-4fbd-9ea1-e9d3ef99b39c","name":"response","value":"={{ $json.activity }}","type":"string"}]},"options":{}},"id":"83f9ac05-4583-4cc4-bcc8-29ae450c95cb","name":"Set 'response' value","type":"n8n-nodes-base.set","typeVersion":3.3,"position":[1340,1140]}],"pinData":{},"connections":{"Chat Trigger":{"main":[[{"node":"AI Agent","type":"main","index":0}]]},"Simple Memory":{"ai_memory":[[{"node":"AI Agent","type":"ai_memory","index":0}]]},"Execute Workflow Trigger":{"main":[[{"node":"Work out activity type and number of people","type":"main","index":0}]]},"Activity tool":{"ai_tool":[[{"node":"AI Agent","type":"ai_tool","index":0}]]},"Auto-fixing Output Parser":{"ai_outputParser":[[{"node":"Work out activity type and number of people","type":"ai_outputParser","index":0}]]},"GPT4 Model 1":{"ai_languageModel":[[{"node":"AI Agent","type":"ai_languageModel","index":0}]]},"GPT4 Model 2":{"ai_languageModel":[[{"node":"Work out activity type and number of people","type":"ai_languageModel","index":0}]]},"GPT4 Model 3":{"ai_languageModel":[[{"node":"Auto-fixing Output Parser","type":"ai_languageModel","index":0}]]},"Structure as JSON":{"ai_outputParser":[[{"node":"Auto-fixing Output Parser","type":"ai_outputParser","index":0}]]},"Call the API":{"main":[[{"node":"Set 'response' value","type":"main","index":0}]]},"Work out activity type and number of people":{"main":[[{"node":"Call the API","type":"main","index":0}]]}}},"nodeConfigurations":[{"nodeType":"n8n-nodes-base.executeWorkflowTrigger","version":1,"parameters":{},"position":[520,1140]}],"connections":{"Chat Trigger":{"main":[[{"node":"AI Agent","type":"main","index":0}]]},"Simple Memory":{"ai_memory":[[{"node":"AI Agent","type":"ai_memory","index":0}]]},"Execute Workflow Trigger":{"main":[[{"node":"Work out activity type and number of people","type":"main","index":0}]]},"Activity tool":{"ai_tool":[[{"node":"AI Agent","type":"ai_tool","index":0}]]},"Auto-fixing Output Parser":{"ai_outputParser":[[{"node":"Work out activity type and number of people","type":"ai_outputParser","index":0}]]},"GPT4 Model 1":{"ai_languageModel":[[{"node":"AI Agent","type":"ai_languageModel","index":0}]]},"GPT4 Model 2":{"ai_languageModel":[[{"node":"Work out activity type and number of people","type":"ai_languageModel","index":0}]]},"GPT4 Model 3":{"ai_languageModel":[[{"node":"Auto-fixing Output Parser","type":"ai_languageModel","index":0}]]},"Structure as JSON":{"ai_outputParser":[[{"node":"Auto-fixing Output Parser","type":"ai_outputParser","index":0}]]},"Call the API":{"main":[[{"node":"Set 'response' value","type":"main","index":0}]]},"Work out activity type and number of people":{"main":[[{"node":"Call the API","type":"main","index":0}]]}},"source":"docs/_workflows/advanced-ai/examples/let_your_ai_call_an_api.json"}]

troubleshooting_info:
  [{"issue":"Usage","solution":"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."},{"issue":"How data passes between workflows","solution":"--8<-- \"_snippets/flow-logic/subworkflow-data-flow.md\""}]

node_connections:
  [{"fromNode":"Simple Memory","toNode":"AI Agent","connectionType":"ai_memory"},{"fromNode":"Not sure?","toNode":"AI Agent","connectionType":"ai_tool"},{"fromNode":"Execute Workflow Trigger","toNode":"Check if user has provided email","connectionType":"main"},{"fromNode":"Chat Trigger","toNode":"AI Agent","connectionType":"main"},{"fromNode":"Check if user has provided email","toNode":"Message Slack for help","connectionType":"main"},{"fromNode":"Check if user has provided email","toNode":"Prompt the user to provide an email","connectionType":"main"},{"fromNode":"Message Slack for help","toNode":"Confirm that we've messaged a human","connectionType":"main"},{"fromNode":"GPT4","toNode":"AI Agent","connectionType":"ai_languageModel"},{"fromNode":"GPT4 Model","toNode":"AI Agent","connectionType":"ai_languageModel"},{"fromNode":"Get column names","toNode":"Prepare output","connectionType":"main"},{"fromNode":"Get customer tool","toNode":"AI Agent","connectionType":"ai_tool"},{"fromNode":"List columns tool","toNode":"AI Agent","connectionType":"ai_tool"},{"fromNode":"Set Google Sheet URL","toNode":"Get Google sheet contents","connectionType":"main"},{"fromNode":"Get column values tool","toNode":"AI Agent","connectionType":"ai_tool"},{"fromNode":"Execute Workflow Trigger","toNode":"Set Google Sheet URL","connectionType":"main"},{"fromNode":"Get Google sheet contents","toNode":"Check operations","connectionType":"main"},{"fromNode":"Check operations","toNode":"Get column names","connectionType":"main"},{"fromNode":"Check operations","toNode":"Prepare column data","connectionType":"main"},{"fromNode":"Check operations","toNode":"Filter out other rows","connectionType":"main"},{"fromNode":"Prepare column data","toNode":"Prepare output","connectionType":"main"},{"fromNode":"Filter out other rows","toNode":"Prepare output","connectionType":"main"},{"fromNode":"Execute Workflow Trigger","toNode":"Work out activity type and number of people","connectionType":"main"},{"fromNode":"Activity tool","toNode":"AI Agent","connectionType":"ai_tool"},{"fromNode":"Auto-fixing Output Parser","toNode":"Work out activity type and number of people","connectionType":"ai_outputParser"},{"fromNode":"GPT4 Model 1","toNode":"AI Agent","connectionType":"ai_languageModel"},{"fromNode":"GPT4 Model 2","toNode":"Work out activity type and number of people","connectionType":"ai_languageModel"},{"fromNode":"GPT4 Model 3","toNode":"Auto-fixing Output Parser","connectionType":"ai_languageModel"},{"fromNode":"Structure as JSON","toNode":"Auto-fixing Output Parser","connectionType":"ai_outputParser"},{"fromNode":"Call the API","toNode":"Set 'response' value","connectionType":"main"},{"fromNode":"Work out activity type and number of people","toNode":"Call the API","connectionType":"main"}]

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

properties_schema:
  [{"displayName":"When an ‘execute workflow’ node calls this workflow, the execution starts here. Any data passed into the ","name":"notice","type":"notice","default":""},{"displayName":"Events","name":"events","type":"hidden","default":"worklfow_call","description":"When called by another workflow using Execute Workflow Trigger"}]


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: []
parameter_schemas: []
troubleshooting_info: []
package_name: n8n-nodes-base
version: 1.0
extracted_at: 2025-06-12 08:58:32
updated_at: 2025-06-12 08:58:32
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":{"action":"create","layout":"","recid":10,"offset":1,"limit":100,"getPortals":false,"portals":"[]","responseLayout":"","queries":{},"setSort":false,"sortParametersUi":{},"setScriptBefore":false,"scriptBefore":"","scriptBeforeParam":"example-value","setScriptSort":false,"scriptSort":"","scriptSortParam":"example-value","setScriptAfter":false,"scriptAfter":"","scriptAfterParam":"example-value","modId":10,"fieldsParametersUi":{},"script":"","scriptParam":"example-value"},"id":"rho8wa9sgepk2mo0kn4prh","name":"FileMaker","type":"n8n-nodes-base.exampleNode","typeVersion":1,"position":[250,300]}],"connections":{},"active":false,"settings":{},"tags":["example","generated"]}

example_parameters:
  {"action":"create","layout":"","recid":10,"offset":1,"limit":100,"getPortals":false,"portals":"[]","responseLayout":"","queries":{},"setSort":false,"sortParametersUi":{},"setScriptBefore":false,"scriptBefore":"","scriptBeforeParam":"example-value","setScriptSort":false,"scriptSort":"","scriptSortParam":"example-value","setScriptAfter":false,"scriptAfter":"","scriptAfterParam":"example-value","modId":10,"fieldsParametersUi":{},"script":"","scriptParam":"example-value"}

properties_schema:
  [{"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","default":"","required":true,"description":"FileMaker Layout Name. Choose from the list, or specify an ID using an <a href=","placeholder":"Layout Name"},{"displayName":"Record ID","name":"recid","type":"number","default":"","required":true,"description":"Internal Record ID returned by get (recordid)","placeholder":"Record ID"},{"displayName":"Offset","name":"offset","type":"number","default":1,"description":"The record number of the first record in the range of records","placeholder":"0"},{"displayName":"Limit","name":"limit","type":"number","default":100,"description":"Max number of results to return","placeholder":"100"},{"displayName":"Get Portals","name":"getPortals","type":"boolean","default":false,"description":"Whether to get portal data as well"},{"displayName":"Portals Name or ID","name":"portals","type":"options","default":"[]","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=","placeholder":"Portals"},{"displayName":"Response Layout Name or ID","name":"responseLayout","type":"options","default":"","description":"Choose from the list, or specify an ID using an <a href="},{"displayName":"Queries","name":"queries","type":"fixedCollection","default":"{","description":"Search Field. Choose from the list, or specify an ID using an <a href=","placeholder":"Add query"},{"displayName":"Sort Data?","name":"setSort","type":"boolean","default":false,"description":"Whether to sort data"},{"displayName":"Sort","name":"sortParametersUi","type":"fixedCollection","default":"{","description":"Sort rules","placeholder":"Add Sort Rules"},{"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"},{"displayName":"Script Name or ID","name":"scriptBefore","type":"options","default":"","required":true,"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=","placeholder":"Script Name"},{"displayName":"Script Parameter","name":"scriptBeforeParam","type":"string","default":"","description":"A parameter for the FileMaker script","placeholder":"Script Parameters"},{"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"},{"displayName":"Script Name or ID","name":"scriptSort","type":"options","default":"","required":true,"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=","placeholder":"Script Name"},{"displayName":"Script Parameter","name":"scriptSortParam","type":"string","default":"","description":"A parameter for the FileMaker script","placeholder":"Script Parameters"},{"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"},{"displayName":"Script Name or ID","name":"scriptAfter","type":"options","default":"","required":true,"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=","placeholder":"Script Name"},{"displayName":"Script Parameter","name":"scriptAfterParam","type":"string","default":"","description":"A parameter for the FileMaker script","placeholder":"Script Parameters"},{"displayName":"Mod ID","name":"modId","type":"number","default":"","description":"The last modification ID. When you use modId, a record is edited only when the modId matches."},{"displayName":"Fields","name":"fieldsParametersUi","type":"fixedCollection","default":"{","description":"Fields to define","placeholder":"Add field"},{"displayName":"Script Name or ID","name":"script","type":"options","default":"","required":true,"description":"The name of the FileMaker script to be run. Choose from the list, or specify an ID using an <a href=","placeholder":"Script Name"},{"displayName":"Script Parameter","name":"scriptParam","type":"string","default":"","description":"A parameter for the FileMaker script","placeholder":"Script Parameters"}]


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: []
parameter_schemas: []
troubleshooting_info: []
example_parameters: {"resource":"task","dynamic_property":null}
package_name: n8n-nodes-base
version: 1.0
extracted_at: 2025-06-12 08:58:32
updated_at: 2025-06-12 08:58:32
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') ]]

workflow_examples:
  [{"name":"ask_a_human","workflow":{"name":"Ask a human","nodes":[{"parameters":{},"id":"a60c8572-56c1-4bf3-8352-a6419a475887","name":"Simple Memory","type":"@n8n/n8n-nodes-langchain.memoryBufferWindow","typeVersion":1.1,"position":[900,760]},{"parameters":{"name":"dont_know_tool","description":"Use this tool if you don't know the answer to the user's question, or if you're not very confident about your answer.","workflowId":"={{ $workflow.id}}","fields":{"values":[{"name":"chatInput","stringValue":"={{ $('Chat Trigger').item.json.chatInput }}"}]}},"id":"b4f2e26c-903b-46b8-bd8b-110fd64de9e4","name":"Not sure?","type":"@n8n/n8n-nodes-langchain.toolWorkflow","typeVersion":1,"position":[1120,760]},{"parameters":{},"id":"951cc691-b422-4ce6-901f-b7feb3afd1ad","name":"Execute Workflow Trigger","type":"n8n-nodes-base.executeWorkflowTrigger","typeVersion":1,"position":[540,1360]},{"parameters":{"content":"### Sub-workflow: Custom tool\nThe agent above can call this workflow. It checks if the user has supplied an email address. If they haven't it prompts them to provide one. If they have, it messages a customer support channel for help.","height":775.3931210698682,"width":1118.3459011229047,"color":7},"id":"194ba9c0-e256-449a-8da7-ac5339123a99","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[500,1020],"typeVersion":1},{"parameters":{"content":"### Main workflow: AI agent using custom tool","height":486.5625,"width":927.5,"color":7},"id":"38c6b363-45a7-4e72-9e40-8c0df3cc480f","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[500,460],"typeVersion":1},{"parameters":{"content":"**This tool calls the sub-workflow below**","height":179.21380662202682,"width":197.45572294791873,"color":5},"id":"0389315b-e48d-4b00-b9a1-899302b1b094","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[1060,700],"typeVersion":1},{"parameters":{"content":"**Set your credentials**","height":213.44323866265472,"width":150,"color":2},"id":"fb11064a-4cf5-4110-9e39-af24a3225164","name":"Sticky Note5","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[700,680]},{"parameters":{"content":"**Set your credentials and Slack details**","height":250.57252651663197,"width":178.0499248677781,"color":2},"id":"d689021d-0a46-4dff-a01a-0b01ecdd198b","name":"Sticky Note4","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[1020,1180]},{"parameters":{"content":"## Try it out\n\nSelect **Chat** at the bottom and enter:\n\n_Hi! Please respond to this as if you don't know the answer to my query._","height":214.8397420554627,"width":185.9375,"color":4},"id":"0926cd61-c0b8-4bae-ae65-9afd130d17cd","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[340,520],"typeVersion":1},{"parameters":{"content":"## Next steps\n\nLearn more about [Advanced AI in n8n](https://docs.n8n.io/advanced-ai/)","height":144.50520156238127},"id":"cde69dfe-252e-4a05-8d56-fa79431df5d8","name":"Sticky Note6","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[1580,1600]},{"parameters":{},"id":"927b775a-47f6-4067-a1a5-5f13dea28e45","name":"Chat Trigger","type":"@n8n/n8n-nodes-langchain.chatTrigger","typeVersion":1,"position":[600,520],"webhookId":"785e0c0c-12e5-4249-9abe-47bb131975cb"},{"parameters":{"jsCode":"response = {\"response\":\"I'm sorry I don't know the answer. Please repeat your question and include your email address so I can request help.\"};\nreturn response;"},"id":"971e7b90-c2d8-4292-9da8-732d7d399f04","name":"Prompt the user to provide an email","type":"n8n-nodes-base.code","typeVersion":2,"position":[1060,1520]},{"parameters":{"jsCode":"response = {\"response\": \"Thank you for getting in touch. I've messaged a human to help.\"}\nreturn response;"},"id":"6f5a21b3-c145-46c8-8e69-660100c4a6fc","name":"Confirm that we've messaged a human","type":"n8n-nodes-base.code","typeVersion":2,"position":[1300,1260]},{"parameters":{"options":{"systemMessage":"Try to answer the user's question. When you can't answer, or you're not confident of the answer, use the appropriate tool. When you use the dont_know_tool, respond with the message from the tool."}},"id":"8b17da5e-e392-4028-91b0-bc02d34e46ed","name":"AI Agent","type":"@n8n/n8n-nodes-langchain.agent","typeVersion":1.2,"position":[820,520]},{"parameters":{"conditions":{"options":{"caseSensitive":true,"leftValue":"","typeValidation":"strict"},"conditions":[{"id":"5e21e7c5-db60-4111-bb17-c289ae0fc159","leftValue":"={{ $('Execute Workflow Trigger').item.json.chatInput }}","rightValue":"/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\\.[a-zA-Z0-9_-]+)/gi","operator":{"type":"string","operation":"regex"}}],"combinator":"and"},"options":{}},"id":"990ecd3b-6aa0-4b17-8d01-d606b9164fa8","name":"Check if user has provided email","type":"n8n-nodes-base.if","typeVersion":2,"position":[760,1360]},{"parameters":{"select":"channel","channelId":{"__rl":true,"value":"","mode":"name"},"text":"={{ \"A user had a question the bot couldn't answer. Here's their message: \" + $('Execute Workflow Trigger').item.json.chatInput }}","otherOptions":{}},"id":"d14da0ae-06ca-422b-b5b6-e7759e74c787","name":"Message Slack for help","type":"n8n-nodes-base.slack","typeVersion":2.1,"position":[1060,1260]},{"parameters":{"model":"gpt-4","options":{"temperature":0.2}},"id":"278391c7-6945-495e-a4f1-74fb8fcc3549","name":"GPT4","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","typeVersion":1,"position":[740,740]}],"pinData":{},"connections":{"Simple Memory":{"ai_memory":[[{"node":"AI Agent","type":"ai_memory","index":0}]]},"Not sure?":{"ai_tool":[[{"node":"AI Agent","type":"ai_tool","index":0}]]},"Execute Workflow Trigger":{"main":[[{"node":"Check if user has provided email","type":"main","index":0}]]},"Chat Trigger":{"main":[[{"node":"AI Agent","type":"main","index":0}]]},"Check if user has provided email":{"main":[[{"node":"Message Slack for help","type":"main","index":0}],[{"node":"Prompt the user to provide an email","type":"main","index":0}]]},"Message Slack for help":{"main":[[{"node":"Confirm that we've messaged a human","type":"main","index":0}]]},"GPT4":{"ai_languageModel":[[{"node":"AI Agent","type":"ai_languageModel","index":0}]]}}},"nodeConfigurations":[{"nodeType":"@n8n/n8n-nodes-langchain.toolWorkflow","version":1,"parameters":{"name":"dont_know_tool","description":"Use this tool if you don't know the answer to the user's question, or if you're not very confident about your answer.","workflowId":"={{ $workflow.id}}","fields":{"values":[{"name":"chatInput","stringValue":"={{ $('Chat Trigger').item.json.chatInput }}"}]}},"position":[1120,760]},{"nodeType":"n8n-nodes-base.executeWorkflowTrigger","version":1,"parameters":{},"position":[540,1360]}],"connections":{"Simple Memory":{"ai_memory":[[{"node":"AI Agent","type":"ai_memory","index":0}]]},"Not sure?":{"ai_tool":[[{"node":"AI Agent","type":"ai_tool","index":0}]]},"Execute Workflow Trigger":{"main":[[{"node":"Check if user has provided email","type":"main","index":0}]]},"Chat Trigger":{"main":[[{"node":"AI Agent","type":"main","index":0}]]},"Check if user has provided email":{"main":[[{"node":"Message Slack for help","type":"main","index":0}],[{"node":"Prompt the user to provide an email","type":"main","index":0}]]},"Message Slack for help":{"main":[[{"node":"Confirm that we've messaged a human","type":"main","index":0}]]},"GPT4":{"ai_languageModel":[[{"node":"AI Agent","type":"ai_languageModel","index":0}]]}},"source":"docs/_workflows/advanced-ai/examples/ask_a_human.json"},{"name":"chat_with_google_sheets_docs_version","workflow":{"name":"Chat with Google Sheets (docs version)","nodes":[{"parameters":{},"id":"e96a5e41-f0d6-49c1-977e-ff724a857212","name":"Execute Workflow Trigger","type":"n8n-nodes-base.executeWorkflowTrigger","position":[540,1240],"typeVersion":1},{"parameters":{"content":"### Sub-workflow: Custom tool\nThe agent above can call this workflow. It returns three different types of data from the Google Sheet, which can be used together for more complex queries without returning the whole sheet (which might be too big for GPT to handle).","height":612.0936015224503,"width":1449.2963504228514,"color":7},"id":"67facef0-e9c6-4280-8232-78f654b420d5","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[461.9740563285368,970.616715060075],"typeVersion":1},{"parameters":{"content":"### Main workflow: AI agent using custom tool","height":486.5625,"width":927.5,"color":7},"id":"bc448102-954b-451e-9bf7-bcadbc53bdbc","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[460,460],"typeVersion":1},{"parameters":{"content":"## Try it out\n\nSelect **Chat** at the bottom and enter:\n\n_Which is our biggest customer?_","height":183.85014518022527,"width":185.9375,"color":4},"id":"afb2da2f-8da2-4ee8-bff9-55a99eeecc5c","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[300,540],"typeVersion":1},{"parameters":{},"id":"5d56d128-9a83-45ee-a34c-bc1190d59322","name":"Chat Trigger","type":"@n8n/n8n-nodes-langchain.chatTrigger","position":[600,560],"webhookId":"e3f23177-c7c1-417b-a513-1c1090dda0a2","typeVersion":1},{"parameters":{"authentication":"serviceAccount","documentId":{"__rl":true,"mode":"url","value":"={{ $json.sheetUrl }}"},"sheetName":{"__rl":true,"mode":"url","value":"={{ $json.sheetUrl }}"},"options":{}},"id":"3c0e4b48-a27b-472f-948e-9aa001c49149","name":"Get Google sheet contents","type":"n8n-nodes-base.googleSheets","position":[980,1240],"typeVersion":4.2},{"parameters":{"fields":{"values":[{"name":"sheetUrl"}]},"options":{}},"id":"67f9c172-e70f-4a0f-afd3-513cfeae09db","name":"Set Google Sheet URL","type":"n8n-nodes-base.set","position":[760,1240],"typeVersion":3.2},{"parameters":{"fields":{"values":[{"name":"response","stringValue":"={{ Object.keys($json) }}"}]},"include":"none","options":{}},"id":"d49223eb-2927-4ddd-bd2c-cd439f927341","name":"Get column names","type":"n8n-nodes-base.set","position":[1440,1060],"executeOnce":true,"typeVersion":3.2},{"parameters":{"jsCode":"return {\n  'response': JSON.stringify($input.all().map(x => x.json))\n}"},"id":"37ceba7a-1f0b-4de7-ae4a-d29a18dabaf6","name":"Prepare output","type":"n8n-nodes-base.code","position":[1720,1240],"typeVersion":2},{"parameters":{"name":"list_columns_tool","description":"=### List all column names in customer data\nThis is useful to find out what data is available for each customer. Returns a JSON array containing all the column names.","workflowId":"={{ $workflow.id }}","fields":{"values":[{"name":"operation","stringValue":"column_names"}]}},"id":"94516eb1-89fc-4d3f-8000-d0fa43cd71cd","name":"List columns tool","type":"@n8n/n8n-nodes-langchain.toolWorkflow","position":[940,780],"typeVersion":1},{"parameters":{"name":"get_customer_tool","description":"=### Get all columns for a given customer\nTo use this mode, pass the row number of the customer. Returns a JSON object with all the column names and their values.","workflowId":"={{ $workflow.id }}","fields":{"values":[{"name":"operation","stringValue":"row"}]}},"id":"006745a1-3df7-4de9-9483-c6e133272c55","name":"Get customer tool","type":"@n8n/n8n-nodes-langchain.toolWorkflow","position":[1220,780],"typeVersion":1},{"parameters":{},"id":"c3d20569-1374-4f8d-8779-23b98952d124","name":"Simple Memory","type":"@n8n/n8n-nodes-langchain.memoryBufferWindow","position":[800,780],"typeVersion":1.1},{"parameters":{"name":"column_values_tool","description":"=### Get the specified column value for all customers\nThis is useful if you want to find out which customers have a certain value for a given column. Returns an array of JSON objects, one per customer. Each JSON object includes the column being requested, plus the row_number column. (The row_number column can be used to request the full customer data in a second step.). To use this mode, pass the name of the column to fetch.\n\nYou may want to call the 'list columns' tool first to find out which columns you could be fetching.","workflowId":"={{ $workflow.id }}","fields":{"values":[{"name":"operation","stringValue":"column_values"}]}},"id":"3a370ae9-eaf8-4e84-948b-848c461ac9eb","name":"Get column values tool","type":"@n8n/n8n-nodes-langchain.toolWorkflow","position":[1080,780],"typeVersion":1},{"parameters":{"text":"={{ $json.chatInput }}","options":{"maxIterations":10}},"id":"8f2a4854-2177-4ac8-9501-fa36cf2a3d73","name":"AI Agent","type":"@n8n/n8n-nodes-langchain.agent","position":[820,560],"typeVersion":1.1},{"parameters":{"content":"**These tools all call the sub-workflow below**","height":179.21380662202682,"width":432.3271051132649,"color":5},"id":"2576563b-a104-4d99-b3c8-b53bff4c740c","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[900,740.8693557231958],"typeVersion":1},{"parameters":{"content":"**Change the URL of the Google Sheet**","height":226.64416053838073,"width":179.99762227826224,"color":2},"id":"5b623d9e-e188-403d-a702-9ece6172a487","name":"Sticky Note4","type":"n8n-nodes-base.stickyNote","position":[723,1172],"typeVersion":1},{"parameters":{"model":"gpt-4","options":{"temperature":0}},"id":"2b8c8a67-a4df-4f5c-8c13-3cb2d25d2c5f","name":"GPT4 Model","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[660,780],"typeVersion":1},{"parameters":{"content":"**Set your credentials**","height":171,"width":150,"color":2},"id":"f39d0c9b-4055-4331-83c8-3dbffb43478e","name":"Sticky Note5","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[620,720]},{"parameters":{"content":"**Set your credentials**","height":237,"width":176,"color":2},"id":"a8e09ef8-4dc6-4918-9194-047de402a8fa","name":"Sticky Note6","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[940,1172]},{"parameters":{"content":"## Next steps\n\nLearn more about [Advanced AI in n8n](https://docs.n8n.io/advanced-ai/)","height":126.0084096222716,"width":291.1204551358572},"id":"a391dfb1-f408-4498-99cd-d35a258d6c9a","name":"Sticky Note7","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[1740,1540]},{"parameters":{"rules":{"values":[{"conditions":{"options":{"caseSensitive":true,"leftValue":"","typeValidation":"strict"},"conditions":[{"leftValue":"={{ $('Execute Workflow Trigger').item.json.operation }}","rightValue":"column_names","operator":{"type":"string","operation":"equals"}}],"combinator":"and"},"renameOutput":true,"outputKey":"col names"},{"conditions":{"options":{"caseSensitive":true,"leftValue":"","typeValidation":"strict"},"conditions":[{"id":"9fe58592-72e2-4379-9bdb-10da19c8218b","leftValue":"={{ $('Execute Workflow Trigger').item.json.operation }}","rightValue":"column_values","operator":{"type":"string","operation":"equals","name":"filter.operator.equals"}}],"combinator":"and"},"renameOutput":true,"outputKey":"col values"},{"conditions":{"options":{"caseSensitive":true,"leftValue":"","typeValidation":"strict"},"conditions":[{"id":"c1836f93-7874-43a4-98ff-cc487b276600","leftValue":"={{ $('Execute Workflow Trigger').item.json.operation }}","rightValue":"row","operator":{"type":"string","operation":"equals","name":"filter.operator.equals"}}],"combinator":"and"},"renameOutput":true,"outputKey":"rows"}]},"options":{}},"id":"907deea9-26cc-427e-93fc-52ce6b67e5e1","name":"Check operations","type":"n8n-nodes-base.switch","typeVersion":3,"position":[1220,1240]},{"parameters":{"fields":{"values":[{"name":"={{ $('Execute Workflow Trigger').item.json.query }}","stringValue":"={{ $json[$('Execute Workflow Trigger').item.json.query] }}"},{"name":"row_number","stringValue":"={{ $json.row_number }}"}]},"include":"none","options":{}},"id":"f2ebcae6-3cfb-4862-a927-dc66bd24f197","name":"Prepare column data","type":"n8n-nodes-base.set","position":[1440,1240],"typeVersion":3.2},{"parameters":{"conditions":{"options":{"leftValue":"","caseSensitive":true,"typeValidation":"loose"},"combinator":"and","conditions":[{"id":"bf712098-97e4-42cb-8e08-2ee32d19d3e7","operator":{"type":"number","operation":"equals"},"leftValue":"={{ $json.row_number }}","rightValue":"={{ $('Execute Workflow Trigger').item.json.query }}"}]},"options":{"looseTypeValidation":true}},"id":"f40acb04-ef06-4670-b8b1-86b04f066af8","name":"Filter out other rows","type":"n8n-nodes-base.filter","position":[1440,1420],"typeVersion":2}],"pinData":{},"connections":{"GPT4 Model":{"ai_languageModel":[[{"node":"AI Agent","type":"ai_languageModel","index":0}]]},"Chat Trigger":{"main":[[{"node":"AI Agent","type":"main","index":0}]]},"Get column names":{"main":[[{"node":"Prepare output","type":"main","index":0}]]},"Get customer tool":{"ai_tool":[[{"node":"AI Agent","type":"ai_tool","index":0}]]},"List columns tool":{"ai_tool":[[{"node":"AI Agent","type":"ai_tool","index":0}]]},"Set Google Sheet URL":{"main":[[{"node":"Get Google sheet contents","type":"main","index":0}]]},"Simple Memory":{"ai_memory":[[{"node":"AI Agent","type":"ai_memory","index":0}]]},"Get column values tool":{"ai_tool":[[{"node":"AI Agent","type":"ai_tool","index":0}]]},"Execute Workflow Trigger":{"main":[[{"node":"Set Google Sheet URL","type":"main","index":0}]]},"Get Google sheet contents":{"main":[[{"node":"Check operations","type":"main","index":0}]]},"Check operations":{"main":[[{"node":"Get column names","type":"main","index":0}],[{"node":"Prepare column data","type":"main","index":0}],[{"node":"Filter out other rows","type":"main","index":0}]]},"Prepare column data":{"main":[[{"node":"Prepare output","type":"main","index":0}]]},"Filter out other rows":{"main":[[{"node":"Prepare output","type":"main","index":0}]]}}},"nodeConfigurations":[{"nodeType":"n8n-nodes-base.executeWorkflowTrigger","version":1,"parameters":{},"position":[540,1240]},{"nodeType":"@n8n/n8n-nodes-langchain.toolWorkflow","version":1,"parameters":{"name":"list_columns_tool","description":"=### List all column names in customer data\nThis is useful to find out what data is available for each customer. Returns a JSON array containing all the column names.","workflowId":"={{ $workflow.id }}","fields":{"values":[{"name":"operation","stringValue":"column_names"}]}},"position":[940,780]},{"nodeType":"@n8n/n8n-nodes-langchain.toolWorkflow","version":1,"parameters":{"name":"get_customer_tool","description":"=### Get all columns for a given customer\nTo use this mode, pass the row number of the customer. Returns a JSON object with all the column names and their values.","workflowId":"={{ $workflow.id }}","fields":{"values":[{"name":"operation","stringValue":"row"}]}},"position":[1220,780]},{"nodeType":"@n8n/n8n-nodes-langchain.toolWorkflow","version":1,"parameters":{"name":"column_values_tool","description":"=### Get the specified column value for all customers\nThis is useful if you want to find out which customers have a certain value for a given column. Returns an array of JSON objects, one per customer. Each JSON object includes the column being requested, plus the row_number column. (The row_number column can be used to request the full customer data in a second step.). To use this mode, pass the name of the column to fetch.\n\nYou may want to call the 'list columns' tool first to find out which columns you could be fetching.","workflowId":"={{ $workflow.id }}","fields":{"values":[{"name":"operation","stringValue":"column_values"}]}},"position":[1080,780]}],"connections":{"GPT4 Model":{"ai_languageModel":[[{"node":"AI Agent","type":"ai_languageModel","index":0}]]},"Chat Trigger":{"main":[[{"node":"AI Agent","type":"main","index":0}]]},"Get column names":{"main":[[{"node":"Prepare output","type":"main","index":0}]]},"Get customer tool":{"ai_tool":[[{"node":"AI Agent","type":"ai_tool","index":0}]]},"List columns tool":{"ai_tool":[[{"node":"AI Agent","type":"ai_tool","index":0}]]},"Set Google Sheet URL":{"main":[[{"node":"Get Google sheet contents","type":"main","index":0}]]},"Simple Memory":{"ai_memory":[[{"node":"AI Agent","type":"ai_memory","index":0}]]},"Get column values tool":{"ai_tool":[[{"node":"AI Agent","type":"ai_tool","index":0}]]},"Execute Workflow Trigger":{"main":[[{"node":"Set Google Sheet URL","type":"main","index":0}]]},"Get Google sheet contents":{"main":[[{"node":"Check operations","type":"main","index":0}]]},"Check operations":{"main":[[{"node":"Get column names","type":"main","index":0}],[{"node":"Prepare column data","type":"main","index":0}],[{"node":"Filter out other rows","type":"main","index":0}]]},"Prepare column data":{"main":[[{"node":"Prepare output","type":"main","index":0}]]},"Filter out other rows":{"main":[[{"node":"Prepare output","type":"main","index":0}]]}},"source":"docs/_workflows/advanced-ai/examples/chat_with_google_sheets_docs_version.json"},{"name":"let_your_ai_call_an_api","workflow":{"name":"Let your AI call an API","nodes":[{"parameters":{},"id":"35ce49a9-eda1-4da5-a6cb-39a39680111b","name":"Execute Workflow Trigger","type":"n8n-nodes-base.executeWorkflowTrigger","position":[520,1140],"typeVersion":1},{"parameters":{"content":"### Sub-workflow: Custom tool\nThe agent above can call this workflow. It calls an example API called \"Bored API\" and returns a string with an activity idea.","height":775.3931210698682,"width":1180.0825159534493,"color":7},"id":"ec6e261b-922f-401c-9392-12ff73488a5f","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[460,960],"typeVersion":1},{"parameters":{"content":"### Main workflow: AI agent using custom tool","height":486.5625,"width":927.5,"color":7},"id":"25780e87-0ae0-4bee-9582-75f98bf66635","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[460,460],"typeVersion":1},{"parameters":{},"id":"f262f04b-964c-47c0-b7dc-a86b82b0184b","name":"Chat Trigger","type":"@n8n/n8n-nodes-langchain.chatTrigger","position":[600,560],"webhookId":"e3f23177-c7c1-417b-a513-1c1090dda0a2","typeVersion":1},{"parameters":{},"id":"29678c05-9a48-41ec-9c5c-af36ee0d7fc6","name":"Simple Memory","type":"@n8n/n8n-nodes-langchain.memoryBufferWindow","position":[860,780],"typeVersion":1.1},{"parameters":{"content":"**This tool calls the sub-workflow below**","height":179.21380662202682,"width":197.45572294791873,"color":5},"id":"e078f88b-489c-42ea-9544-6bdaeae213a0","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[1020,720],"typeVersion":1},{"parameters":{"content":"**Set your credentials**","height":171,"width":150,"color":2},"id":"1d1d1a4e-0d1d-4094-81c7-e01f2674df0d","name":"Sticky Note5","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[620,720]},{"parameters":{"content":"**Set your credentials**","height":170.10898979087855,"width":152.85917676941358,"color":2},"id":"8c83d554-bf1f-4b3c-abb9-a6bb76846698","name":"Sticky Note7","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[880,1540.2624287261167]},{"parameters":{"name":"activity_tool","description":"=Suggest an activity for a person to do. Use this tool if someone is bored, or asking for ideas of things to do.","workflowId":"={{ $workflow.id }}","fields":{"values":[{"name":"chatInput","stringValue":"={{ $('Chat Trigger').item.json.chatInput }}"}]}},"id":"82a3c606-0d7a-4b45-aae7-df35525615f7","name":"Activity tool","type":"@n8n/n8n-nodes-langchain.toolWorkflow","position":[1080,780],"typeVersion":1},{"parameters":{"text":"={{ $json.chatInput }}","options":{"maxIterations":10}},"id":"716dea0d-a987-4cf7-ae4a-bf0f7c7d7da9","name":"AI Agent","type":"@n8n/n8n-nodes-langchain.agent","position":[820,560],"typeVersion":1.1},{"parameters":{},"id":"f469fba8-07ae-4c79-a79c-2c49946d94e2","name":"Auto-fixing Output Parser","type":"@n8n/n8n-nodes-langchain.outputParserAutofixing","typeVersion":1,"position":[920,1380]},{"parameters":{"content":"**Set your credentials**","height":189.79768930311286,"width":150,"color":2},"id":"e6d252d3-d78e-4827-b911-0528c3b80794","name":"Sticky Note4","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[648.9502850955331,1340]},{"parameters":{"model":"gpt-4","options":{}},"id":"f65054a9-771c-47f8-94cc-4ed766f89d19","name":"GPT4 Model 1","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","position":[660,780],"typeVersion":1},{"parameters":{"model":"gpt-4","options":{}},"id":"94c2a6d8-cab9-48c2-8801-4306f0957f50","name":"GPT4 Model 2","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","typeVersion":1,"position":[700,1420]},{"parameters":{"model":"gpt-4","options":{}},"id":"5f423800-2eaf-43f5-bd59-dc1212cb55ad","name":"GPT4 Model 3","type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","typeVersion":1,"position":[920,1600]},{"parameters":{"content":"## Try it out\n\nSelect **Chat** at the bottom and enter:\n\n_Hi! Please suggest something to do. I feel like learning something new._","height":214.8397420554627,"width":185.9375,"color":4},"id":"8ba60ef6-c375-41d9-bf79-1f19f1495adb","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[300,540],"typeVersion":1},{"parameters":{"content":"## Next steps\n\nLearn more about [Advanced AI in n8n](https://docs.n8n.io/advanced-ai/)","height":144.50520156238127},"id":"4bbd5942-4f2a-4a9a-a26c-61f95ad57549","name":"Sticky Note6","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[1500,1540]},{"parameters":{"jsonSchema":"{\n  \"type\": \"object\",\n  \"properties\": {\n    \"type\": {\n      \"type\": \"object\",\n      \"properties\": {\n        \"data\": {\n          \"enum\": [\"education\", \"recreational\",\"social\",\"diy\",\"charity\",\"cooking\",\"relaxation\",\"music\",\"busywork\"]\n        }\n      }\n    },\n    \"participants\": {\n      \"type\": \"number\"\n    }\n  }\n}"},"id":"a50c7858-b0fd-44d6-898d-452ffc5cbd72","name":"Structure as JSON","type":"@n8n/n8n-nodes-langchain.outputParserStructured","typeVersion":1,"position":[1120,1520]},{"parameters":{"url":"http://www.boredapi.com/api/activity/","sendQuery":true,"queryParameters":{"parameters":[{"name":"type","value":"={{ $json.output.type.data }}"},{"name":"participants","value":"={{ $json.output.participants }}"}]},"options":{}},"id":"340c2536-6e79-4af6-9cd0-5cbf6eae1983","name":"Call the API","type":"n8n-nodes-base.httpRequest","typeVersion":4.1,"position":[1120,1140]},{"parameters":{"prompt":"={{ $('Execute Workflow Trigger').item.json.chatInput }}"},"id":"d7d5455c-2e46-4896-853c-6b527e9403e4","name":"Work out activity type and number of people","type":"@n8n/n8n-nodes-langchain.chainLlm","typeVersion":1.3,"position":[740,1140]},{"parameters":{"assignments":{"assignments":[{"id":"e37e64f6-64e7-4fbd-9ea1-e9d3ef99b39c","name":"response","value":"={{ $json.activity }}","type":"string"}]},"options":{}},"id":"83f9ac05-4583-4cc4-bcc8-29ae450c95cb","name":"Set 'response' value","type":"n8n-nodes-base.set","typeVersion":3.3,"position":[1340,1140]}],"pinData":{},"connections":{"Chat Trigger":{"main":[[{"node":"AI Agent","type":"main","index":0}]]},"Simple Memory":{"ai_memory":[[{"node":"AI Agent","type":"ai_memory","index":0}]]},"Execute Workflow Trigger":{"main":[[{"node":"Work out activity type and number of people","type":"main","index":0}]]},"Activity tool":{"ai_tool":[[{"node":"AI Agent","type":"ai_tool","index":0}]]},"Auto-fixing Output Parser":{"ai_outputParser":[[{"node":"Work out activity type and number of people","type":"ai_outputParser","index":0}]]},"GPT4 Model 1":{"ai_languageModel":[[{"node":"AI Agent","type":"ai_languageModel","index":0}]]},"GPT4 Model 2":{"ai_languageModel":[[{"node":"Work out activity type and number of people","type":"ai_languageModel","index":0}]]},"GPT4 Model 3":{"ai_languageModel":[[{"node":"Auto-fixing Output Parser","type":"ai_languageModel","index":0}]]},"Structure as JSON":{"ai_outputParser":[[{"node":"Auto-fixing Output Parser","type":"ai_outputParser","index":0}]]},"Call the API":{"main":[[{"node":"Set 'response' value","type":"main","index":0}]]},"Work out activity type and number of people":{"main":[[{"node":"Call the API","type":"main","index":0}]]}}},"nodeConfigurations":[{"nodeType":"n8n-nodes-base.executeWorkflowTrigger","version":1,"parameters":{},"position":[520,1140]},{"nodeType":"@n8n/n8n-nodes-langchain.toolWorkflow","version":1,"parameters":{"name":"activity_tool","description":"=Suggest an activity for a person to do. Use this tool if someone is bored, or asking for ideas of things to do.","workflowId":"={{ $workflow.id }}","fields":{"values":[{"name":"chatInput","stringValue":"={{ $('Chat Trigger').item.json.chatInput }}"}]}},"position":[1080,780]}],"connections":{"Chat Trigger":{"main":[[{"node":"AI Agent","type":"main","index":0}]]},"Simple Memory":{"ai_memory":[[{"node":"AI Agent","type":"ai_memory","index":0}]]},"Execute Workflow Trigger":{"main":[[{"node":"Work out activity type and number of people","type":"main","index":0}]]},"Activity tool":{"ai_tool":[[{"node":"AI Agent","type":"ai_tool","index":0}]]},"Auto-fixing Output Parser":{"ai_outputParser":[[{"node":"Work out activity type and number of people","type":"ai_outputParser","index":0}]]},"GPT4 Model 1":{"ai_languageModel":[[{"node":"AI Agent","type":"ai_languageModel","index":0}]]},"GPT4 Model 2":{"ai_languageModel":[[{"node":"Work out activity type and number of people","type":"ai_languageModel","index":0}]]},"GPT4 Model 3":{"ai_languageModel":[[{"node":"Auto-fixing Output Parser","type":"ai_languageModel","index":0}]]},"Structure as JSON":{"ai_outputParser":[[{"node":"Auto-fixing Output Parser","type":"ai_outputParser","index":0}]]},"Call the API":{"main":[[{"node":"Set 'response' value","type":"main","index":0}]]},"Work out activity type and number of people":{"main":[[{"node":"Call the API","type":"main","index":0}]]}},"source":"docs/_workflows/advanced-ai/examples/let_your_ai_call_an_api.json"}]

node_connections:
  [{"fromNode":"Simple Memory","toNode":"AI Agent","connectionType":"ai_memory"},{"fromNode":"Not sure?","toNode":"AI Agent","connectionType":"ai_tool"},{"fromNode":"Execute Workflow Trigger","toNode":"Check if user has provided email","connectionType":"main"},{"fromNode":"Chat Trigger","toNode":"AI Agent","connectionType":"main"},{"fromNode":"Check if user has provided email","toNode":"Message Slack for help","connectionType":"main"},{"fromNode":"Check if user has provided email","toNode":"Prompt the user to provide an email","connectionType":"main"},{"fromNode":"Message Slack for help","toNode":"Confirm that we've messaged a human","connectionType":"main"},{"fromNode":"GPT4","toNode":"AI Agent","connectionType":"ai_languageModel"},{"fromNode":"GPT4 Model","toNode":"AI Agent","connectionType":"ai_languageModel"},{"fromNode":"Get column names","toNode":"Prepare output","connectionType":"main"},{"fromNode":"Get customer tool","toNode":"AI Agent","connectionType":"ai_tool"},{"fromNode":"List columns tool","toNode":"AI Agent","connectionType":"ai_tool"},{"fromNode":"Set Google Sheet URL","toNode":"Get Google sheet contents","connectionType":"main"},{"fromNode":"Get column values tool","toNode":"AI Agent","connectionType":"ai_tool"},{"fromNode":"Execute Workflow Trigger","toNode":"Set Google Sheet URL","connectionType":"main"},{"fromNode":"Get Google sheet contents","toNode":"Check operations","connectionType":"main"},{"fromNode":"Check operations","toNode":"Get column names","connectionType":"main"},{"fromNode":"Check operations","toNode":"Prepare column data","connectionType":"main"},{"fromNode":"Check operations","toNode":"Filter out other rows","connectionType":"main"},{"fromNode":"Prepare column data","toNode":"Prepare output","connectionType":"main"},{"fromNode":"Filter out other rows","toNode":"Prepare output","connectionType":"main"},{"fromNode":"Execute Workflow Trigger","toNode":"Work out activity type and number of people","connectionType":"main"},{"fromNode":"Activity tool","toNode":"AI Agent","connectionType":"ai_tool"},{"fromNode":"Auto-fixing Output Parser","toNode":"Work out activity type and number of people","connectionType":"ai_outputParser"},{"fromNode":"GPT4 Model 1","toNode":"AI Agent","connectionType":"ai_languageModel"},{"fromNode":"GPT4 Model 2","toNode":"Work out activity type and number of people","connectionType":"ai_languageModel"},{"fromNode":"GPT4 Model 3","toNode":"Auto-fixing Output Parser","connectionType":"ai_languageModel"},{"fromNode":"Structure as JSON","toNode":"Auto-fixing Output Parser","connectionType":"ai_outputParser"},{"fromNode":"Call the API","toNode":"Set 'response' value","connectionType":"main"},{"fromNode":"Work out activity type and number of people","toNode":"Call the API","connectionType":"main"}]

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

properties_schema:
  [{"displayName":"Resource","name":"resource","type":"options","default":"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.","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."}]},{"name":"dynamic_property","type":"unknown","displayName":"Dynamic Property","_source":"...TaskDescription_1.taskOperations"},{"name":"dynamic_property","type":"unknown","displayName":"Dynamic Property","_source":"...TaskDescription_1.taskFields"}]


node_type: n8n-nodes-base.Function
name: Function
display_name: Function
category: transform
icon: fa:code
code_hash: d68f1ab94b190161e2ec2c56ec6631f6c3992826557c100ec578efff5de96a70
example_parameters: {"notice":null,"functionCode":"`// Code here will run only once"}
package_name: n8n-nodes-base
version: 1.0
extracted_at: 2025-06-12 08:58:34
updated_at: 2025-06-12 08:58:34
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":{"notice":null,"functionCode":"`// Code here will run only once"},"id":"fqjfx6bosw6yd8l8wvgzwf","name":"Function","type":"n8n-nodes-base.exampleNode","typeVersion":1,"position":[250,300]}],"connections":{},"active":false,"settings":{},"tags":["example","generated"]}

properties_schema:
  [{"displayName":"A newer version of this node type is available, called the ‘Code’ node","name":"notice","type":"notice","default":""},{"displayName":"JavaScript Code","name":"functionCode","type":"string","default":"`// Code here will run only once","description":"The JavaScript code to execute"}]


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
package_name: n8n-nodes-base
version: 1.0
extracted_at: 2025-06-12 08:58:34
updated_at: 2025-06-12 08:58:34
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":{"notice":null,"functionCode":"`// Code here will run once per input item.\n// More info and help: https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.functionitem/\n// Tip: You can use luxon for dates and $jmespath for querying JSON structures\n\n// Add a new field called 'myNewField' to the JSON of the item\nitem.myNewField = 1;\n\n// You can write logs to the browser console\nconsole.log('Done!');\n\nreturn item;`"},"id":"2n1ou8qju3mu95ga5uu9mm","name":"Function Item","type":"n8n-nodes-base.exampleNode","typeVersion":1,"position":[250,300]}],"connections":{},"active":false,"settings":{},"tags":["example","generated"]}

example_parameters:
  {"notice":null,"functionCode":"`// Code here will run once per input item.\n// More info and help: https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.functionitem/\n// Tip: You can use luxon for dates and $jmespath for querying JSON structures\n\n// Add a new field called 'myNewField' to the JSON of the item\nitem.myNewField = 1;\n\n// You can write logs to the browser console\nconsole.log('Done!');\n\nreturn item;`"}

properties_schema:
  [{"displayName":"A newer version of this node type is available, called the ‘Code’ node","name":"notice","type":"notice","default":""},{"displayName":"JavaScript Code","name":"functionCode","type":"string","default":"`// Code here will run once per input item.\n// More info and help: https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.functionitem/\n// Tip: You can use luxon for dates and $jmespath for querying JSON structures\n\n// Add a new field called 'myNewField' to the JSON of the item\nitem.myNewField = 1;\n\n// You can write logs to the browser console\nconsole.log('Done!');\n\nreturn item;`","description":"The JavaScript code to execute for each item"}]


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: []
parameter_schemas: []
troubleshooting_info: []
example_parameters: {"resource":"account","dynamic_property":null}
package_name: n8n-nodes-base
version: 1.0
extracted_at: 2025-06-12 08:58:34
updated_at: 2025-06-12 08:58:34
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":{"resource":"account","dynamic_property":null},"id":"k460le1udnpmff1dpyt89j","name":"Freshworks CRM","type":"n8n-nodes-base.exampleNode","typeVersion":1,"position":[250,300]}],"connections":{},"active":false,"settings":{},"tags":["example","generated"]}

properties_schema:
  [{"displayName":"Resource","name":"resource","type":"options","default":"account","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"}]},{"name":"dynamic_property","type":"unknown","displayName":"Dynamic Property","_source":"...descriptions_1.accountOperations"},{"name":"dynamic_property","type":"unknown","displayName":"Dynamic Property","_source":"...descriptions_1.accountFields"},{"name":"dynamic_property","type":"unknown","displayName":"Dynamic Property","_source":"...descriptions_1.appointmentOperations"},{"name":"dynamic_property","type":"unknown","displayName":"Dynamic Property","_source":"...descriptions_1.appointmentFields"},{"name":"dynamic_property","type":"unknown","displayName":"Dynamic Property","_source":"...descriptions_1.contactOperations"},{"name":"dynamic_property","type":"unknown","displayName":"Dynamic Property","_source":"...descriptions_1.contactFields"},{"name":"dynamic_property","type":"unknown","displayName":"Dynamic Property","_source":"...descriptions_1.dealOperations"},{"name":"dynamic_property","type":"unknown","displayName":"Dynamic Property","_source":"...descriptions_1.dealFields"},{"name":"dynamic_property","type":"unknown","displayName":"Dynamic Property","_source":"...descriptions_1.noteOperations"},{"name":"dynamic_property","type":"unknown","displayName":"Dynamic Property","_source":"...descriptions_1.noteFields"},{"name":"dynamic_property","type":"unknown","displayName":"Dynamic Property","_source":"...descriptions_1.salesActivityOperations"},{"name":"dynamic_property","type":"unknown","displayName":"Dynamic Property","_source":"...descriptions_1.salesActivityFields"},{"name":"dynamic_property","type":"unknown","displayName":"Dynamic Property","_source":"...descriptions_1.searchOperations"},{"name":"dynamic_property","type":"unknown","displayName":"Dynamic Property","_source":"...descriptions_1.searchFields"},{"name":"dynamic_property","type":"unknown","displayName":"Dynamic Property","_source":"...descriptions_1.taskOperations"},{"name":"dynamic_property","type":"unknown","displayName":"Dynamic Property","_source":"...descriptions_1.taskFields"}]


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: []
parameter_schemas: []
troubleshooting_info: []
example_parameters: {"resource":"agent","dynamic_property":null}
package_name: n8n-nodes-base
version: 1.0
extracted_at: 2025-06-12 08:58:34
updated_at: 2025-06-12 08:58:34
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":{"resource":"agent","dynamic_property":null},"id":"wlh9i2hqc9evy07x1wwsnl","name":"Freshservice","type":"n8n-nodes-base.exampleNode","typeVersion":1,"position":[250,300]}],"connections":{},"active":false,"settings":{},"tags":["example","generated"]}

properties_schema:
  [{"displayName":"Resource","name":"resource","type":"options","default":"agent","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"}]},{"name":"dynamic_property","type":"unknown","displayName":"Dynamic Property","_source":"...descriptions_1.agentOperations"},{"name":"dynamic_property","type":"unknown","displayName":"Dynamic Property","_source":"...descriptions_1.agentFields"},{"name":"dynamic_property","type":"unknown","displayName":"Dynamic Property","_source":"...descriptions_1.agentGroupOperations"},{"name":"dynamic_property","type":"unknown","displayName":"Dynamic Property","_source":"...descriptions_1.agentGroupFields"},{"name":"dynamic_property","type":"unknown","displayName":"Dynamic Property","_source":"...descriptions_1.agentRoleOperations"},{"name":"dynamic_property","type":"unknown","displayName":"Dynamic Property","_source":"...descriptions_1.agentRoleFields"},{"name":"dynamic_property","type":"unknown","displayName":"Dynamic Property","_source":"...descriptions_1.announcementOperations"},{"name":"dynamic_property","type":"unknown","displayName":"Dynamic Property","_source":"...descriptions_1.announcementFields"},{"name":"dynamic_property","type":"unknown","displayName":"Dynamic Property","_source":"...descriptions_1.assetTypeOperations"},{"name":"dynamic_property","type":"unknown","displayName":"Dynamic Property","_source":"...descriptions_1.assetTypeFields"},{"name":"dynamic_property","type":"unknown","displayName":"Dynamic Property","_source":"...descriptions_1.changeOperations"},{"name":"dynamic_property","type":"unknown","displayName":"Dynamic Property","_source":"...descriptions_1.changeFields"},{"name":"dynamic_property","type":"unknown","displayName":"Dynamic Property","_source":"...descriptions_1.departmentOperations"},{"name":"dynamic_property","type":"unknown","displayName":"Dynamic Property","_source":"...descriptions_1.departmentFields"},{"name":"dynamic_property","type":"unknown","displayName":"Dynamic Property","_source":"...descriptions_1.locationOperations"},{"name":"dynamic_property","type":"unknown","displayName":"Dynamic Property","_source":"...descriptions_1.locationFields"},{"name":"dynamic_property","type":"unknown","displayName":"Dynamic Property","_source":"...descriptions_1.problemOperations"},{"name":"dynamic_property","type":"unknown","displayName":"Dynamic Property","_source":"...descriptions_1.problemFields"},{"name":"dynamic_property","type":"unknown","displayName":"Dynamic Property","_source":"...descriptions_1.productOperations"},{"name":"dynamic_property","type":"unknown","displayName":"Dynamic Property","_source":"...descriptions_1.productFields"},{"name":"dynamic_property","type":"unknown","displayName":"Dynamic Property","_source":"...descriptions_1.releaseOperations"},{"name":"dynamic_property","type":"unknown","displayName":"Dynamic Property","_source":"...descriptions_1.releaseFields"},{"name":"dynamic_property","type":"unknown","displayName":"Dynamic Property","_source":"...descriptions_1.requesterOperations"},{"name":"dynamic_property","type":"unknown","displayName":"Dynamic Property","_source":"...descriptions_1.requesterFields"},{"name":"dynamic_property","type":"unknown","displayName":"Dynamic Property","_source":"...descriptions_1.requesterGroupOperations"},{"name":"dynamic_property","type":"unknown","displayName":"Dynamic Property","_source":"...descriptions_1.requesterGroupFields"},{"name":"dynamic_property","type":"unknown","displayName":"Dynamic Property","_source":"...descriptions_1.softwareOperations"},{"name":"dynamic_property","type":"unknown","displayName":"Dynamic Property","_source":"...descriptions_1.softwareFields"},{"name":"dynamic_property","type":"unknown","displayName":"Dynamic Property","_source":"...descriptions_1.ticketOperations"},{"name":"dynamic_property","type":"unknown","displayName":"Dynamic Property","_source":"...descriptions_1.ticketFields"}]


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: []
parameter_schemas: []
troubleshooting_info: []
package_name: n8n-nodes-base
version: 1.0
extracted_at: 2025-06-12 08:58:34
updated_at: 2025-06-12 08:58:34
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":{"resource":"contact","operation":"create","requester":"email","requesterIdentificationValue":"example-value","status":"closed","priority":"low","source":"chat","options":{},"ticketId":"example-value","updateFields":{},"returnAll":false,"limit":5,"dynamic_property":null},"id":"ov7avtwsuu7gze9dyvk0u","name":"Freshdesk","type":"n8n-nodes-base.exampleNode","typeVersion":1,"position":[250,300]}],"connections":{},"active":false,"settings":{},"tags":["example","generated"]}

example_parameters:
  {"resource":"contact","operation":"create","requester":"email","requesterIdentificationValue":"example-value","status":"closed","priority":"low","source":"chat","options":{},"ticketId":"example-value","updateFields":{},"returnAll":false,"limit":5,"dynamic_property":null}

properties_schema:
  [{"displayName":"Resource","name":"resource","type":"options","default":"ticket","required":true,"options":[{"name":"Contact","value":"contact"},{"name":"Ticket","value":"ticket"}]},{"displayName":"Operation","name":"operation","type":"options","default":"create","required":true,"description":"Create a new ticket","options":[{"name":"Create","value":"create","description":"Create a new ticket"},{"name":"Delete","value":"delete","description":"Delete a ticket"},{"name":"Get","value":"get","description":"Get a ticket"},{"name":"Get Many","value":"getAll","description":"Get many tickets"},{"name":"Update","value":"update","description":"Update a ticket"}]},{"displayName":"Requester Identification","name":"requester","type":"options","default":"requesterId","required":true,"description":"Email address of the requester. If no contact exists with this email address in Freshdesk, it will be added as a new contact.","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"},{"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."}]},{"displayName":"Value","name":"requesterIdentificationValue","type":"string","default":"","required":true,"description":"Value of the identification selected"},{"displayName":"Status","name":"status","type":"options","default":"pending","required":true,"options":[{"name":"Closed","value":"closed"},{"name":"Open","value":"open"},{"name":"Pending","value":"pending"},{"name":"Resolved","value":"resolved"}]},{"displayName":"Priority","name":"priority","type":"options","default":"low","required":true,"options":[{"name":"Low","value":"low"},{"name":"Medium","value":"medium"},{"name":"High","value":"high"},{"name":"Urgent","value":"urgent"}]},{"displayName":"Source","name":"source","type":"options","default":"portal","required":true,"description":"The channel through which the ticket was created","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"}]},{"displayName":"Options","name":"options","type":"collection","default":"{","description":"ID of the agent to whom the ticket has been assigned. Choose from the list, or specify an ID using an <a href=","placeholder":"Add Option"},{"displayName":"Ticket ID","name":"ticketId","type":"string","default":"","required":true},{"displayName":"Update Fields","name":"updateFields","type":"collection","default":"{","description":"ID of the agent to whom the ticket has been assigned. Choose from the list, or specify an ID using an <a href=","placeholder":"Add Field"},{"displayName":"Ticket ID","name":"ticketId","type":"string","default":"","required":true},{"displayName":"Return All","name":"returnAll","type":"boolean","default":false,"description":"Whether to return all results or only up to a given limit"},{"displayName":"Limit","name":"limit","type":"number","default":5,"description":"Max number of results to return"},{"displayName":"Options","name":"options","type":"collection","default":"{","description":"Order sort attribute ascending or descending","placeholder":"Add Option"},{"displayName":"Ticket ID","name":"ticketId","type":"string","default":"","required":true},{"name":"dynamic_property","type":"unknown","displayName":"Dynamic Property","_source":"...ContactDescription_1.contactOperations"},{"name":"dynamic_property","type":"unknown","displayName":"Dynamic Property","_source":"...ContactDescription_1.contactFields"}]


node_type: n8n-nodes-base.Ftp
name: Ftp
display_name: FTP
description: Transfers files via FTP or SFTP
category: input
icon: fa:server
code_hash: 48e8e0ee75c7e8ba39f526f5a690b1bcc679c5852a93609ddd264fd68ced6e92
package_name: n8n-nodes-base
version: 1.0
extracted_at: 2025-06-12 08:58:34
updated_at: 2025-06-12 08:58:34
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.Ftp = void 0;
  const n8n_workflow_1 = require("n8n-workflow");
  const utilities_1 = require("../../utils/utilities");
  const fs_1 = require("fs");
  const path_1 = require("path");
  const stream_1 = require("stream");
  const util_1 = require("util");
  const tmp_promise_1 = require("tmp-promise");
  const promise_ftp_1 = __importDefault(require("promise-ftp"));
  const ssh2_sftp_client_1 = __importDefault(require("ssh2-sftp-client"));
  const streamPipeline = (0, util_1.promisify)(stream_1.pipeline);
  async function callRecursiveList(path, client, normalizeFunction) {
      const pathArray = [path];
      let currentPath = path;
      const directoryItems = [];
      let index = 0;
      const prepareAndNormalize = (item) => {
          if (pathArray[index].endsWith('/')) {
              currentPath = `${pathArray[index]}${item.name}`;
          }
          else {
              currentPath = `${pathArray[index]}/${item.name}`;
          }
          if (item.type === 'd') {
              if (item.name === '.' || item.name === '..') {
                  return;
              }
              pathArray.push(currentPath);
          }
          normalizeFunction(item, currentPath, true);
          directoryItems.push(item);
      };
      do {
          const returnData = await client.list(pathArray[index]);
          returnData.map(prepareAndNormalize);
          index++;
      } while (index <= pathArray.length - 1);
      return directoryItems;
  }
  async function recursivelyCreateSftpDirs(sftp, path) {
      const dirPath = (0, path_1.dirname)(path);
      const dirExists = await sftp.exists(dirPath);
      if (!dirExists) {
          await sftp.mkdir(dirPath, true);
      }
  }
  function normalizeSFtpItem(input, path, recursive = false) {
      const item = input;
      item.accessTime = new Date(input.accessTime);
      item.modifyTime = new Date(input.modifyTime);
      item.path = !recursive ? `${path}${path.endsWith('/') ? '' : '/'}${item.name}` : path;
  }
  function normalizeFtpItem(input, path, recursive = false) {
      const item = input;
      item.modifyTime = input.date;
      item.path = !recursive ? `${path}${path.endsWith('/') ? '' : '/'}${item.name}` : path;
      item.date = undefined;
  }
  class Ftp {
      constructor() {
          this.description = {
              displayName: 'FTP',
              name: 'ftp',
              icon: 'fa:server',
              group: ['input'],
              version: 1,
              subtitle: '={{$parameter["protocol"] + ": " + $parameter["operation"]}}',
              description: 'Transfers files via FTP or SFTP',
              defaults: {
                  name: 'FTP',
                  color: '#303050',
              },
              inputs: ['main'],
              outputs: ['main'],
              credentials: [
                  {
                      name: 'ftp',
                      required: true,
                      displayOptions: {
                          show: {
                              protocol: ['ftp'],
                          },
                      },
                      testedBy: 'ftpConnectionTest',
                  },
                  {
                      name: 'sftp',
                      required: true,
                      displayOptions: {
                          show: {
                              protocol: ['sftp'],
                          },
                      },
                      testedBy: 'sftpConnectionTest',
                  },
              ],
              properties: [
                  {
                      displayName: 'Protocol',
                      name: 'protocol',
                      type: 'options',
                      options: [
                          {
                              name: 'FTP',
                              value: 'ftp',
                          },
                          {
                              name: 'SFTP',
                              value: 'sftp',
                          },
                      ],
                      default: 'ftp',
                      description: 'File transfer protocol',
                  },
                  {
                      displayName: 'Operation',
                      name: 'operation',
                      type: 'options',
                      options: [
                          {
                              name: 'Delete',
                              value: 'delete',
                              description: 'Delete a file/folder',
                              action: 'Delete a file or folder',
                          },
                          {
                              name: 'Download',
                              value: 'download',
                              description: 'Download a file',
                              action: 'Download a file',
                          },
                          {
                              name: 'List',
                              value: 'list',
                              description: 'List folder content',
                              action: 'List folder content',
                          },
                          {
                              name: 'Rename',
                              value: 'rename',
                              description: 'Rename/move oldPath to newPath',
                              action: 'Rename / move a file or folder',
                          },
                          {
                              name: 'Upload',
                              value: 'upload',
                              description: 'Upload a file',
                              action: 'Upload a file',
                          },
                      ],
                      default: 'download',
                      noDataExpression: true,
                  },
                  {
                      displayName: 'Path',
                      displayOptions: {
                          show: {
                              operation: ['delete'],
                          },
                      },
                      name: 'path',
                      type: 'string',
                      default: '',
                      description: 'The file path of the file to delete. Has to contain the full path.',
                      required: true,
                  },
                  {
                      displayName: 'Options',
                      name: 'options',
                      type: 'collection',
                      placeholder: 'Add Option',
                      displayOptions: {
                          show: {
                              operation: ['delete'],
                          },
                      },
                      default: {},
                      options: [
                          {
                              displayName: 'Folder',
                              name: 'folder',
                              type: 'boolean',
                              default: false,
                              description: 'Whether folders can be deleted',
                          },
                          {
                              displayName: 'Recursive',
                              displayOptions: {
                                  show: {
                                      folder: [true],
                                  },
                              },
                              name: 'recursive',
                              type: 'boolean',
                              default: false,
                              description: 'Whether to remove all files and directories in target directory',
                          },
                      ],
                  },
                  {
                      displayName: 'Path',
                      displayOptions: {
                          show: {
                              operation: ['download'],
                          },
                      },
                      name: 'path',
                      type: 'string',
                      default: '',
                      placeholder: '/documents/invoice.txt',
                      description: 'The file path of the file to download. Has to contain the full path.',
                      required: true,
                  },
                  {
                      displayName: 'Binary Property',
                      displayOptions: {
                          show: {
                              operation: ['download'],
                          },
                      },
                      name: 'binaryPropertyName',
                      type: 'string',
                      default: 'data',
                      description: 'Object property name which holds binary data',
                      required: true,
                  },
                  {
                      displayName: 'Old Path',
                      displayOptions: {
                          show: {
                              operation: ['rename'],
                          },
                      },
                      name: 'oldPath',
                      type: 'string',
                      default: '',
                      required: true,
                  },
                  {
                      displayName: 'New Path',
                      displayOptions: {
                          show: {
                              operation: ['rename'],
                          },
                      },
                      name: 'newPath',
                      type: 'string',
                      default: '',
                      required: true,
                  },
                  {
                      displayName: 'Options',
                      name: 'options',
                      type: 'collection',
                      placeholder: 'Add Field',
                      default: {},
                      displayOptions: {
                          show: {
                              operation: ['rename'],
                          },
                      },
                      options: [
                          {
                              displayName: 'Create Directories',
                              name: 'createDirectories',
                              type: 'boolean',
                              default: false,
                              description: 'Whether to recursively create destination directory when renaming an existing file or folder',
                          },
                      ],
                  },
                  {
                      displayName: 'Path',
                      displayOptions: {
                          show: {
                              operation: ['upload'],
                          },
                      },
                      name: 'path',
                      type: 'string',
                      default: '',
                      description: 'The file path of the file to upload. Has to contain the full path.',
                      required: true,
                  },
                  {
                      displayName: 'Binary Data',
                      displayOptions: {
                          show: {
                              operation: ['upload'],
                          },
                      },
                      name: 'binaryData',
                      type: 'boolean',
                      default: true,
                      description: 'The text content of the file to upload',
                  },
                  {
                      displayName: 'Binary Property',
                      displayOptions: {
                          show: {
                              operation: ['upload'],
                              binaryData: [true],
                          },
                      },
                      name: 'binaryPropertyName',
                      type: 'string',
                      default: 'data',
                      description: 'Object property name which holds binary data',
                      required: true,
                  },
                  {
                      displayName: 'File Content',
                      displayOptions: {
                          show: {
                              operation: ['upload'],
                              binaryData: [false],
                          },
                      },
                      name: 'fileContent',
                      type: 'string',
                      default: '',
                      description: 'The text content of the file to upload',
                  },
                  {
                      displayName: 'Path',
                      displayOptions: {
                          show: {
                              operation: ['list'],
                          },
                      },
                      name: 'path',
                      type: 'string',
                      default: '/',
                      description: 'Path of directory to list contents of',
                      required: true,
                  },
                  {
                      displayName: 'Recursive',
                      displayOptions: {
                          show: {
                              operation: ['list'],
                          },
                      },
                      name: 'recursive',
                      type: 'boolean',
                      default: false,
                      description: 'Whether to return object representing all directories / objects recursively found within SFTP server',
                      required: true,
                  },
              ],
          };
          this.methods = {
              credentialTest: {
                  async ftpConnectionTest(credential) {
                      const credentials = credential.data;
                      try {
                          const ftp = new promise_ftp_1.default();
                          await ftp.connect({
                              host: credentials.host,
                              port: credentials.port,
                              user: credentials.username,
                              password: credentials.password,
                          });
                      }
                      catch (error) {
                          return {
                              status: 'Error',
                              message: error.message,
                          };
                      }
                      return {
                          status: 'OK',
                          message: 'Connection successful!',
                      };
                  },
                  async sftpConnectionTest(credential) {
                      const credentials = credential.data;
                      try {
                          const sftp = new ssh2_sftp_client_1.default();
                          if (credentials.privateKey) {
                              await sftp.connect({
                                  host: credentials.host,
                                  port: credentials.port,
                                  username: credentials.username,
                                  privateKey: (0, utilities_1.formatPrivateKey)(credentials.privateKey),
                                  passphrase: credentials.passphrase,
                              });
                          }
                          else {
                              await sftp.connect({
                                  host: credentials.host,
                                  port: credentials.port,
                                  username: credentials.username,
                                  password: credentials.password,
                              });
                          }
                      }
                      catch (error) {
                          return {
                              status: 'Error',
                              message: error.message,
                          };
                      }
                      return {
                          status: 'OK',
                          message: 'Connection successful!',
                      };
                  },
              },
          };
      }
      async execute() {
          const items = this.getInputData();
          const returnItems = [];
          let responseData;
          const operation = this.getNodeParameter('operation', 0);
          let credentials = undefined;
          const protocol = this.getNodeParameter('protocol', 0);
          if (protocol === 'sftp') {
              credentials = await this.getCredentials('sftp');
          }
          else {
              credentials = await this.getCredentials('ftp');
          }
          try {
              let ftp;
              let sftp;
              if (protocol === 'sftp') {
                  sftp = new ssh2_sftp_client_1.default();
                  if (credentials.privateKey) {
                      await sftp.connect({
                          host: credentials.host,
                          port: credentials.port,
                          username: credentials.username,
                          privateKey: (0, utilities_1.formatPrivateKey)(credentials.privateKey),
                          passphrase: credentials.passphrase,
                      });
                  }
                  else {
                      await sftp.connect({
                          host: credentials.host,
                          port: credentials.port,
                          username: credentials.username,
                          password: credentials.password,
                      });
                  }
              }
              else {
                  ftp = new promise_ftp_1.default();
                  await ftp.connect({
                      host: credentials.host,
                      port: credentials.port,
                      user: credentials.username,
                      password: credentials.password,
                  });
              }
              for (let i = 0; i < items.length; i++) {
                  const newItem = {
                      json: items[i].json,
                      binary: {},
                  };
                  if (items[i].binary !== undefined && newItem.binary) {
                      Object.assign(newItem.binary, items[i].binary);
                  }
                  items[i] = newItem;
                  if (protocol === 'sftp') {
                      if (operation === 'list') {
                          const path = this.getNodeParameter('path', i);
                          const recursive = this.getNodeParameter('recursive', i);
                          if (recursive) {
                              responseData = await callRecursiveList(path, sftp, normalizeSFtpItem);
                              const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
                              returnItems.push.apply(returnItems, executionData);
                          }
                          else {
                              responseData = await sftp.list(path);
                              responseData.forEach((item) => normalizeSFtpItem(item, path));
                              const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
                              returnItems.push.apply(returnItems, executionData);
                          }
                      }
                      if (operation === 'delete') {
                          const path = this.getNodeParameter('path', i);
                          const options = this.getNodeParameter('options', i);
                          if (options.folder === true) {
                              responseData = await sftp.rmdir(path, !!options.recursive);
                          }
                          else {
                              responseData = await sftp.delete(path);
                          }
                          const executionData = this.helpers.constructExecutionMetaData([{ json: { success: true } }], { itemData: { item: i } });
                          returnItems.push(...executionData);
                      }
                      if (operation === 'rename') {
                          const oldPath = this.getNodeParameter('oldPath', i);
                          const { createDirectories = false } = this.getNodeParameter('options', i);
                          const newPath = this.getNodeParameter('newPath', i);
                          if (createDirectories) {
                              await recursivelyCreateSftpDirs(sftp, newPath);
                          }
                          responseData = await sftp.rename(oldPath, newPath);
                          const executionData = this.helpers.constructExecutionMetaData([{ json: { success: true } }], { itemData: { item: i } });
                          returnItems.push(...executionData);
                      }
                      if (operation === 'download') {
                          const path = this.getNodeParameter('path', i);
                          const binaryFile = await (0, tmp_promise_1.file)({ prefix: 'n8n-sftp-' });
                          try {
                              await sftp.get(path, (0, fs_1.createWriteStream)(binaryFile.path));
                              const dataPropertyNameDownload = this.getNodeParameter('binaryPropertyName', i);
                              const remoteFilePath = this.getNodeParameter('path', i);
                              items[i].binary[dataPropertyNameDownload] = await this.nodeHelpers.copyBinaryFile(binaryFile.path, (0, path_1.basename)(remoteFilePath));
                              const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(items[i]), { itemData: { item: i } });
                              returnItems.push(...executionData);
                          }
                          finally {
                              await binaryFile.cleanup();
                          }
                      }
                      if (operation === 'upload') {
                          const remotePath = this.getNodeParameter('path', i);
                          await recursivelyCreateSftpDirs(sftp, remotePath);
                          if (this.getNodeParameter('binaryData', i)) {
                              const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
                              const binaryData = this.helpers.assertBinaryData(i, binaryPropertyName);
                              let uploadData;
                              if (binaryData.id) {
                                  uploadData = await this.helpers.getBinaryStream(binaryData.id);
                              }
                              else {
                                  uploadData = Buffer.from(binaryData.data, n8n_workflow_1.BINARY_ENCODING);
                              }
                              await sftp.put(uploadData, remotePath);
                          }
                          else {
                              const buffer = Buffer.from(this.getNodeParameter('fileContent', i), 'utf8');
                              await sftp.put(buffer, remotePath);
                          }
                          const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(items[i]), { itemData: { item: i } });
                          returnItems.push(...executionData);
                      }
                  }
                  if (protocol === 'ftp') {
                      if (operation === 'list') {
                          const path = this.getNodeParameter('path', i);
                          const recursive = this.getNodeParameter('recursive', i);
                          if (recursive) {
                              responseData = await callRecursiveList(path, ftp, normalizeFtpItem);
                              const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
                              returnItems.push.apply(returnItems, executionData);
                          }
                          else {
                              responseData = await ftp.list(path);
                              responseData.forEach((item) => normalizeFtpItem(item, path));
                              const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
                              returnItems.push.apply(returnItems, executionData);
                          }
                      }
                      if (operation === 'delete') {
                          const path = this.getNodeParameter('path', i);
                          const options = this.getNodeParameter('options', i);
                          if (options.folder === true) {
                              responseData = await ftp.rmdir(path, !!options.recursive);
                          }
                          else {
                              responseData = await ftp.delete(path);
                          }
                          const executionData = this.helpers.constructExecutionMetaData([{ json: { success: true } }], { itemData: { item: i } });
                          returnItems.push(...executionData);
                      }
                      if (operation === 'download') {
                          const path = this.getNodeParameter('path', i);
                          const binaryFile = await (0, tmp_promise_1.file)({ prefix: 'n8n-sftp-' });
                          try {
                              const stream = await ftp.get(path);
                              await streamPipeline(stream, (0, fs_1.createWriteStream)(binaryFile.path));
                              const dataPropertyNameDownload = this.getNodeParameter('binaryPropertyName', i);
                              const remoteFilePath = this.getNodeParameter('path', i);
                              items[i].binary[dataPropertyNameDownload] = await this.nodeHelpers.copyBinaryFile(binaryFile.path, (0, path_1.basename)(remoteFilePath));
                              const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(items[i]), { itemData: { item: i } });
                              returnItems.push(...executionData);
                          }
                          finally {
                              await binaryFile.cleanup();
                          }
                      }
                      if (operation === 'rename') {
                          const oldPath = this.getNodeParameter('oldPath', i);
                          const newPath = this.getNodeParameter('newPath', i);
                          responseData = await ftp.rename(oldPath, newPath);
                          const executionData = this.helpers.constructExecutionMetaData([{ json: { success: true } }], { itemData: { item: i } });
                          returnItems.push(...executionData);
                      }
                      if (operation === 'upload') {
                          const remotePath = this.getNodeParameter('path', i);
                          const fileName = (0, path_1.basename)(remotePath);
                          const dirPath = remotePath.replace(fileName, '');
                          if (this.getNodeParameter('binaryData', i)) {
                              const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
                              const binaryData = this.helpers.assertBinaryData(i, binaryPropertyName);
                              let uploadData;
                              if (binaryData.id) {
                                  uploadData = await this.helpers.getBinaryStream(binaryData.id);
                              }
                              else {
                                  uploadData = Buffer.from(binaryData.data, n8n_workflow_1.BINARY_ENCODING);
                              }
                              try {
                                  await ftp.put(uploadData, remotePath);
                              }
                              catch (error) {
                                  if (error.code === 553) {
                                      await ftp.mkdir(dirPath, true);
                                      await ftp.put(uploadData, remotePath);
                                  }
                                  else {
                                      throw new n8n_workflow_1.NodeApiError(this.getNode(), error);
                                  }
                              }
                          }
                          else {
                              const buffer = Buffer.from(this.getNodeParameter('fileContent', i), 'utf8');
                              try {
                                  await ftp.put(buffer, remotePath);
                              }
                              catch (error) {
                                  if (error.code === 553) {
                                      await ftp.mkdir(dirPath, true);
                                      await ftp.put(buffer, remotePath);
                                  }
                                  else {
                                      throw new n8n_workflow_1.NodeApiError(this.getNode(), error);
                                  }
                              }
                          }
                          const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(items[i]), { itemData: { item: i } });
                          returnItems.push(...executionData);
                      }
                  }
              }
              if (protocol === 'sftp') {
                  await sftp.end();
              }
              else {
                  await ftp.end();
              }
          }
          catch (error) {
              if (this.continueOnFail()) {
                  return [[{ json: { error: error.message } }]];
              }
              throw error;
          }
          return [returnItems];
      }
  }
  exports.Ftp = Ftp;
  //# sourceMappingURL=Ftp.node.js.map

example_workflow:
  {"name":"FTP Example Workflow","nodes":[{"parameters":{"protocol":"ftp","operation":"delete","path":"/","options":{},"binaryPropertyName":"Example Name","oldPath":"example-value","newPath":"example-value","binaryData":true,"fileContent":"example-value","recursive":false},"id":"m5r8q0mxmesrhzp495zao","name":"FTP","type":"n8n-nodes-base.exampleNode","typeVersion":1,"position":[250,300]}],"connections":{},"active":false,"settings":{},"tags":["example","generated"]}

example_parameters:
  {"protocol":"ftp","operation":"delete","path":"/","options":{},"binaryPropertyName":"Example Name","oldPath":"example-value","newPath":"example-value","binaryData":true,"fileContent":"example-value","recursive":false}

properties_schema:
  [{"displayName":"Protocol","name":"protocol","type":"options","default":"ftp","description":"File transfer protocol","options":[{"name":"FTP","value":"ftp"},{"name":"SFTP","value":"sftp"}]},{"displayName":"Operation","name":"operation","type":"options","default":"download","description":"Delete a file/folder","options":[{"name":"Delete","value":"delete","description":"Delete a file/folder"},{"name":"Download","value":"download","description":"Download a file"},{"name":"List","value":"list","description":"List folder content"},{"name":"Rename","value":"rename","description":"Rename/move oldPath to newPath"},{"name":"Upload","value":"upload","description":"Upload a file"}]},{"displayName":"Path","name":"path","type":"string","default":"","required":true,"description":"The file path of the file to delete. Has to contain the full path."},{"displayName":"Options","name":"options","type":"collection","default":"{","description":"Whether folders can be deleted","placeholder":"Add Option"},{"displayName":"Path","name":"path","type":"string","default":"","required":true,"description":"The file path of the file to download. Has to contain the full path.","placeholder":"/documents/invoice.txt"},{"displayName":"Binary Property","name":"binaryPropertyName","type":"string","default":"data","required":true,"description":"Object property name which holds binary data"},{"displayName":"Old Path","name":"oldPath","type":"string","default":"","required":true},{"displayName":"New Path","name":"newPath","type":"string","default":"","required":true},{"displayName":"Options","name":"options","type":"collection","default":"{","description":"Whether to recursively create destination directory when renaming an existing file or folder","placeholder":"Add Field"},{"displayName":"Path","name":"path","type":"string","default":"","required":true,"description":"The file path of the file to upload. Has to contain the full path."},{"displayName":"Binary Data","name":"binaryData","type":"boolean","default":true,"description":"The text content of the file to upload"},{"displayName":"Binary Property","name":"binaryPropertyName","type":"string","default":"data","required":true,"description":"Object property name which holds binary data"},{"displayName":"File Content","name":"fileContent","type":"string","default":"","description":"The text content of the file to upload"},{"displayName":"Path","name":"path","type":"string","default":"/","required":true,"description":"Path of directory to list contents of"},{"displayName":"Recursive","name":"recursive","type":"boolean","default":false,"required":true,"description":"Whether to return object representing all directories / objects recursively found within SFTP server"}]


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: []
parameter_schemas: []
troubleshooting_info: []
example_parameters: {"authentication":"apiKey","resource":"contact","dynamic_property":null}
package_name: n8n-nodes-base
version: 1.0
extracted_at: 2025-06-12 08:58:34
updated_at: 2025-06-12 08:58:34
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":{"authentication":"apiKey","resource":"contact","dynamic_property":null},"id":"n9pvb36a3yeseav1w4m35j","name":"GetResponse","type":"n8n-nodes-base.exampleNode","typeVersion":1,"position":[250,300]}],"connections":{},"active":false,"settings":{},"tags":["example","generated"]}

properties_schema:
  [{"displayName":"Authentication","name":"authentication","type":"options","default":"apiKey","options":[{"name":"API Key","value":"apiKey"},{"name":"OAuth2","value":"oAuth2"}]},{"displayName":"Resource","name":"resource","type":"options","default":"contact","options":[{"name":"Contact","value":"contact"}]},{"name":"dynamic_property","type":"unknown","displayName":"Dynamic Property","_source":"...ContactDescription_1.contactOperations"},{"name":"dynamic_property","type":"unknown","displayName":"Dynamic Property","_source":"...ContactDescription_1.contactFields"}]


node_type: n8n-nodes-base.Ghost
name: Ghost
display_name: Ghost
description: Consume Ghost API
category: input
icon: file:ghost.svg
code_hash: d71663706631c3fa7968cf9519d85bac19bdfb4b37d8043b0ed29130df735818
documentation_url: https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.Ghost
documentation_title: Ghost node documentation
api_methods: []
documentation_examples: []
templates: [{"name":"ghost","description":"Templates for ghost"}]
related_resources: []
required_scopes: []
parameter_schemas: []
example_parameters: {"source":"adminApi","resource":"post","dynamic_property":null}
package_name: n8n-nodes-base
version: 1.0
extracted_at: 2025-06-12 08:58:35
updated_at: 2025-06-12 08:58:35
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.Ghost = void 0;
  const n8n_workflow_1 = require("n8n-workflow");
  const GenericFunctions_1 = require("./GenericFunctions");
  const PostDescription_1 = require("./PostDescription");
  const moment_timezone_1 = __importDefault(require("moment-timezone"));
  class Ghost {
      constructor() {
          this.description = {
              displayName: 'Ghost',
              name: 'ghost',
              icon: 'file:ghost.svg',
              group: ['input'],
              version: 1,
              subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
              description: 'Consume Ghost API',
              defaults: {
                  name: 'Ghost',
              },
              inputs: ['main'],
              outputs: ['main'],
              credentials: [
                  {
                      name: 'ghostAdminApi',
                      required: true,
                      displayOptions: {
                          show: {
                              source: ['adminApi'],
                          },
                      },
                  },
                  {
                      name: 'ghostContentApi',
                      required: true,
                      displayOptions: {
                          show: {
                              source: ['contentApi'],
                          },
                      },
                  },
              ],
              properties: [
                  {
                      displayName: 'Source',
                      name: 'source',
                      type: 'options',
                      description: 'Pick where your data comes from, Content or Admin API',
                      options: [
                          {
                              name: 'Admin API',
                              value: 'adminApi',
                          },
                          {
                              name: 'Content API',
                              value: 'contentApi',
                          },
                      ],
                      default: 'contentApi',
                  },
                  {
                      displayName: 'Resource',
                      name: 'resource',
                      type: 'options',
                      options: [
                          {
                              name: 'Post',
                              value: 'post',
                          },
                      ],
                      noDataExpression: true,
                      default: 'post',
                  },
                  ...PostDescription_1.postOperations,
                  ...PostDescription_1.postFields,
              ],
          };
          this.methods = {
              loadOptions: {
                  async getAuthors() {
                      const returnData = [];
                      const users = await GenericFunctions_1.ghostApiRequestAllItems.call(this, 'users', 'GET', '/admin/users');
                      for (const user of users) {
                          returnData.push({
                              name: user.name,
                              value: user.id,
                          });
                      }
                      return returnData;
                  },
                  async getTags() {
                      const returnData = [];
                      const tags = await GenericFunctions_1.ghostApiRequestAllItems.call(this, 'tags', 'GET', '/admin/tags');
                      for (const tag of tags) {
                          returnData.push({
                              name: tag.name,
                              value: tag.name,
                          });
                      }
                      return returnData;
                  },
              },
          };
      }
      async execute() {
          const items = this.getInputData();
          const returnData = [];
          const length = items.length;
          const timezone = this.getTimezone();
          const qs = {};
          let responseData;
          const resource = this.getNodeParameter('resource', 0);
          const operation = this.getNodeParameter('operation', 0);
          const source = this.getNodeParameter('source', 0);
          for (let i = 0; i < length; i++) {
              try {
                  if (source === 'contentApi') {
                      if (resource === 'post') {
                          if (operation === 'get') {
                              const by = this.getNodeParameter('by', i);
                              const identifier = this.getNodeParameter('identifier', i);
                              const options = this.getNodeParameter('options', i);
                              Object.assign(qs, options);
                              let endpoint;
                              if (by === 'slug') {
                                  endpoint = `/content/posts/slug/${identifier}`;
                              }
                              else {
                                  endpoint = `/content/posts/${identifier}`;
                              }
                              responseData = await GenericFunctions_1.ghostApiRequest.call(this, 'GET', endpoint, {}, qs);
                              responseData = responseData.posts;
                          }
                          if (operation === 'getAll') {
                              const returnAll = this.getNodeParameter('returnAll', 0);
                              const options = this.getNodeParameter('options', i);
                              Object.assign(qs, options);
                              if (returnAll) {
                                  responseData = await GenericFunctions_1.ghostApiRequestAllItems.call(this, 'posts', 'GET', '/content/posts', {}, qs);
                              }
                              else {
                                  qs.limit = this.getNodeParameter('limit', 0);
                                  responseData = await GenericFunctions_1.ghostApiRequest.call(this, 'GET', '/content/posts', {}, qs);
                                  responseData = responseData.posts;
                              }
                          }
                      }
                  }
                  if (source === 'adminApi') {
                      if (resource === 'post') {
                          if (operation === 'create') {
                              const title = this.getNodeParameter('title', i);
                              const contentFormat = this.getNodeParameter('contentFormat', i);
                              const content = this.getNodeParameter('content', i);
                              const additionalFields = this.getNodeParameter('additionalFields', i);
                              const post = {
                                  title,
                              };
                              if (contentFormat === 'html') {
                                  post.html = content;
                                  qs.source = 'html';
                              }
                              else if (contentFormat === 'lexical') {
                                  const lexical = (0, GenericFunctions_1.validateJSON)(content);
                                  if (lexical === undefined) {
                                      throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Content must be a valid JSON', {
                                          itemIndex: i,
                                      });
                                  }
                                  post.lexical = content;
                              }
                              else {
                                  const mobileDoc = (0, GenericFunctions_1.validateJSON)(content);
                                  if (mobileDoc === undefined) {
                                      throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Content must be a valid JSON', {
                                          itemIndex: i,
                                      });
                                  }
                                  post.mobiledoc = content;
                              }
                              delete post.content;
                              Object.assign(post, additionalFields);
                              if (post.published_at) {
                                  post.published_at = moment_timezone_1.default.tz(post.published_at, timezone).utc().format();
                              }
                              if (post.status === 'scheduled' && post.published_at === undefined) {
                                  throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Published at must be define when status is scheduled', { itemIndex: i });
                              }
                              responseData = await GenericFunctions_1.ghostApiRequest.call(this, 'POST', '/admin/posts', { posts: [post] }, qs);
                              responseData = responseData.posts;
                          }
                          if (operation === 'delete') {
                              const postId = this.getNodeParameter('postId', i);
                              responseData = await GenericFunctions_1.ghostApiRequest.call(this, 'DELETE', `/admin/posts/${postId}`);
                          }
                          if (operation === 'get') {
                              const by = this.getNodeParameter('by', i);
                              const identifier = this.getNodeParameter('identifier', i);
                              const options = this.getNodeParameter('options', i);
                              Object.assign(qs, options);
                              let endpoint;
                              if (by === 'slug') {
                                  endpoint = `/admin/posts/slug/${identifier}`;
                              }
                              else {
                                  endpoint = `/admin/posts/${identifier}`;
                              }
                              responseData = await GenericFunctions_1.ghostApiRequest.call(this, 'GET', endpoint, {}, qs);
                              responseData = responseData.posts;
                          }
                          if (operation === 'getAll') {
                              const returnAll = this.getNodeParameter('returnAll', 0);
                              const options = this.getNodeParameter('options', i);
                              Object.assign(qs, options);
                              if (returnAll) {
                                  responseData = await GenericFunctions_1.ghostApiRequestAllItems.call(this, 'posts', 'GET', '/admin/posts', {}, qs);
                              }
                              else {
                                  qs.limit = this.getNodeParameter('limit', 0);
                                  responseData = await GenericFunctions_1.ghostApiRequest.call(this, 'GET', '/admin/posts', {}, qs);
                                  responseData = responseData.posts;
                              }
                          }
                          if (operation === 'update') {
                              const postId = this.getNodeParameter('postId', i);
                              const contentFormat = this.getNodeParameter('contentFormat', i);
                              const updateFields = this.getNodeParameter('updateFields', i);
                              const post = {};
                              if (contentFormat === 'html') {
                                  post.html = updateFields.content || '';
                                  qs.source = 'html';
                                  delete updateFields.content;
                              }
                              else if (contentFormat === 'lexical') {
                                  const lexical = (0, GenericFunctions_1.validateJSON)(updateFields.contentJson || undefined);
                                  if (lexical === undefined) {
                                      throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Content must be a valid JSON', {
                                          itemIndex: i,
                                      });
                                  }
                                  post.lexical = updateFields.contentJson;
                                  delete updateFields.contentJson;
                              }
                              else {
                                  const mobileDoc = (0, GenericFunctions_1.validateJSON)(updateFields.contentJson || undefined);
                                  if (mobileDoc === undefined) {
                                      throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Content must be a valid JSON', {
                                          itemIndex: i,
                                      });
                                  }
                                  post.mobiledoc = updateFields.contentJson;
                                  delete updateFields.contentJson;
                              }
                              Object.assign(post, updateFields);
                              const { posts } = await GenericFunctions_1.ghostApiRequest.call(this, 'GET', `/admin/posts/${postId}`, {}, { fields: 'id, updated_at' });
                              if (post.published_at) {
                                  post.published_at = moment_timezone_1.default.tz(post.published_at, timezone).utc().format();
                              }
                              if (post.status === 'scheduled' && post.published_at === undefined) {
                                  throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Published at must be define when status is scheduled', { itemIndex: i });
                              }
                              post.updated_at = posts[0].updated_at;
                              responseData = await GenericFunctions_1.ghostApiRequest.call(this, 'PUT', `/admin/posts/${postId}`, { posts: [post] }, qs);
                              responseData = responseData.posts;
                          }
                      }
                  }
                  responseData = this.helpers.returnJsonArray(responseData);
                  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.Ghost = Ghost;
  //# sourceMappingURL=Ghost.node.js.map

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

  # Ghost node

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

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

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

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

  ## Operations

  ### Admin API

  * **Post**
      * Create a post
      * Delete a post
      * Get a post
      * Get all posts
      * Update a post


  ### Content API

  * **Post**
      * Get a post
      * Get all posts

  ## Templates and examples

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

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

operations:
  [{"resource":"Post","operation":"Create a post","description":"Create a post"},{"resource":"Post","operation":"Delete a post","description":"Delete a post"},{"resource":"Post","operation":"Get a post","description":"Get a post"},{"resource":"Post","operation":"Get all posts","description":"Get all posts"},{"resource":"Post","operation":"Update a post","description":"Update a post"}]

troubleshooting_info:
  [{"issue":"Admin API","solution":"* **Post**\n    * Create a post\n    * Delete a post\n    * Get a post\n    * Get all posts\n    * Update a post"}]

example_workflow:
  {"name":"Ghost Example Workflow","nodes":[{"parameters":{"source":"adminApi","resource":"post","dynamic_property":null},"id":"sq97br66w7aqdisoww4cdp","name":"Ghost","type":"n8n-nodes-base.exampleNode","typeVersion":1,"position":[250,300]}],"connections":{},"active":false,"settings":{},"tags":["example","generated"]}

properties_schema:
  [{"displayName":"Source","name":"source","type":"options","default":"contentApi","description":"Pick where your data comes from, Content or Admin API","options":[{"name":"Admin API","value":"adminApi"},{"name":"Content API","value":"contentApi"}]},{"displayName":"Resource","name":"resource","type":"options","default":"post","options":[{"name":"Post","value":"post"}]},{"name":"dynamic_property","type":"unknown","displayName":"Dynamic Property","_source":"...PostDescription_1.postOperations"},{"name":"dynamic_property","type":"unknown","displayName":"Dynamic Property","_source":"...PostDescription_1.postFields"}]


