{
 "name": "ChatKomodo — lead reaches a stage → follow-up WhatsApp",
 "nodes": [
  {
   "parameters": {
    "httpMethod": "POST",
    "path": "chatkomodo-leads",
    "responseMode": "onReceived",
    "options": {}
   },
   "name": "ChatKomodo webhook (lead.stage_changed)",
   "type": "n8n-nodes-base.webhook",
   "typeVersion": 2,
   "position": [
    0,
    0
   ],
   "webhookId": "chatkomodo-leads"
  },
  {
   "parameters": {
    "conditions": {
     "options": {
      "caseSensitive": false,
      "leftValue": "",
      "typeValidation": "loose"
     },
     "conditions": [
      {
       "leftValue": "={{ $json.body.data.stage }}",
       "rightValue": "won",
       "operator": {
        "type": "string",
        "operation": "equals"
       }
      }
     ],
     "combinator": "and"
    },
    "options": {}
   },
   "name": "Deal won?",
   "type": "n8n-nodes-base.if",
   "typeVersion": 2,
   "position": [
    260,
    0
   ]
  },
  {
   "parameters": {
    "amount": 1,
    "unit": "hours"
   },
   "name": "Wait 1 hour",
   "type": "n8n-nodes-base.wait",
   "typeVersion": 1.1,
   "position": [
    500,
    -80
   ],
   "webhookId": "chatkomodo-wait"
  },
  {
   "parameters": {
    "method": "POST",
    "url": "https://api.chatkomodo.com/v1/sessions/YOUR_DEVICE_ID/messages",
    "authentication": "genericCredentialType",
    "genericAuthType": "httpHeaderAuth",
    "sendBody": true,
    "specifyBody": "json",
    "jsonBody": "={{ JSON.stringify({ chat_id: $('ChatKomodo webhook (lead.stage_changed)').item.json.body.data.phone, type: 'text', body: 'Terima kasih, ' + ($('ChatKomodo webhook (lead.stage_changed)').item.json.body.data.name || 'kak') + '! Pesanan Anda kami proses.' }) }}",
    "options": {}
   },
   "name": "Thank you message",
   "type": "n8n-nodes-base.httpRequest",
   "typeVersion": 4.2,
   "position": [
    740,
    -80
   ],
   "credentials": {
    "httpHeaderAuth": {
     "id": "",
     "name": "ChatKomodo API"
    }
   }
  },
  {
   "parameters": {
    "content": "## Follow up when a lead is won\nCredential: Header Auth named \"ChatKomodo API\" with Name = Authorization and Value = Bearer <your API key>. Replace YOUR_DEVICE_ID with the device id (Devices → device → ID).\n`stage` is the stage id (won, new…); `stage_name` is its name on your board.\nIn ChatKomodo → Webhooks, add this workflow's production URL with the event lead.stage_changed.",
    "height": 240,
    "width": 460
   },
   "name": "Note",
   "type": "n8n-nodes-base.stickyNote",
   "typeVersion": 1,
   "position": [
    -40,
    -300
   ]
  }
 ],
 "connections": {
  "ChatKomodo webhook (lead.stage_changed)": {
   "main": [
    [
     {
      "node": "Deal won?",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "Deal won?": {
   "main": [
    [
     {
      "node": "Wait 1 hour",
      "type": "main",
      "index": 0
     }
    ],
    []
   ]
  },
  "Wait 1 hour": {
   "main": [
    [
     {
      "node": "Thank you message",
      "type": "main",
      "index": 0
     }
    ]
   ]
  }
 },
 "settings": {}
}
