{
  "functions": [
    {
      "id": "6932d9c7197f9d3390afc2f1",
      "name": "n8n webhook",
      "createdByID": 955467,
      "folderID": null,
      "code": "export default async function main(args) {\n  /**\n   * Send a request to webhook in n8n\n   * Author: Juan Carlos Quintero (https://moonside.ai)\n   * License: MIT\n   **/\n  // Extracting input variables\n  const { payload, webhookUrl } = args.inputVars;\n\n  // Validate that the required input variables is provided\n  if (!payload || !webhookUrl) {\n    return {\n      next: { path: 'error' },\n      trace: [{ type: \"debug\", payload: { message: \"[n8n] Missing required input variables for this function\" } }]\n    };\n  }\n\n  // Configure the fetch request\n  const config = {\n    method: 'POST',\n    headers: {\n      'Accept': 'application/json',\n      'Content-Type': 'application/json',\n    },\n    body: payload\n  };\n\n  try {\n    // Make the API call\n    const response = await fetch(webhookUrl, config);\n\n    // Check if the response status is OK\n    if (!response.ok) {\n      throw new Error(`HTTP error! status: ${response.status}`);\n    }\n\n    // Extract the JSON body from the response\n    const responseBody = response.json;\n\n    // Check response\n    if (!responseBody || typeof responseBody !== 'object'){\n      throw new Error(`Response body is incorrect! body: ${responseBody}`);\n    }\n\n    const responseData = JSON.stringify(responseBody)\n\n    return {\n      next: { path: 'success' }, // Directing the flow to continue on the 'success' path\n      outputVars: {\n        response: responseData ,\n      },\n      trace: [\n        {\n          type: 'debug',\n          payload: { message: \"[n8n] Webhook call successful\" }\n        },\n        {\n          type: 'debug',\n          payload: { message: `[n8n] Webhook response: ${responseData}` }\n        }\n      ]\n    };\n  }\n  catch (error) {\n    return {\n      next: { path: 'error' },\n      trace: [{ type: 'debug', payload: { message: \"[n8n] Webhook call error: \" + error.message } }]\n    };\n  }\n}",
      "image": "https://cm4-production-assets.s3.amazonaws.com/1764069544822-n8n-logo-pink.png",
      "description": "Send a POST webhook to trigger an automation in n8n",
      "pathOrder": [
        "6932d9c7197f9d3390afc2f2",
        "6932d9c7197f9d3390afc2f3"
      ],
      "createdAt": "2025-12-05T13:10:32.000Z",
      "updatedAt": "2025-12-05T13:12:00.000Z",
      "updatedByID": 955467
    }
  ],
  "functionPaths": [
    {
      "id": "6932d9c7197f9d3390afc2f2",
      "name": "success",
      "label": "Success",
      "functionID": "6932d9c7197f9d3390afc2f1",
      "createdAt": "2025-12-05T13:10:31.652Z"
    },
    {
      "id": "6932d9c7197f9d3390afc2f3",
      "name": "error",
      "label": "Error",
      "functionID": "6932d9c7197f9d3390afc2f1",
      "createdAt": "2025-12-05T13:10:31.653Z"
    }
  ],
  "functionVariables": [
    {
      "id": "6932d9c7197f9d3390afc2f4",
      "name": "webhookUrl",
      "type": "input",
      "functionID": "6932d9c7197f9d3390afc2f1",
      "description": "Webhook url that you want to trigger",
      "createdAt": "2025-12-05T13:10:31.652Z"
    },
    {
      "id": "6932d9c7197f9d3390afc2f5",
      "name": "payload",
      "type": "input",
      "functionID": "6932d9c7197f9d3390afc2f1",
      "description": "JSON object with payload to send to n8n",
      "createdAt": "2025-12-05T13:10:31.653Z"
    },
    {
      "id": "6932d9c7197f9d3390afc2f6",
      "name": "response",
      "type": "output",
      "functionID": "6932d9c7197f9d3390afc2f1",
      "description": "Response from n8n",
      "createdAt": "2025-12-05T13:10:31.654Z"
    }
  ]
}