{
  "name": "Ticimax Sipariş ve Kargo Webhook SMS (Başlıklı SMS)",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "ticimax-siparis",
        "options": {}
      },
      "id": "ticimax-webhook-trigger",
      "name": "Ticimax Webhook Tetikleyici",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [220, 300]
    },
    {
      "parameters": {
        "jsCode": "const trMap = {'ç':'c','Ç':'C','ğ':'g','Ğ':'G','ı':'i','İ':'I','ö':'o','Ö':'O','ş':'s','Ş':'S','ü':'u','Ü':'U'};\nconst raw = items[0].json.body || items[0].json;\nconst rawPhone = raw.TeslimatTelefon || raw.UyeTelefon || raw.phone || '';\nconst phone = String(rawPhone).replace(/\\D/g, '');\nconst orderNo = String(raw.SiparisNo || raw.orderNo || raw.Id || '0000');\nconst customerName = String(raw.UyeAdi || raw.customerName || 'Musterimiz').trim();\nconst trackingNumber = String(raw.KargoTakipNo || raw.trackingNumber || '').trim();\nconst cargoCompany = String(raw.KargoFirma || raw.cargoCompany || 'kargo').trim();\nconst status = String(raw.SiparisDurumu || raw.status || 'ONAYLANDI').trim();\nlet rawMsg = `Sayin ${customerName}, #${orderNo} nolu Ticimax siparisinizin durumu: ${status}.`;\nif (trackingNumber) {\n  rawMsg = `Sayin ${customerName}, #${orderNo} nolu siparisiniz ${cargoCompany} ile kargoya verildi. Takip: ${trackingNumber}`;\n}\nconst message = rawMsg.replace(/[çÇğĞıİöÖşŞüÜ]/g, (ch) => trMap[ch]);\nconst idempotencyKey = `ticimax-${orderNo}-${status}`.replace(/[^a-zA-Z0-9_-]/g, '-').slice(0, 64);\nreturn [{ json: { orderNo, status, phone, message, idempotencyKey } }];"
      },
      "id": "ticimax-gsm7-normalize",
      "name": "Ticimax Payload ve GSM-7 Dönüşümü",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [470, 300]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://basliklisms.com/api/v1/sms/send",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            { "name": "X-API-Key", "value": "={{ $env.BASLIKLISMS_API_KEY }}" },
            { "name": "Idempotency-Key", "value": "={{ $json.idempotencyKey }}" }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ header: 'MAGAZANIZ', message: $json.message, recipients: [$json.phone] }) }}"
      },
      "id": "ticimax-send-sms",
      "name": "Başlıklı SMS Gönder",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [730, 300]
    }
  ],
  "connections": {
    "Ticimax Webhook Tetikleyici": {
      "main": [[{ "node": "Ticimax Payload ve GSM-7 Dönüşümü", "type": "main", "index": 0 }]]
    },
    "Ticimax Payload ve GSM-7 Dönüşümü": {
      "main": [[{ "node": "Başlıklı SMS Gönder", "type": "main", "index": 0 }]]
    }
  },
  "active": false,
  "settings": { "executionOrder": "v1" }
}
