{
  "name": "tool/send_waha",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "tool/send_waha",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "11111111-1111-4111-8111-111111111111",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        240,
        300
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "secret-check",
              "leftValue": "={{ $json.headers['x-astra-secret'] }}",
              "rightValue": "={{ $env.CORTEX_SHARED_SECRET }}",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "22222222-2222-4222-8222-222222222222",
      "name": "Verify Secret",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        460,
        300
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{ ($env.WAHA_BASE_URL || 'http://waha:3000') }}/api/sendText",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "X-Api-Key",
              "value": "={{ $env.WAHA_API_KEY }}"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ session: ($env.WAHA_SESSION || 'default'), chatId: $('Webhook').item.json.body.to, text: $('Webhook').item.json.body.text }) }}",
        "options": {}
      },
      "id": "33333333-3333-4333-8333-333333333333",
      "name": "WAHA sendText",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        680,
        200
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify({ ok: true }) }}",
        "options": {}
      },
      "id": "44444444-4444-4444-8444-444444444444",
      "name": "Respond OK",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        900,
        200
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseCode": 403,
        "responseBody": "={{ JSON.stringify({ ok: false, error: 'forbidden' }) }}",
        "options": {}
      },
      "id": "55555555-5555-4555-8555-555555555555",
      "name": "Respond 403",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        680,
        420
      ]
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Verify Secret",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Verify Secret": {
      "main": [
        [
          {
            "node": "WAHA sendText",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Respond 403",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "WAHA sendText": {
      "main": [
        [
          {
            "node": "Respond OK",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "active": false
}