{
  "id": "MRS85XLwuma7aEeY",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "No-Show Appointment Recovery Bot",
  "tags": [],
  "nodes": [
    {
      "id": "1ac4eb6c-6300-4ae5-b853-314a1fd7e482",
      "name": "Hourly Check Trigger",
      "type": "n8n-nodes-base.cron",
      "position": [
        -1120,
        816
      ],
      "parameters": {
        "triggerTimes": {
          "item": [
            {
              "mode": "everyHour"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "2a5b2876-6fda-459b-b573-fcd354958dea",
      "name": "Get Active Calendly Appointments",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -896,
        816
      ],
      "parameters": {
        "url": "https://api.calendly.com/scheduled_events?user={{$env.CALENDLY_USER_URI}}&status=active",
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "a5008069-f79b-4ba8-a55f-5f7bedf187d4",
      "name": "Filter No-Show Appointments (30+ min past)",
      "type": "n8n-nodes-base.function",
      "position": [
        -656,
        816
      ],
      "parameters": {
        "functionCode": "const now = new Date();\nconst thresholdMinutes = 30;\n\nconst missed = [];\nfor (const item of items[0].json.collection) {\n  const endTime = new Date(item.end_time);\n  const diffMinutes = (now - endTime) / 60000;\n  if (diffMinutes > thresholdMinutes && !item.attended) {\n    missed.push({ json: item });\n  }\n}\nreturn missed;"
      },
      "typeVersion": 1
    },
    {
      "id": "a4c3136a-8697-48dc-ac99-42b126a38d29",
      "name": "Check If High Intent Lead",
      "type": "n8n-nodes-base.if",
      "position": [
        -416,
        816
      ],
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{ $json.metadata ? $json.metadata.contact_tags : '' }}",
              "value2": "High Intent",
              "operation": "contains"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "e9cfd82c-7632-4957-9133-a80f742f6ff0",
      "name": "Send Reschedule Link via Telegram",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -176,
        768
      ],
      "parameters": {
        "text": "Hi {{$json.invitee_name}}, we missed you on our call earlier!\\nYou can reschedule here: {{$json.uri}}\\n\u2014 Team Shoonya",
        "chatId": "={{ $json.metadata ? $json.metadata.telegram_id : '' }}",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "78f1d804-c3f8-48c5-87a0-6c15371470b1",
      "name": "Alert Sales Rep via Email",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        64,
        768
      ],
      "parameters": {
        "text": "The meeting with {{$json.invitee_name}} appears missed.\\nTelegram message sent successfully.\\nPlease follow up or reschedule here: {{$json.uri}}",
        "options": {},
        "subject": "Missed Appointment: {{$json.invitee_name}}",
        "toEmail": "={{ $json.metadata ? $json.metadata.rep_email : 'sales@yourcompany.com' }}",
        "fromEmail": "user@example.com"
      },
      "credentials": {
        "smtp": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "ec4bb9a0-b81e-450e-b640-b593c8223f33",
      "name": "Sticky Note - Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1488,
        448
      ],
      "parameters": {
        "width": 280,
        "height": 268,
        "content": "## \ud83d\ude80 WORKFLOW START\n\n**Purpose:** Automatically detect and recover no-show appointments\n\n**Trigger:** Runs every hour to check for missed meetings\n\n**Target:** High-intent leads who didn't attend their scheduled calls"
      },
      "typeVersion": 1
    },
    {
      "id": "51435d29-7443-496e-b7a2-c5eeec29509c",
      "name": "Sticky Note - Fetch",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1056,
        512
      ],
      "parameters": {
        "width": 280,
        "height": 284,
        "content": "## \ud83d\udcc5 STEP 1: Fetch Appointments\n\n**Action:** Retrieves all active scheduled events from Calendly\n\n**API Endpoint:** Calendly scheduled_events API\n\n**Data Retrieved:** Meeting details, invitee info, attendance status, metadata"
      },
      "typeVersion": 1
    },
    {
      "id": "4fe58a6e-b193-4fc7-b0c6-e83bf77521a8",
      "name": "Sticky Note - Filter",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -736,
        976
      ],
      "parameters": {
        "width": 280,
        "height": 268,
        "content": "## \ud83d\udd0d STEP 2: Identify No-Shows\n\n**Logic:** Filters appointments where:\n- Meeting ended 30+ minutes ago\n- Attendee did NOT show up (attended = false)\n\n**Output:** List of missed appointments only"
      },
      "typeVersion": 1
    },
    {
      "id": "0bf45c2b-5a96-452b-95e0-18a10ed3b56c",
      "name": "Sticky Note - Condition",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -576,
        512
      ],
      "parameters": {
        "width": 280,
        "height": 268,
        "content": "## \ud83c\udfaf STEP 3: Priority Check\n\n**Condition:** Only proceed if contact has \"High Intent\" tag\n\n**Why:** Focus recovery efforts on qualified leads\n\n**Source:** Checks metadata.contact_tags field"
      },
      "typeVersion": 1
    },
    {
      "id": "71b384d7-a800-468a-8c0d-142ebf28bd8c",
      "name": "Sticky Note - Telegram",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -256,
        960
      ],
      "parameters": {
        "width": 280,
        "height": 316,
        "content": "## \ud83d\udcac STEP 4: Customer Outreach\n\n**Action:** Sends friendly reschedule message via Telegram\n\n**Message Includes:**\n- Personalized greeting\n- Direct reschedule link\n- Company signature\n\n**Target:** Lead's Telegram ID from metadata"
      },
      "typeVersion": 1
    },
    {
      "id": "7446d041-d351-4419-8a15-bd5882e04361",
      "name": "Sticky Note - Email Alert",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -80,
        400
      ],
      "parameters": {
        "width": 280,
        "height": 348,
        "content": "## \ud83d\udce7 STEP 5: Internal Notification\n\n**Action:** Alerts assigned sales rep about the no-show\n\n**Email Contains:**\n- Customer name\n- Confirmation of Telegram message sent\n- Reschedule link for manual follow-up\n\n**Recipient:** Sales rep email from metadata"
      },
      "typeVersion": 1
    },
    {
      "id": "2e2db44b-f716-4771-91ff-72f11659383a",
      "name": "Sticky Note - Setup Requirements",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1472,
        1056
      ],
      "parameters": {
        "width": 280,
        "height": 300,
        "content": "## \u2699\ufe0f REQUIRED SETUP\n\n**Environment Variables:**\n- CALENDLY_USER_URI\n\n**Credentials:**\n- Telegram API (configured)\n- SMTP/Gmail (configured)\n\n**Metadata Fields Needed:**\n- contact_tags (for \"High Intent\")\n- telegram_id\n- rep_email"
      },
      "typeVersion": 1
    },
    {
      "id": "4ffa2f77-867d-4bc8-8b4b-c13aa86e0bae",
      "name": "Sticky Note - Benefits",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1472,
        768
      ],
      "parameters": {
        "width": 280,
        "height": 220,
        "content": "## \ud83d\udca1 KEY BENEFITS\n\n\u2705 Automatic no-show detection\n\u2705 Immediate customer re-engagement\n\u2705 Sales team stays informed\n\u2705 Prioritizes high-value leads\n\u2705 Reduces manual follow-up work\n\u2705 Increases reschedule rate"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "8b29c79b-4f82-41bb-9023-3b77e53e4ca0",
  "connections": {
    "Hourly Check Trigger": {
      "main": [
        [
          {
            "node": "Get Active Calendly Appointments",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check If High Intent Lead": {
      "main": [
        [
          {
            "node": "Send Reschedule Link via Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Active Calendly Appointments": {
      "main": [
        [
          {
            "node": "Filter No-Show Appointments (30+ min past)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Reschedule Link via Telegram": {
      "main": [
        [
          {
            "node": "Alert Sales Rep via Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter No-Show Appointments (30+ min past)": {
      "main": [
        [
          {
            "node": "Check If High Intent Lead",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}