{
  "name": "Payment reminders on WhatsApp that stop when the customer says \"paid\"",
  "nodes": [
    {
      "parameters": {
        "content": "## Payment reminders on WhatsApp that stop when the customer says \"paid\"\n\nWhat you get: a daily reminder to customers with an open invoice, and an automatic stop (plus a CRM note) the moment they reply that they paid.\nWhat it replaces: manual chasing, spreadsheets of \"who did I remind\", and reminders sent to people who already paid.\nSetup time: about 15 minutes.\n\nPolite, persistent, and it never nags someone who has already paid.\n\nWorks with a normal WhatsApp number — no Meta Business account needed.\n\nTwo independent triggers live in this one workflow: a daily Schedule Trigger (top lane) and a WASync Trigger (lane below it). The Bitrix24 fields used here (deal stage ID, and the custom fields for amount/due date) are placeholders -- adjust them to match your own pipeline before activating.\n\nSetup:\n1. Install the community node: n8n Settings -> Community Nodes -> npm package `n8n-nodes-wasync`.\n2. Create a free WASync account at https://developers.wasync.app/register, connect a WhatsApp number, then create an API key at https://developers.wasync.app/keys.\n3. In n8n, add a new \"WASync API\" credential using that key.\n4. Open the \"Settings\" node at the top of this workflow and fill in your own values. Never commit real portal URLs, tokens, or phone numbers.\n\nDocs: https://docs.wasync.app/docs/guides/n8n?utm_source=n8n&utm_medium=template&utm_campaign=t3",
        "height": 580,
        "width": 1880
      },
      "name": "Read Me First",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -140,
        -660
      ]
    },
    {
      "parameters": {
        "content": "**① Trigger — daily run**\nRuns once a day at 09:00 in the workflow's timezone.",
        "height": 300,
        "width": 280,
        "color": 7
      },
      "name": "① Trigger — daily run",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -140,
        426
      ]
    },
    {
      "parameters": {
        "content": "**② CRM lookup**\nReads the deals sitting in your awaiting-payment stage\nand splits the result into one item per deal.",
        "height": 300,
        "width": 600,
        "color": 7
      },
      "name": "② CRM lookup",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        180,
        426
      ]
    },
    {
      "parameters": {
        "content": "**③ Send on WhatsApp**\nOne polite reminder per open deal.",
        "height": 300,
        "width": 280,
        "color": 7
      },
      "name": "③ Send on WhatsApp",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        820,
        426
      ]
    },
    {
      "parameters": {
        "content": "**Settings — fill these in**\nPlaceholders only — replace every value here before you activate the\nworkflow. Nothing else in the workflow needs editing.\nFields: bitrixPortalUrl, bitrixWebhookToken, dealStageIdAwaitingPayment, wasyncConnectionId.",
        "height": 366,
        "width": 600,
        "color": 7
      },
      "name": "Settings — fill these in",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -140,
        0
      ]
    },
    {
      "parameters": {
        "content": "**① Trigger — customer reply**\nFires when the customer answers on WhatsApp.",
        "height": 322,
        "width": 280,
        "color": 7
      },
      "name": "① Trigger — customer reply",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -140,
        1250
      ]
    },
    {
      "parameters": {
        "content": "**② CRM lookup**\nMatches \"paid\" or \"1\", resolves the contact and their open deal,\nand writes a note on the deal timeline.",
        "height": 322,
        "width": 1240,
        "color": 7
      },
      "name": "② CRM lookup (2)",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        180,
        1250
      ]
    },
    {
      "parameters": {
        "content": "**③ Send on WhatsApp**\nConfirms to the customer that the reminders stop.",
        "height": 322,
        "width": 280,
        "color": 7
      },
      "name": "③ Send on WhatsApp (2)",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1460,
        1250
      ]
    },
    {
      "parameters": {
        "content": "**Settings — fill these in**\nPlaceholders only — replace every value here before you activate the\nworkflow. Nothing else in the workflow needs editing.\nFields: bitrixPortalUrl, bitrixWebhookToken.",
        "height": 344,
        "width": 600,
        "color": 7
      },
      "name": "Settings — fill these in (2)",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -140,
        846
      ]
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "days",
              "triggerAtHour": 9,
              "triggerAtMinute": 0
            }
          ]
        }
      },
      "name": "Run Daily at 09:00",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        0,
        606
      ]
    },
    {
      "parameters": {
        "mode": "manual",
        "assignments": {
          "assignments": [
            {
              "id": "Settings (Reminders)-0",
              "name": "bitrixPortalUrl",
              "value": "https://yourportal.bitrix24.com",
              "type": "string"
            },
            {
              "id": "Settings (Reminders)-1",
              "name": "bitrixWebhookToken",
              "value": "REPLACE_WITH_YOUR_INBOUND_WEBHOOK_TOKEN",
              "type": "string"
            },
            {
              "id": "Settings (Reminders)-2",
              "name": "dealStageIdAwaitingPayment",
              "value": "REPLACE_WITH_YOUR_STAGE_ID",
              "type": "string"
            },
            {
              "id": "Settings (Reminders)-3",
              "name": "wasyncConnectionId",
              "value": "REPLACE_WITH_YOUR_WASYNC_CONNECTION_ID",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "name": "Settings (Reminders)",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        0,
        246
      ]
    },
    {
      "parameters": {
        "method": "GET",
        "url": "={{ $('Settings (Reminders)').item.json.bitrixPortalUrl }}/rest/{{ $('Settings (Reminders)').item.json.bitrixWebhookToken }}/crm.deal.list",
        "options": {},
        "sendQuery": true,
        "specifyQuery": "keypair",
        "queryParameters": {
          "parameters": [
            {
              "name": "filter[STAGE_ID]",
              "value": "={{ $('Settings (Reminders)').item.json.dealStageIdAwaitingPayment }}"
            },
            {
              "name": "filter[CLOSED]",
              "value": "N"
            },
            {
              "name": "select[]",
              "value": "ID"
            },
            {
              "name": "select[]",
              "value": "TITLE"
            },
            {
              "name": "select[]",
              "value": "OPPORTUNITY"
            },
            {
              "name": "select[]",
              "value": "CURRENCY_ID"
            },
            {
              "name": "select[]",
              "value": "UF_CRM_DUE_DATE"
            },
            {
              "name": "select[]",
              "value": "UF_CRM_WHATSAPP_PHONE"
            }
          ]
        }
      },
      "name": "List Awaiting-Payment Deals in Bitrix24",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        320,
        606
      ]
    },
    {
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "// crm.deal.list returns one item with a `result` array.\n// Turn each deal into its own item so the WASync node below sends one reminder per deal.\nconst deals = $input.first().json.result || [];\nreturn deals.map((deal) => ({ json: deal }));"
      },
      "name": "Split Deals",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        640,
        606
      ]
    },
    {
      "parameters": {
        "resource": "message",
        "operation": "send",
        "connectionId": "={{ $('Settings (Reminders)').item.json.wasyncConnectionId }}",
        "to": "={{ $json.UF_CRM_WHATSAPP_PHONE }}",
        "text": "=Hi! This is a friendly reminder that your invoice for \"{{ $json.TITLE }}\" ({{ $json.OPPORTUNITY }} {{ $json.CURRENCY_ID }}, due {{ $json.UF_CRM_DUE_DATE }}) is still awaiting payment. Reply *PAID* once you've sent it, and we'll confirm right away.",
        "additionalFields": {}
      },
      "name": "Send Payment Reminder on WhatsApp",
      "type": "n8n-nodes-wasync.wasync",
      "typeVersion": 1,
      "position": [
        960,
        606
      ],
      "credentials": {
        "wasyncApi": {
          "name": "WASync account"
        }
      }
    },
    {
      "parameters": {
        "events": [
          "message.received"
        ]
      },
      "name": "Receive WhatsApp Message",
      "type": "n8n-nodes-wasync.wasyncTrigger",
      "typeVersion": 1,
      "position": [
        0,
        1452
      ],
      "credentials": {
        "wasyncApi": {
          "name": "WASync account"
        }
      }
    },
    {
      "parameters": {
        "mode": "manual",
        "assignments": {
          "assignments": [
            {
              "id": "Settings (Payment Confirmation)-0",
              "name": "bitrixPortalUrl",
              "value": "https://yourportal.bitrix24.com",
              "type": "string"
            },
            {
              "id": "Settings (Payment Confirmation)-1",
              "name": "bitrixWebhookToken",
              "value": "REPLACE_WITH_YOUR_INBOUND_WEBHOOK_TOKEN",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "name": "Settings (Payment Confirmation)",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        0,
        1070
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "id": "Says Paid?-cond0",
              "leftValue": "={{ $('Receive WhatsApp Message').item.json.message.text.trim().toUpperCase() }}",
              "rightValue": "PAID",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            },
            {
              "id": "Says Paid?-cond1",
              "leftValue": "={{ $('Receive WhatsApp Message').item.json.message.text.trim() }}",
              "rightValue": "1",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "or"
        },
        "options": {}
      },
      "name": "Customer Says Paid?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        320,
        1452
      ]
    },
    {
      "parameters": {
        "method": "GET",
        "url": "={{ $('Settings (Payment Confirmation)').item.json.bitrixPortalUrl }}/rest/{{ $('Settings (Payment Confirmation)').item.json.bitrixWebhookToken }}/crm.contact.list",
        "options": {},
        "sendQuery": true,
        "specifyQuery": "keypair",
        "queryParameters": {
          "parameters": [
            {
              "name": "filter[PHONE]",
              "value": "={{ $('Receive WhatsApp Message').item.json.message.from }}"
            },
            {
              "name": "select[]",
              "value": "ID"
            }
          ]
        }
      },
      "name": "Find Contact in Bitrix24",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        640,
        1452
      ]
    },
    {
      "parameters": {
        "method": "GET",
        "url": "={{ $('Settings (Payment Confirmation)').item.json.bitrixPortalUrl }}/rest/{{ $('Settings (Payment Confirmation)').item.json.bitrixWebhookToken }}/crm.deal.list",
        "options": {},
        "sendQuery": true,
        "specifyQuery": "keypair",
        "queryParameters": {
          "parameters": [
            {
              "name": "filter[CONTACT_ID]",
              "value": "={{ $json.result && $json.result[0] ? $json.result[0].ID : '' }}"
            },
            {
              "name": "filter[CLOSED]",
              "value": "N"
            },
            {
              "name": "order[DATE_CREATE]",
              "value": "DESC"
            },
            {
              "name": "select[]",
              "value": "ID"
            }
          ]
        }
      },
      "name": "Find Open Deal in Bitrix24",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        960,
        1452
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{ $('Settings (Payment Confirmation)').item.json.bitrixPortalUrl }}/rest/{{ $('Settings (Payment Confirmation)').item.json.bitrixWebhookToken }}/crm.timeline.comment.add",
        "sendBody": true,
        "contentType": "json",
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ fields: { ENTITY_ID: ($json.result && $json.result[0] ? $json.result[0].ID : ''), ENTITY_TYPE: 'deal', COMMENT: 'Customer confirmed payment via WhatsApp (' + $('Receive WhatsApp Message').item.json.message.from + ')' } }) }}",
        "options": {}
      },
      "name": "Add Timeline Comment in Bitrix24",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1280,
        1452
      ]
    },
    {
      "parameters": {
        "resource": "message",
        "operation": "send",
        "connectionId": "={{ $('Receive WhatsApp Message').item.json.connection_id }}",
        "to": "={{ $('Receive WhatsApp Message').item.json.message.from }}",
        "text": "=Thank you for confirming your payment! We've noted it on your account.",
        "additionalFields": {}
      },
      "name": "Send Thank You on WhatsApp",
      "type": "n8n-nodes-wasync.wasync",
      "typeVersion": 1,
      "position": [
        1600,
        1452
      ],
      "credentials": {
        "wasyncApi": {
          "name": "WASync account"
        }
      }
    }
  ],
  "connections": {
    "Run Daily at 09:00": {
      "main": [
        [
          {
            "node": "Settings (Reminders)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Settings (Reminders)": {
      "main": [
        [
          {
            "node": "List Awaiting-Payment Deals in Bitrix24",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "List Awaiting-Payment Deals in Bitrix24": {
      "main": [
        [
          {
            "node": "Split Deals",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Deals": {
      "main": [
        [
          {
            "node": "Send Payment Reminder on WhatsApp",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Receive WhatsApp Message": {
      "main": [
        [
          {
            "node": "Settings (Payment Confirmation)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Settings (Payment Confirmation)": {
      "main": [
        [
          {
            "node": "Customer Says Paid?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Customer Says Paid?": {
      "main": [
        [
          {
            "node": "Find Contact in Bitrix24",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Find Contact in Bitrix24": {
      "main": [
        [
          {
            "node": "Find Open Deal in Bitrix24",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Find Open Deal in Bitrix24": {
      "main": [
        [
          {
            "node": "Add Timeline Comment in Bitrix24",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add Timeline Comment in Bitrix24": {
      "main": [
        [
          {
            "node": "Send Thank You on WhatsApp",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  }
}
