{
  "name": "Feedback Collector",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "feedback",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "webhook-feedback",
      "name": "Webhook - Feedback",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "=INSERT INTO feedback (timestamp, rating, comment, email, want_updates, user_agent, screen_resolution)\nVALUES (\n  TO_TIMESTAMP('{{ $json.body.timestamp }}', 'YYYY-MM-DD\"T\"HH24:MI:SS.MS\"Z\"'),\n  {{ $json.body.rating }},\n  '{{ $json.body.comment.replace(/'/g, \"''\") }}',\n  '{{ $json.body.email }}',\n  {{ $json.body.wantUpdates }},\n  '{{ $json.body.userAgent.replace(/'/g, \"''\") }}',\n  '{{ $json.body.screenResolution }}'\n)\nRETURNING id;",
        "options": {}
      },
      "id": "save-to-postgres",
      "name": "Save to Postgres",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.4,
      "position": [
        450,
        300
      ],
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ { success: true, message: 'Feedback received. Thank you!' } }}"
      },
      "id": "respond-to-webhook",
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        650,
        300
      ]
    }
  ],
  "connections": {
    "Webhook - Feedback": {
      "main": [
        [
          {
            "node": "Save to Postgres",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save to Postgres": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {},
  "versionId": "1",
  "id": "feedback-collector",
  "tags": []
}