{
  "name": "Reply to every new lead on WhatsApp within 60 seconds",
  "nodes": [
    {
      "parameters": {
        "content": "What you get: a personalised WhatsApp message to every new CRM lead the moment it is created, from your own number.\nWhat it replaces: the \"we'll call you back\" email and the hour a lead waits while nobody notices it.\nSetup time: about 10 minutes.\n\nLeads answered in the first minute close more often — this template makes that automatic.\n\nWorks with a normal WhatsApp number — no Meta Business account needed.\n\nSetup:\n1. Create an API key at https://developers.wasync.app/keys (scopes: whatsapp.send).\n2. In n8n, go to Credentials -> New -> Header Auth. Name the credential \"WASync API key\". Set its Name field to `Authorization` and its Value field to `Bearer wsk_live_<your key>`.\n3. Open the \"Settings\" node at the top of this workflow and fill in your own values. Never commit real portal URLs, tokens, connection ids, or phone numbers.\n\nAlso add an outbound webhook in Bitrix24 (Applications -> Webhooks -> Outbound) for event ONCRMLEADADD, pointing at this workflow's \"Bitrix Lead Webhook\" node URL. Find your WASync connectionId by calling `GET https://developers.wasync.app/api/v1/connections` with your API key, or from your connection list at developers.wasync.app -- put it in the Settings node.\n\nThis template uses only built-in n8n nodes, so it works on n8n Cloud; if you self-host, you can also use our community node n8n-nodes-wasync.\n\nDocs: https://docs.wasync.app/docs/guides/n8n?utm_source=n8n&utm_medium=template&utm_campaign=t1-http",
        "height": 520,
        "width": 460
      },
      "name": "Read Me First",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        0,
        -80
      ]
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "wasync-t1-new-lead",
        "responseMode": "onReceived",
        "options": {}
      },
      "name": "Bitrix Lead Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        0,
        200
      ]
    },
    {
      "parameters": {
        "mode": "manual",
        "assignments": {
          "assignments": [
            {
              "id": "Settings-0",
              "name": "bitrixPortalUrl",
              "value": "https://yourportal.bitrix24.com",
              "type": "string"
            },
            {
              "id": "Settings-1",
              "name": "bitrixWebhookToken",
              "value": "REPLACE_WITH_YOUR_INBOUND_WEBHOOK_TOKEN",
              "type": "string"
            },
            {
              "id": "Settings-2",
              "name": "companyName",
              "value": "Your Company",
              "type": "string"
            },
            {
              "id": "Settings-3",
              "name": "wasyncConnectionId",
              "value": "REPLACE_WITH_YOUR_WASYNC_CONNECTION_ID",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "name": "Settings",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        0,
        460
      ]
    },
    {
      "parameters": {
        "method": "GET",
        "url": "={{ $('Settings').item.json.bitrixPortalUrl }}/rest/{{ $('Settings').item.json.bitrixWebhookToken }}/crm.lead.get",
        "options": {},
        "sendQuery": true,
        "specifyQuery": "keypair",
        "queryParameters": {
          "parameters": [
            {
              "name": "ID",
              "value": "={{ $('Bitrix Lead Webhook').item.json.body.data.FIELDS.ID }}"
            }
          ]
        }
      },
      "name": "Get Lead",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        260,
        460
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "id": "Has Phone?-cond0",
              "leftValue": "={{ $json.result && $json.result.PHONE ? $json.result.PHONE.length : 0 }}",
              "rightValue": 0,
              "operator": {
                "type": "number",
                "operation": "gt"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "name": "Has Phone?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        520,
        460
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://developers.wasync.app/api/v1/messages",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Accept",
              "value": "application/json"
            }
          ]
        },
        "options": {},
        "sendBody": true,
        "contentType": "json",
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ connectionId: $('Settings').item.json.wasyncConnectionId, to: $json.result.PHONE[0].VALUE, text: 'Hello ' + ($json.result.NAME || 'there') + '! Thanks for reaching out to ' + $('Settings').item.json.companyName + '. We received your request and will follow up shortly.' }) }}"
      },
      "name": "Send Welcome Message",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        780,
        380
      ],
      "credentials": {
        "httpHeaderAuth": {
          "name": "WASync API key"
        }
      }
    }
  ],
  "connections": {
    "Bitrix Lead Webhook": {
      "main": [
        [
          {
            "node": "Settings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Settings": {
      "main": [
        [
          {
            "node": "Get Lead",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Lead": {
      "main": [
        [
          {
            "node": "Has Phone?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Has Phone?": {
      "main": [
        [
          {
            "node": "Send Welcome Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  }
}
