{
  "name": "WooCommerce Sipariş SMS Bildirimi (Başlıklı SMS)",
  "nodes": [
    {
      "parameters": {
        "topic": "order.updated"
      },
      "id": "wc-trigger",
      "name": "WooCommerce Sipariş Güncellendi",
      "type": "n8n-nodes-base.wooCommerceTrigger",
      "typeVersion": 1,
      "position": [220, 300]
    },
    {
      "parameters": {
        "jsCode": "const map = {'ç':'c','Ç':'C','ğ':'g','Ğ':'G','ı':'i','İ':'I','ö':'o','Ö':'O','ş':'s','Ş':'S','ü':'u','Ü':'U'};\nconst raw = items[0].json;\nconst statusText = raw.status === 'completed' ? 'tamamlandi ve kargoya hazir' : 'alindi ve hazirlaniyor';\nconst name = `${raw.billing?.first_name || ''} ${raw.billing?.last_name || ''}`.trim() || 'Musterimiz';\nconst text = `Sayin ${name}, #${raw.number || raw.id} nolu siparisiniz ${statusText}.`.replace(/[çÇğĞıİöÖşŞüÜ]/g, c => map[c]);\nreturn [{ json: { orderId: raw.id, status: raw.status, phone: raw.billing?.phone, message: text } }];"
      },
      "id": "gsm7-normalize",
      "name": "GSM-7 Türkçe Karakter Dönüştür",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [460, 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": "={{ 'wc-' + $json.orderId + '-' + $json.status }}" }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ header: 'MAGAZANIZ', message: $json.message, recipients: [$json.phone] }) }}"
      },
      "id": "send-sms",
      "name": "Başlıklı SMS Gönder",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [700, 300]
    }
  ],
  "connections": {
    "WooCommerce Sipariş Güncellendi": {
      "main": [[{ "node": "GSM-7 Türkçe Karakter Dönüştür", "type": "main", "index": 0 }]]
    },
    "GSM-7 Türkçe Karakter Dönüştür": {
      "main": [[{ "node": "Başlıklı SMS Gönder", "type": "main", "index": 0 }]]
    }
  },
  "active": false,
  "settings": { "executionOrder": "v1" }
}
