{
  "name": "05 Webhook - Google Sheets Skeleton",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "google-sheets-order-demo",
        "responseMode": "responseNode",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [
        220,
        300
      ],
      "id": "79917335-58f7-4dcb-9bb1-b0ba6bde0051",
      "name": "Webhook",
      "webhookId": "google-sheets-order-demo"
    },
    {
      "parameters": {
        "keepOnlySet": false,
        "values": {
          "string": [
            {
              "name": "created_at",
              "value": "={{$now}}"
            },
            {
              "name": "order_name",
              "value": "={{$json.body.name}}"
            },
            {
              "name": "order_email",
              "value": "={{$json.body.email}}"
            },
            {
              "name": "course_name",
              "value": "={{$json.body.course}}"
            },
            {
              "name": "payment_status",
              "value": "={{$json.body.paid ? 'paid' : 'unpaid'}}"
            }
          ],
          "number": [
            {
              "name": "order_amount",
              "value": "={{$json.body.amount}}"
            }
          ]
        },
        "options": {}
      },
      "id": "79917335-58f7-4dcb-9bb1-b0ba6bde0052",
      "name": "Normalize Order",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        500,
        300
      ]
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "https://docs.google.com/spreadsheets/d/YOUR_SPREADSHEET_ID/edit#gid=0",
          "mode": "url"
        },
        "sheetName": {
          "__rl": true,
          "value": "Orders",
          "mode": "name"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "created_at": "={{$json.created_at}}",
            "order_name": "={{$json.order_name}}",
            "order_email": "={{$json.order_email}}",
            "course_name": "={{$json.course_name}}",
            "order_amount": "={{$json.order_amount}}",
            "payment_status": "={{$json.payment_status}}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "created_at",
              "displayName": "created_at",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "order_name",
              "displayName": "order_name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "order_email",
              "displayName": "order_email",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "course_name",
              "displayName": "course_name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "order_amount",
              "displayName": "order_amount",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "payment_status",
              "displayName": "payment_status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        780,
        300
      ],
      "id": "79917335-58f7-4dcb-9bb1-b0ba6bde0053",
      "name": "Append row in sheet"
    },
    {
      "parameters": {
        "keepOnlySet": false,
        "values": {
          "string": [
            {
              "name": "status",
              "value": "saved"
            },
            {
              "name": "message",
              "value": "Order written to Google Sheets"
            }
          ]
        },
        "options": {}
      },
      "id": "79917335-58f7-4dcb-9bb1-b0ba6bde0054",
      "name": "Build Response",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        1040,
        300
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{$json}}",
        "options": {
          "responseCode": 200
        }
      },
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.4,
      "position": [
        1280,
        300
      ],
      "id": "79917335-58f7-4dcb-9bb1-b0ba6bde0055",
      "name": "Respond to Webhook"
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Normalize Order",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize Order": {
      "main": [
        [
          {
            "node": "Append row in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Append row in sheet": {
      "main": [
        [
          {
            "node": "Build Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Response": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {},
  "meta": {}
}
