{
  "name": "Conviro CSAT to Google Sheets",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "conviro-csat",
        "responseMode": "onReceived"
      },
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{$json[\"event\"]}}",
              "value2": "csat.received"
            }
          ]
        }
      },
      "name": "Filter CSAT",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        450,
        300
      ]
    },
    {
      "parameters": {
        "operation": "append",
        "sheetId": "YOUR_SPREADSHEET_ID",
        "range": "CSAT!A:E",
        "columns": "Timestamp,Session ID,Score,Feedback,Chatbot",
        "options": {}
      },
      "name": "Append to Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 2,
      "position": [
        700,
        250
      ],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "Timestamp",
              "value": "={{$json[\"timestamp\"]}}"
            },
            {
              "name": "Session ID",
              "value": "={{$json[\"data\"][\"sessionId\"]}}"
            },
            {
              "name": "Score",
              "value": "={{$json[\"data\"][\"score\"]}}"
            },
            {
              "name": "Feedback",
              "value": "={{$json[\"data\"][\"feedback\"] || ''}}"
            },
            {
              "name": "Chatbot",
              "value": "={{$json[\"data\"][\"chatbotName\"] || 'Default'}}"
            }
          ]
        }
      },
      "name": "Set Fields",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        550,
        250
      ]
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Filter CSAT",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter CSAT": {
      "main": [
        [
          {
            "node": "Set Fields",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "Set Fields": {
      "main": [
        [
          {
            "node": "Append to Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  }
}