{
  "name": "WhatsApp Gateway - Recipient Opted Out",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "whatsapp-gateway-opt-out",
        "responseMode": "onReceived",
        "options": {}
      },
      "id": "webhook-opt-out",
      "name": "WhatsApp Gateway Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [240, 300]
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{$json.body.event}}",
              "operation": "equals",
              "value2": "recipient.opted_out"
            }
          ]
        }
      },
      "id": "only-opt-out",
      "name": "Only recipient.opted_out",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [500, 300]
    },
    {
      "parameters": {
        "url": "https://crm.example.com/replace-with-opt-out-endpoint",
        "method": "POST",
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {"name": "phone", "value": "={{$json.body.from}}"},
            {"name": "reason", "value": "={{$json.body.reason}}"},
            {"name": "timestamp", "value": "={{$json.body.timestamp}}"}
          ]
        }
      },
      "id": "update-opt-out-placeholder",
      "name": "Update Opt-Out List Placeholder",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [780, 220],
      "notes": "Replace the example CRM URL with your own private endpoint."
    }
  ],
  "connections": {
    "WhatsApp Gateway Webhook": {
      "main": [[{"node": "Only recipient.opted_out", "type": "main", "index": 0}]]
    },
    "Only recipient.opted_out": {
      "main": [[{"node": "Update Opt-Out List Placeholder", "type": "main", "index": 0}], []]
    }
  },
  "active": false,
  "settings": {},
  "tags": ["WhatsApp Gateway", "starter-template"]
}
