{
  "name": "SimpleX Bridge Handler",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "simplex-bridge",
        "options": {
          "rawBody": false
        }
      },
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{ $json.message }}",
              "operation": "isNotEmpty"
            }
          ]
        }
      },
      "name": "Has Message?",
      "type": "n8n-nodes-base.if",
      "position": [
        450,
        300
      ]
    },
    {
      "parameters": {
        "model": "claude-sonnet-4-5-20250929",
        "messages": {
          "values": [
            {
              "content": "={{ $json.message }}"
            }
          ]
        },
        "options": {
          "systemMessage": "You are a helpful assistant. The user is messaging via SimpleX Chat. Keep responses concise."
        }
      },
      "name": "Claude",
      "type": "@n8n/n8n-nodes-langchain.lmChatAnthropic",
      "position": [
        650,
        250
      ],
      "note": "Replace with your preferred AI node or custom logic"
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify({ response: $json.output || $json.text || 'No response generated.' }) }}"
      },
      "name": "Respond",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        850,
        250
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify({ response: 'Empty message received.' }) }}"
      },
      "name": "Respond Empty",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        650,
        400
      ]
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Has Message?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Has Message?": {
      "main": [
        [
          {
            "node": "Claude",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Respond Empty",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Claude": {
      "main": [
        [
          {
            "node": "Respond",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}