{
  "id": "76LqncXo7HU6frDp",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Send Tour Payment Reminders with Payment Links",
  "tags": [],
  "nodes": [
    {
      "id": "33b5aa5a-20c2-4394-8136-427abc8fb678",
      "name": "Prepare WhatsApp Reminder",
      "type": "n8n-nodes-base.code",
      "position": [
        720,
        336
      ],
      "parameters": {
        "jsCode": "const tourData = $input.first().json;\n\nconst whatsappMessage = `\u2708\ufe0f *Tour Payment Reminder*\\n\\nDear ${tourData.travelerName},\\n\\n\ud83d\udcb0 Payment for *${tourData.tourName}*\\n\ud83d\udcb5 Amount Due: $${tourData.amountDue}\\n\ud83d\udcc5 Tour Date: ${tourData.tourDate}\\n\u23f0 ${tourData.daysRemaining} days remaining\\n\\n\ud83d\udd17 *Pay Now:* ${tourData.paymentLink}\\n\\n_Please complete the payment before the tour to secure your booking._\\n\\nTravel Agency`;\n\nreturn [{\n  json: {\n    phone: tourData.phone,\n    message: whatsappMessage,\n    travelerName: tourData.travelerName,\n    tourName: tourData.tourName,\n    paymentLink: tourData.paymentLink\n  }\n}];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "a8e0a132-88d4-4f04-9fe9-f2d2efe8cb89",
      "name": "Update Reminder Status",
      "type": "n8n-nodes-base.microsoftExcel",
      "position": [
        1168,
        336
      ],
      "parameters": {
        "options": {},
        "dataMode": "autoMap",
        "resource": "worksheet",
        "workbook": {
          "__rl": true,
          "mode": "id",
          "value": "=fee-records-workbook"
        },
        "operation": "update",
        "worksheet": {
          "__rl": true,
          "mode": "id",
          "value": "=345yhhgt43wedf"
        },
        "columnToMatchOn": "=name"
      },
      "credentials": {
        "microsoftExcelOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "030b1fe5-b3e6-4243-8902-35f7c2b77c93",
      "name": "Read Pending Travel Payment",
      "type": "n8n-nodes-base.microsoftExcel",
      "position": [
        272,
        336
      ],
      "parameters": {
        "filters": {
          "fields": [
            {
              "value": "Pending",
              "column": "Status"
            }
          ]
        },
        "resource": "worksheet",
        "workbook": {
          "__rl": true,
          "mode": "id",
          "value": "=nhjiko987uyhn"
        }
      },
      "credentials": {
        "microsoftExcelOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "2e32c9a2-2415-4efd-913f-c050c70e68d0",
      "name": "Daily Payment Check - 7 AM",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        48,
        336
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 7
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "dd933644-7cb7-4f7a-a46e-c607f53373ba",
      "name": "Process Payment Reminders",
      "type": "n8n-nodes-base.code",
      "position": [
        496,
        336
      ],
      "parameters": {
        "jsCode": "const currentDate = new Date();\nconst reminderDate = new Date();\nreminderDate.setDate(currentDate.getDate() + 3); // Remind 3 days before tour/payment\n\nconst tourRecords = $input.all(); // All tour booking records\nconst reminders = [];\n\nfor (const record of tourRecords) {\n  const tourData = record.json;\n  const tourDate = new Date(tourData.tourDate); // Tour start date\n  \n  if (tourDate <= reminderDate && tourDate > currentDate) {\n    const paymentLink = `https://payments.travelplatform.com/pay?traveler=${tourData.travelerId}&amount=${tourData.amountDue}&ref=${tourData.bookingId}`;\n    \n    reminders.push({\n      travelerName: tourData.travelerName,\n      email: tourData.email,\n      phone: tourData.phone,\n      tourName: tourData.tourName,\n      amountDue: tourData.amountDue,\n      tourDate: tourData.tourDate,\n      bookingId: tourData.bookingId,\n      paymentLink: paymentLink,\n      daysRemaining: Math.ceil((tourDate - currentDate) / (1000 * 60 * 60 * 24))\n    });\n  }\n}\n\nreturn reminders.map(item => ({ json: item }));\n"
      },
      "typeVersion": 2
    },
    {
      "id": "64d6d6f9-e19c-4d13-a13f-301f3d22aadc",
      "name": "Send Email Reminder",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        944,
        560
      ],
      "parameters": {
        "text": "={{$json.body}}",
        "options": {},
        "subject": "={{$json.subject}}",
        "toEmail": "={{$json.to}}",
        "fromEmail": "user@example.com",
        "emailFormat": "text"
      },
      "credentials": {
        "smtp": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "d32a00bb-ce08-46b8-9f99-74a85c1b21de",
      "name": "Daily Payment Check - 7 PM",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        48,
        560
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 19
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "5fe702d0-d962-4079-8a34-db870a2dc713",
      "name": "Check Pending Payment",
      "type": "n8n-nodes-base.microsoftExcel",
      "position": [
        272,
        560
      ],
      "parameters": {
        "filters": {
          "fields": [
            {
              "value": "Pending",
              "column": "Status"
            }
          ]
        },
        "resource": "worksheet",
        "workbook": {
          "__rl": true,
          "mode": "id",
          "value": "=nhjiko987uyhn"
        }
      },
      "credentials": {
        "microsoftExcelOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "e9624483-19b9-4008-88b7-281545886494",
      "name": "Create Payment Reminders",
      "type": "n8n-nodes-base.code",
      "position": [
        496,
        560
      ],
      "parameters": {
        "jsCode": "const currentDate = new Date();\nconst reminderDate = new Date();\nreminderDate.setDate(currentDate.getDate() + 3); // Remind 3 days before tour/payment\n\nconst tourRecords = $input.all(); // All tour booking records\nconst reminders = [];\n\nfor (const record of tourRecords) {\n  const tourData = record.json;\n  const tourDate = new Date(tourData.tourDate); // Tour start date\n  \n  if (tourDate <= reminderDate && tourDate > currentDate) {\n    const paymentLink = `https://payments.travelplatform.com/pay?traveler=${tourData.travelerId}&amount=${tourData.amountDue}&ref=${tourData.bookingId}`;\n    \n    reminders.push({\n      travelerName: tourData.travelerName,\n      email: tourData.email,\n      phone: tourData.phone,\n      tourName: tourData.tourName,\n      amountDue: tourData.amountDue,\n      tourDate: tourData.tourDate,\n      bookingId: tourData.bookingId,\n      paymentLink: paymentLink,\n      daysRemaining: Math.ceil((tourDate - currentDate) / (1000 * 60 * 60 * 24))\n    });\n  }\n}\n\nreturn reminders.map(item => ({ json: item }));\n"
      },
      "typeVersion": 2
    },
    {
      "id": "2a2c09fa-9d44-43e9-96cc-cad33f8fb39f",
      "name": "Make Reminder For Email",
      "type": "n8n-nodes-base.code",
      "position": [
        720,
        560
      ],
      "parameters": {
        "jsCode": "const tourData = $input.first().json;\n\nconst email = `\u2708\ufe0f *Tour Payment Reminder*\\n\\nDear ${tourData.travelerName},\\n\\n\ud83d\udcb0 Payment for *${tourData.tourName}*\\n\ud83d\udcb5 Amount Due: $${tourData.amountDue}\\n\ud83d\udcc5 Tour Date: ${tourData.tourDate}\\n\u23f0 ${tourData.daysRemaining} days remaining\\n\\n\ud83d\udd17 *Pay Now:* ${tourData.paymentLink}\\n\\n_Please complete the payment before the tour to secure your booking._\\n\\nTravel Agency`;\n\nreturn [{\n  json: {\n    phone: tourData.phone,\n    message: email,\n    travelerName: tourData.travelerName,\n    tourName: tourData.tourName,\n    paymentLink: tourData.paymentLink\n  }\n}];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "fae21a72-36cf-478d-9906-4d97d0e4469c",
      "name": "Send Message",
      "type": "n8n-nodes-base.whatsApp",
      "position": [
        944,
        336
      ],
      "parameters": {
        "textBody": "={{$json.body}}",
        "operation": "send",
        "phoneNumberId": "=+919388776655",
        "additionalFields": {},
        "recipientPhoneNumber": "={{$json.toforwp}}"
      },
      "credentials": {
        "whatsAppApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "e4b973e6-1cb5-4fe0-91a6-72ae9d262747",
      "name": "Update Status Of Reminder",
      "type": "n8n-nodes-base.microsoftExcel",
      "position": [
        1168,
        560
      ],
      "parameters": {
        "options": {},
        "dataMode": "autoMap",
        "resource": "worksheet",
        "workbook": {
          "__rl": true,
          "mode": "id",
          "value": "=fee-records-workbook"
        },
        "operation": "update",
        "worksheet": {
          "__rl": true,
          "mode": "id",
          "value": "=345yhhgt43wedf"
        },
        "columnToMatchOn": "=name"
      },
      "credentials": {
        "microsoftExcelOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "80be7c99-ff21-4c7a-9576-0d03ba231628",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        368,
        -176
      ],
      "parameters": {
        "color": 4,
        "width": 608,
        "height": 192,
        "content": "## \ud83d\ude80 Key Features\n- \u23f0 Scheduled Daily Execution \u2013 Fully automated at 7 AM and 7 PM  \n- \ud83e\uddee Due-Date Filtering \u2013 Only targets payments due in the next 3 days  \n- \ud83d\udcac Multi-Channel Notifications \u2013 Sends reminders via both Email and WhatsApp  \n- \ud83d\udd17 Secure Payment Links \u2013 Auto-generated for each traveler  \n- \ud83d\udd04 Reminder Tracking \u2013 Prevents duplicate reminders by updating status  "
      },
      "typeVersion": 1
    },
    {
      "id": "5411a3c8-b897-46f5-a71d-3d154738ceb1",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        368,
        -400
      ],
      "parameters": {
        "color": 3,
        "width": 608,
        "height": 192,
        "content": "## Description:\n\nThis workflow automatically notifies travelers about their pending trip payments and provides secure payment links through Email and WhatsApp. It runs twice daily (at 7 AM and 7 PM) to ensure timely reminders before the due date. Designed for travel agencies, it simplifies payment tracking, reduces manual follow-up, and ensures every traveler receives personalized reminders with real-time payment status updates."
      },
      "typeVersion": 1
    },
    {
      "id": "cb85e01a-051c-4d26-b6f7-d2fb8bf43708",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1072,
        -336
      ],
      "parameters": {
        "color": 5,
        "width": 608,
        "height": 288,
        "content": "## Purpose:\n\nThis workflow ensures automated, accurate, and timely payment reminders, helping travel agencies:\n\n- Maintain smooth cash flow\n\n- Minimize overdue payments\n\n- Provide a professional and automated customer communication experience"
      },
      "typeVersion": 1
    },
    {
      "id": "7dd63f3c-14bd-4a6c-b4f5-0c5be5a57546",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -448,
        32
      ],
      "parameters": {
        "width": 784,
        "height": 432,
        "content": "## Morning Flow (7 AM)\n\n- Daily Payment Check \u2013 7 AM:\nScheduled trigger initiates the process.\n\n- Read Pending Travel Payment:\nReads all pending payment records from the Google Sheet.\n\n- Process Payment Reminders:\nFilters records based on due date and payment status.\n\n- Prepare WhatsApp Reminder:\nFormats personalized message content with traveler name, amount, due date, and secure payment link.\n\n- Send Message:\nSends the WhatsApp message automatically.\n\n- Update Reminder Status:\nUpdates the record in the Google Sheet as \u201cReminder Sent\u201d."
      },
      "typeVersion": 1
    },
    {
      "id": "8a167f62-bc36-4940-9a14-fcedb0696c64",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -448,
        544
      ],
      "parameters": {
        "color": 6,
        "width": 784,
        "height": 432,
        "content": "## Evening Flow (7 PM)\n\n- Daily Payment Check \u2013 7 PM:\nScheduled trigger for the evening run.\n\n- Check Pending Payment:\nReads pending payment data again to catch newly added records.\n\n- Create Payment Reminders:\nFilters and prepares records for reminder generation.\n\n- Make Reminder For Email:\nCreates customized email content for each traveler.\n\n- Send Email Reminder:\nSends the email reminders with payment details and link.\n\n- Update Status Of Reminder:\nUpdates the traveler\u2019s record to avoid duplicate notifications."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "ad02aa2c-8239-46d8-9be1-0508458f6ac1",
  "connections": {
    "Send Message": {
      "main": [
        [
          {
            "node": "Update Reminder Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Email Reminder": {
      "main": [
        [
          {
            "node": "Update Status Of Reminder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Pending Payment": {
      "main": [
        [
          {
            "node": "Create Payment Reminders",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Make Reminder For Email": {
      "main": [
        [
          {
            "node": "Send Email Reminder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Payment Reminders": {
      "main": [
        [
          {
            "node": "Make Reminder For Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare WhatsApp Reminder": {
      "main": [
        [
          {
            "node": "Send Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Process Payment Reminders": {
      "main": [
        [
          {
            "node": "Prepare WhatsApp Reminder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Daily Payment Check - 7 AM": {
      "main": [
        [
          {
            "node": "Read Pending Travel Payment",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Daily Payment Check - 7 PM": {
      "main": [
        [
          {
            "node": "Check Pending Payment",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read Pending Travel Payment": {
      "main": [
        [
          {
            "node": "Process Payment Reminders",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}