{
  "id": "VpVyNGlpxalLtHP9",
  "name": "SLA Breach Alerts",
  "tags": [],
  "nodes": [
    {
      "id": "fa7fabe9-ef90-43ec-be27-967d0c799f66",
      "name": "Every 5 Minutes",
      "type": "n8n-nodes-base.cron",
      "position": [
        -1456,
        112
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "2d70b5ab-2d7d-42ae-a29f-bfe28e8755f2",
      "name": "SLA Breach Check",
      "type": "n8n-nodes-base.if",
      "position": [
        -976,
        112
      ],
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{ $json.Status }}",
              "value2": "unreplied"
            }
          ],
          "dateTime": [
            {
              "value1": "={{ new Date(Date.now() - 15 * 60 * 1000) }}",
              "value2": "={{ Date.now() }}",
              "operation": "before"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "d3ba740b-efee-4bf5-bdb1-f7e84925460b",
      "name": "Get row(s) in sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -1216,
        112
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 540316831,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/17rcNd_ZpUQLm0uWEVbD-NY6GyFUkrD4BglvawlyBygM/edit#gid=540316831",
          "cachedResultName": "sample_leads_50"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "17rcNd_ZpUQLm0uWEVbD-NY6GyFUkrD4BglvawlyBygM",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/17rcNd_ZpUQLm0uWEVbD-NY6GyFUkrD4BglvawlyBygM/edit?usp=drivesdk",
          "cachedResultName": "sample_leads_50"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4
    },
    {
      "id": "66afc02d-a12f-4db6-9528-3cf5b621ee1e",
      "name": "Send a text message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -432,
        96
      ],
      "parameters": {
        "text": "=\ud83d\udea8 SLA BREACH ALERT\n\nCompany: {{ $json['Company Name'] }}\nContact: {{ $json['Contact Person'] }}\nPosition: {{ $json['Job Title'] }}\nIndustry: {{ $json.Industry }}\nLocation: {{ $json.Location }}\n\nEmail: {{ $json.Email }}\nPhone: {{ $json.Phone }}\nSource: {{ $json['Lead Source'] }}\n\nStatus: {{ $json.Status === 'unreplied' ? 'UNREPLIED \u274c' : $json.Status.toUpperCase() + ' \u2705' }}\nBooking: {{ $json['Booking Status'] === 'Unbooked' ? 'UNBOOKED \ud83d\udd34' : $json['Booking Status'].toUpperCase() + ' \ud83d\udfe2' }}\n\nIMMEDIATE ACTION REQUIRED\nThis lead needs attention to maintain SLA compliance!\n\nLead ID: #{{ $json.row_number }}\n\nView Details: {{ $json.link }}",
        "chatId": "=963318735",
        "additionalFields": {
          "parse_mode": "HTML"
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "3dda9d02-7920-432e-bf43-ecaa8a8a94ab",
      "name": "Code1",
      "type": "n8n-nodes-base.code",
      "position": [
        -688,
        96
      ],
      "parameters": {
        "jsCode": "const inputData = $input.all();\nconst outputData = [];\n\nfor (const item of inputData) {\n  const data = item.json;\n  \n  // Pass all data as-is and just add the link field\n  const passedData = {\n    ...data, // Keep everything exactly as it was\n    link: \"https://docs.google.com/spreadsheets/d/17rcNd_ZpUQLm0uWEVbD-NY6GyFUkrD4BglvawlyBygM/edit?gid=540316831#gid=540316831\" // Add your link here\n  };\n  \n  outputData.push({ json: passedData });\n}\n\nreturn outputData;"
      },
      "typeVersion": 2
    },
    {
      "id": "9d5033e4-5b03-4c86-985e-d686f48bf030",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -464,
        272
      ],
      "parameters": {
        "color": 5,
        "height": 192,
        "content": "This node sends a Telegram notification whenever an SLA breach is detected. The message includes the lead\u2019s personal details and a clickable Google Sheet link. This helps the team act fast, preventing unattended leads and reducing response delays."
      },
      "typeVersion": 1
    },
    {
      "id": "e8113032-96c0-4fd5-9a24-e8ee72fb19c6",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -752,
        -112
      ],
      "parameters": {
        "color": 4,
        "content": "This node enriches the output by adding a direct link to the Google Sheet row. This ensures that when the alert is sent, the recipient can quickly open the sheet and view all the lead details in one click."
      },
      "typeVersion": 1
    },
    {
      "id": "2b731ed5-8d37-4df6-b708-9db6f105a36c",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1040,
        272
      ],
      "parameters": {
        "color": 3,
        "content": "This node applies the condition to filter leads that remain \u201cUnreplied\u201d for more than 15 minutes. If the condition is true, it passes them to the next step for escalation."
      },
      "typeVersion": 1
    },
    {
      "id": "3f2dd2cd-4fcc-4da2-85ae-5ba4d06ab20c",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1296,
        -96
      ],
      "parameters": {
        "color": 2,
        "content": "This node fetches all lead data from Google Sheets. It acts as the data source where information like lead status, contact details, and timestamps are retrieved and passed forward."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "be7b96f3-5ebf-4a8e-93d5-e8de10f8519b",
  "connections": {
    "Code1": {
      "main": [
        [
          {
            "node": "Send a text message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Every 5 Minutes": {
      "main": [
        [
          {
            "node": "Get row(s) in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "SLA Breach Check": {
      "main": [
        [
          {
            "node": "Code1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get row(s) in sheet": {
      "main": [
        [
          {
            "node": "SLA Breach Check",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send a text message": {
      "main": [
        []
      ]
    }
  }
}