{
  "name": "WA GCLID Tracking \u2014 Incoming Message to CRM",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "wa-incoming",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "a1b2c3d4-0001-0001-0001-000000000001",
      "name": "Webhook \u2014 WA Gateway",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        240,
        300
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://filter-bot-crmcutting.qk6yxt.easypanel.host/api/webhooks/whatsapp/incoming",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ $json.body ?? $json }}",
        "options": {
          "timeout": 10000,
          "response": {
            "response": {
              "neverError": true
            }
          }
        }
      },
      "id": "a1b2c3d4-0002-0002-0002-000000000002",
      "name": "HTTP Request \u2014 CRM Backend",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        480,
        300
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify({ ok: true, customerId: $json.data?.customerId ?? null, gclid: $json.data?.gclid ?? null, keywordText: $json.data?.keywordText ?? null }) }}",
        "options": {
          "responseCode": 200
        }
      },
      "id": "a1b2c3d4-0003-0003-0003-000000000003",
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        720,
        300
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "id": "cond-001",
              "leftValue": "={{ $json.data?.gclid }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "notEmpty"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "a1b2c3d4-0004-0004-0004-000000000004",
      "name": "Has GCLID?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        480,
        500
      ]
    },
    {
      "parameters": {
        "operation": "appendOrUpdate",
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "GANTI_DENGAN_ID_GOOGLE_SHEET"
        },
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "Sheet1"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Tanggal": "={{ new Date().toLocaleDateString('id-ID', {timeZone:'Asia/Jakarta'}) }}",
            "Phone": "={{ $('HTTP Request \u2014 CRM Backend').item.json.data?.customerId ?? '' }}",
            "GCLID": "={{ $('HTTP Request \u2014 CRM Backend').item.json.data?.gclid ?? '' }}",
            "Keyword": "={{ $('HTTP Request \u2014 CRM Backend').item.json.data?.keywordText ?? '' }}",
            "UTM Source": "={{ $('HTTP Request \u2014 CRM Backend').item.json.data?.utmSource ?? '' }}",
            "UTM Campaign": "={{ $('HTTP Request \u2014 CRM Backend').item.json.data?.utmCampaign ?? '' }}",
            "Pesan": "={{ $('HTTP Request \u2014 CRM Backend').item.json.data?.cleanedMessage ?? '' }}"
          },
          "matchingColumns": [
            "GCLID"
          ],
          "schema": [
            {
              "id": "Tanggal",
              "displayName": "Tanggal",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "string",
              "removed": false
            },
            {
              "id": "Phone",
              "displayName": "Phone",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "string",
              "removed": false
            },
            {
              "id": "GCLID",
              "displayName": "GCLID",
              "required": false,
              "defaultMatch": true,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "string",
              "removed": false
            },
            {
              "id": "Keyword",
              "displayName": "Keyword",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "string",
              "removed": false
            },
            {
              "id": "UTM Source",
              "displayName": "UTM Source",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "string",
              "removed": false
            },
            {
              "id": "UTM Campaign",
              "displayName": "UTM Campaign",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "string",
              "removed": false
            },
            {
              "id": "Pesan",
              "displayName": "Pesan",
              "required": false,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "display": true,
              "type": "string",
              "removed": false
            }
          ]
        },
        "options": {}
      },
      "id": "a1b2c3d4-0005-0005-0005-000000000005",
      "name": "Google Sheets \u2014 Log GCLID (Opsional)",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        720,
        500
      ],
      "notes": "OPSIONAL: Log ke Google Sheets untuk monitoring. Isi documentId dengan ID sheet Anda, atau hapus node ini jika tidak diperlukan."
    }
  ],
  "connections": {
    "Webhook \u2014 WA Gateway": {
      "main": [
        [
          {
            "node": "HTTP Request \u2014 CRM Backend",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request \u2014 CRM Backend": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          },
          {
            "node": "Has GCLID?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Has GCLID?": {
      "main": [
        [
          {
            "node": "Google Sheets \u2014 Log GCLID (Opsional)",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "saveManualExecutions": true,
    "callerPolicy": "workflowsFromSameOwner",
    "errorWorkflow": ""
  },
  "staticData": null,
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "tags": [
    "whatsapp",
    "gclid",
    "tracking",
    "crm"
  ],
  "triggerCount": 0,
  "updatedAt": "2026-05-12T00:00:00.000Z",
  "versionId": "1"
}