{
  "nodes": [
    {
      "id": "a5bc6043-aa78-4d48-a963-e222a07bf279",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "disabled": true,
      "position": [
        240,
        -140
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.1
    },
    {
      "id": "078e096f-8dd8-45cd-9d99-8daed60560a3",
      "name": "Execute Workflow Trigger",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        240,
        40
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "12df0479-e9b8-4e14-ade7-3093347c639f",
      "name": "Send Request to NixGuard API",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1280,
        60
      ],
      "parameters": {
        "url": "https://nix.thenex.world",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "jsonHeaders": "{\"Content-Type\": \"application/json\"}",
        "sendHeaders": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "apiKey",
              "value": "={{ $json.apiKey }}"
            },
            {
              "name": "prompt",
              "value": "={{ $json.chatInput }}"
            }
          ]
        },
        "specifyHeaders": "json"
      },
      "typeVersion": 4.2
    },
    {
      "id": "511f9f45-b588-489e-be68-4b9524c15f9d",
      "name": "Format API Response",
      "type": "n8n-nodes-base.set",
      "position": [
        1420,
        280
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "e41e3031-3669-432b-a669-8ece63e0a2a4",
              "name": "content",
              "type": "string",
              "value": "={{ $json.content }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "cc49de4b-51a8-42d3-826a-be24a33f7fc6",
      "name": "Prepare Final Output",
      "type": "n8n-nodes-base.code",
      "position": [
        1580,
        220
      ],
      "parameters": {
        "jsCode": "const output = items[0].json.content;\n\nreturn [{json: {output}}];"
      },
      "typeVersion": 2
    },
    {
      "id": "cb9e71dc-2894-49da-b012-de32448e4474",
      "name": "Parse NixGuard Response",
      "type": "n8n-nodes-base.code",
      "position": [
        1260,
        340
      ],
      "parameters": {
        "jsCode": "const nixResponse = JSON.parse($input.first().json.data);\nconst nixResult = nixResponse.result;\n\nreturn nixResponse;"
      },
      "typeVersion": 2
    },
    {
      "id": "93e01374-8c80-4b8c-9b99-ccaea768c538",
      "name": "Merge Input Data",
      "type": "n8n-nodes-base.merge",
      "position": [
        800,
        -80
      ],
      "parameters": {},
      "typeVersion": 3
    },
    {
      "id": "9d82ba68-ee6a-4078-8e77-33ae53598dba",
      "name": "Aggregate Security Data",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        960,
        -20
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData"
      },
      "typeVersion": 1
    },
    {
      "id": "51f2637f-c41a-417f-89e1-ae518489cfe0",
      "name": "Combine Security Data",
      "type": "n8n-nodes-base.code",
      "position": [
        1120,
        20
      ],
      "parameters": {
        "jsCode": "\n// Combine properties from both objects into a single object \nconst combinedObject = Object.assign({}, ...$input.first().json.data); \n// Return the combined object as a single item \nreturn [combinedObject];"
      },
      "typeVersion": 2
    },
    {
      "id": "735957a6-1421-47e9-8bee-c7946cb637d6",
      "name": "Prepare API Request Data",
      "type": "n8n-nodes-base.set",
      "disabled": true,
      "position": [
        440,
        -140
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "78b78cf7-943f-4f4f-91c5-c71efeb7d78a",
              "name": "apiKey",
              "type": "string",
              "value": "PASTE_YOUR_NIXGUARD_API_KEY_HERE"
            },
            {
              "id": "0ee0f3f2-2954-414b-a701-4ca14e3c5be2",
              "name": "sessionId",
              "type": "string",
              "value": "={{ $json.sessionId }}"
            },
            {
              "id": "a0f7d4d4-0ac7-474e-b87a-b87536f5e303",
              "name": "action",
              "type": "string",
              "value": "={{ $json.action }}"
            },
            {
              "id": "3d047460-d218-4408-aa7a-466f55a5de24",
              "name": "chatInput",
              "type": "string",
              "value": "={{ $json.chatInput }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "2128ecaa-a5d4-4c8d-a7d8-c136831f8879",
      "name": "Data Aggregation",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        500,
        80
      ],
      "parameters": {
        "color": 7,
        "width": 400,
        "height": 340,
        "content": "## Data Aggregation\n\nThis section combines multiple security data sources:\n1. **Merge Input Data**: Combines triggers from different sources\n2. **Aggregate Security Data**: Consolidates security events\n3. **Combine Security Data**: Creates unified request payload\n\n### Use Cases:\n- Correlate Wazuh alerts with NixGuard insights\n- Combine multiple security queries\n- Process batch security events"
      },
      "typeVersion": 1
    },
    {
      "id": "4fa5f6c0-63b5-47ab-b0f8-09a3cbb4e6e4",
      "name": "Workflow Overview1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -320,
        -140
      ],
      "parameters": {
        "color": 7,
        "width": 500,
        "height": 380,
        "content": "## NixGuard Security Connector Workflow\n\nThis workflow integrates NixGuard's RAG (Retrieval-Augmented Generation) with Wazuh security data to provide real-time security insights.\n\n### Key Features:\n- Processes security queries through NixGuard's AI\n- Combines multiple security data sources\n- Returns actionable security insights\n\n### Authentication:\nRequires valid API key for NixGuard endpoint (configured in 'Prepare API Request Data' node)."
      },
      "typeVersion": 1
    },
    {
      "id": "f2fd2765-789b-4440-a6fc-7dead13cfae8",
      "name": "API Request Explanation1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        500,
        440
      ],
      "parameters": {
        "color": 7,
        "width": 400,
        "height": 380,
        "content": "## API Request Configuration\n\nThis node sends the security query to NixGuard's API endpoint with:\n- Proper authentication headers\n- Formatted request body\n- Required content type\n\n### Configuration:\n1. Set your NixGuard API endpoint URL\n2. Ensure headers include `Content-Type: application/json`\n3. Body contains:\n   - `apiKey`: Your NixGuard API key\n   - `prompt`: The security query/input"
      },
      "typeVersion": 1
    },
    {
      "id": "c0acc267-23af-4d98-b0b2-1b5743ce3402",
      "name": "Response Processing1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1440,
        440
      ],
      "parameters": {
        "color": 7,
        "width": 400,
        "height": 320,
        "content": "## Response Processing\n\nThis section handles the NixGuard API response:\n1. **Parse NixGuard Response**: Converts JSON string to object\n2. **Format API Response**: Extracts relevant content\n3. **Prepare Final Output**: Structures output for end users\n\n### Error Handling:\n- Invalid responses will trigger error paths\n- Ensure proper error handling in subsequent workflows"
      },
      "typeVersion": 1
    },
    {
      "id": "6a632ce2-5490-4a68-9fa7-22126cc7781a",
      "name": "Setup Guide1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -220,
        280
      ],
      "parameters": {
        "color": 7,
        "width": 400,
        "height": 440,
        "content": "## Getting Started\n\n### Prerequisites:\n- Valid NixGuard API key\n\n### Setup Instructions:\n1. Configure your NixGuard API key in 'Prepare API Request Data' node\n2. Set up trigger method (chat or manual)\n3. Test with sample security queries\n4. Make sure NixGuard agents are installed on your network endpoints for real-time security events\n\n### Support:\nFor your free api key, visit [NixGuard Subscribe Page](https://thenex.world/security/subscribe)\nFor questions, visit [NixGuard Documentation](https://nixguard.thenex.world) or join our [Community Discord](https://discord.com/invite/ajCYwYCwHb)"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Merge Input Data": {
      "main": [
        [
          {
            "node": "Aggregate Security Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format API Response": {
      "main": [
        [
          {
            "node": "Prepare Final Output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Combine Security Data": {
      "main": [
        [
          {
            "node": "Send Request to NixGuard API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate Security Data": {
      "main": [
        [
          {
            "node": "Combine Security Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse NixGuard Response": {
      "main": [
        [
          {
            "node": "Format API Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Execute Workflow Trigger": {
      "main": [
        [
          {
            "node": "Merge Input Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare API Request Data": {
      "main": [
        [
          {
            "node": "Merge Input Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "Prepare API Request Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Request to NixGuard API": {
      "main": [
        [
          {
            "node": "Parse NixGuard Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}