{
  "name": "Schedule an interview from an application",
  "nodes": [
    {
      "parameters": {
        "content": "## Schedule an interview from an application\n\nPortfolio demo only. This workflow is an original example for demonstration. It is not client work and it does not represent a deployment for any customer.\n\nRun **Run demo** to execute the offline rules engine. The live branch is used only when the incoming item sets `demo` to false and the placeholder credentials have been replaced.",
        "height": 220,
        "width": 520,
        "color": 4
      },
      "id": "e99009ed-7a63-4064-943f-45f7adaf1f46",
      "name": "Overview",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -40,
        -40
      ]
    },
    {
      "parameters": {},
      "id": "bb8d2469-7201-470e-9a93-e7e6649e9226",
      "name": "Run demo",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        40,
        280
      ],
      "notes": "CLI and the n8n editor start here. An empty manual run loads the bundled sample.",
      "notesInFlow": true
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "interview-schedule-from-application",
        "authentication": "none",
        "responseMode": "lastNode",
        "responseData": "firstEntryJson",
        "options": {}
      },
      "id": "42fb687b-7495-4dcc-860e-23afdbef4752",
      "name": "Inbound webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        40,
        460
      ],
      "notes": "POST JSON to this path. Include demo:false only after credentials are connected.",
      "notesInFlow": true,
      "webhookId": "0883d5f7-2ca9-4b90-b7b4-c9edf86a8a19"
    },
    {
      "parameters": {
        "mode": "runOnceForAllItems",
        "language": "javaScript",
        "jsCode": "const sample = {\n  \"demo\": true,\n  \"name\": \"Leila Haddad\",\n  \"email\": \"leila@example.com\",\n  \"role\": \"Automation engineer\",\n  \"years\": 5,\n  \"workAuth\": true,\n  \"resumeText\": \"Five years building JavaScript services, SQL reporting, and n8n workflows for HubSpot teams.\",\n  \"start\": \"2026-12-04T16:00:00.000Z\",\n  \"end\": \"2026-12-04T16:30:00.000Z\",\n  \"status\": \"booked\",\n  \"phone\": \"+15555550155\",\n  \"title\": \"Interview with Leila Haddad\"\n};\nconst incoming = $input.first()?.json ?? {};\nconst provided = Object.keys(incoming).filter((key) => incoming[key] !== undefined && incoming[key] !== null && incoming[key] !== '');\nconst base = provided.length ? { ...sample, ...incoming } : { ...sample };\nconst flag = incoming.demo;\nbase.demo = !(flag === false || flag === 'false' || flag === 0 || flag === '0');\nreturn [{ json: base }];\n"
      },
      "id": "ae184971-5234-4082-a005-418141a21a9a",
      "name": "Normalize input",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        340,
        360
      ],
      "notes": "Merges the request over the bundled sample. demo stays true unless the caller explicitly turns it off.",
      "notesInFlow": true
    },
    {
      "parameters": {
        "mode": "runOnceForAllItems",
        "language": "javaScript",
        "jsCode": "const item = $input.first().json;\nconst produced = (() => {\n\nconst start = Date.parse(item.start || item.startsAt || '');\nconst status = String(item.status || 'booked').toLowerCase();\nconst offsets = ['24h'];\nconst hours = { '24h': 24, '2h': 2, '1h': 1, '15m': 0.25 };\nconst reminders = offsets.map((offset) => ({\n  offset,\n  sendAt: Number.isNaN(start) ? null : new Date(start - (hours[offset] || 1) * 3600 * 1000).toISOString(),\n  channel: item.phone ? 'sms' : 'email',\n}));\nlet route = 'schedule';\nif (status === 'canceled' || status === 'cancelled') route = 'reschedule';\nelse if (status === 'no-show') route = 'recover';\nelse if (Number.isNaN(start)) route = 'missing-time';\nconst record = {\n  email: item.email || '',\n  phone: item.phone || '',\n  to: item.phone || '',\n  title: item.title || 'Appointment',\n  start: item.start || item.startsAt || '',\n  end: item.end || '',\n  status,\n  reminders,\n  message: 'Reminder: ' + (item.title || 'your appointment') + ' at ' + (item.start || item.startsAt || 'the scheduled time') + '.',\n};\nreturn {\n  summary: record.title + ' for ' + (record.email || record.phone || 'the guest') + ' is ' + route + '.',\n  route,\n  record,\n  slackText: route.toUpperCase() + ' \u2014 ' + record.title + ' (' + (record.start || 'unscheduled') + ')',\n  actions: reminders.map((reminder) => ({ app: reminder.channel, operation: 'remind', payload: reminder })),\n};\n\n})();\nif (!produced || typeof produced.summary !== 'string' || !produced.summary.trim()) {\n  throw new Error('Apply rules must return a summary string');\n}\nreturn [{\n  json: {\n    ...item,\n    ...produced,\n    demo: item.demo !== false,\n  },\n}];\n"
      },
      "id": "a0be4991-a9bc-4908-a529-c3678c352343",
      "name": "Apply rules",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        620,
        360
      ],
      "notes": "Deterministic stand-in for the model or enrichment API. Replace or precede this with a live model node when you turn demo mode off.",
      "notesInFlow": true
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "97b076df-d703-40a4-8edb-9a1a7bede0be",
              "leftValue": "={{ $json.demo }}",
              "rightValue": true,
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "90b48c1e-229f-4f5c-81e5-660e4301e804",
      "name": "Demo mode?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        900,
        360
      ],
      "notes": "True: package the offline result. False: run the credentialed apps.",
      "notesInFlow": true
    },
    {
      "parameters": {
        "mode": "runOnceForAllItems",
        "language": "javaScript",
        "jsCode": "const item = $input.first().json;\nreturn [{\n  json: {\n    demo: true,\n    status: 'demo_ready',\n    workflow: 'interview-schedule-from-application',\n    summary: item.summary,\n    route: item.route ?? null,\n    record: item.record ?? {},\n    actions: item.actions ?? [],\n    slackText: item.slackText ?? item.summary,\n    notes: 'Demo mode did not call external apps. Send {\"demo\": false} after placeholder credentials are replaced.',\n  },\n}];\n"
      },
      "id": "18970773-8486-4c9f-ac5d-63aa88ee1faf",
      "name": "Package demo result",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1180,
        180
      ]
    },
    {
      "parameters": {
        "resource": "event",
        "operation": "create",
        "calendar": {
          "__rl": true,
          "mode": "id",
          "value": "calendar@example.com"
        },
        "start": "={{ $json.record.start }}",
        "end": "={{ $json.record.end }}",
        "additionalFields": {
          "summary": "={{ $json.record.title || $json.summary }}"
        }
      },
      "id": "5699c282-9c19-4a45-9a3b-a7a78005d5c3",
      "name": "Create calendar event",
      "type": "n8n-nodes-base.googleCalendar",
      "typeVersion": 1.3,
      "position": [
        1180,
        760
      ],
      "credentials": {
        "googleCalendarOAuth2Api": {
          "id": "PLACEHOLDER_GOOGLECALENDAROAUTH2API",
          "name": "Google Calendar account"
        }
      }
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "resource": "draft",
        "operation": "create",
        "sendTo": "={{ $json.record.email || $json.email || 'lead@example.com' }}",
        "subject": "={{ $json.record.subject || $json.summary }}",
        "message": "={{ $json.record.body || $json.record.message || $json.summary }}",
        "emailType": "text",
        "messageId": "={{ $json.record.messageId || 'MESSAGE_ID' }}",
        "labelIds": [
          "Label_1"
        ]
      },
      "id": "98109f1c-ae73-48f6-a943-d5b7f5a0447b",
      "name": "Create Gmail draft",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        1460,
        760
      ],
      "credentials": {
        "gmailOAuth2": {
          "id": "PLACEHOLDER_GMAILOAUTH2",
          "name": "Gmail account"
        }
      }
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "resource": "sheet",
        "operation": "append",
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "YOUR_SPREADSHEET_ID"
        },
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "Interviews"
        },
        "columns": {
          "mappingMode": "autoMapInputData",
          "value": {},
          "matchingColumns": [],
          "schema": []
        },
        "options": {}
      },
      "id": "f852c2dd-9e1b-4f6b-965b-befc255344f1",
      "name": "Append Interviews",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        1740,
        760
      ],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "PLACEHOLDER_GOOGLESHEETSOAUTH2API",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "content": "## Live path\n\nReplace every `PLACEHOLDER_*` credential, then POST the sample with `\"demo\": false`.\n\nThe nodes on this branch use the `record` and `actions` fields produced by Apply rules.",
        "height": 180,
        "width": 420,
        "color": 6
      },
      "id": "cb07ea7b-5c2b-4208-83ac-cb43cf359855",
      "name": "Live path",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1120,
        520
      ]
    }
  ],
  "connections": {
    "Run demo": {
      "main": [
        [
          {
            "node": "Normalize input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Inbound webhook": {
      "main": [
        [
          {
            "node": "Normalize input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize input": {
      "main": [
        [
          {
            "node": "Apply rules",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Apply rules": {
      "main": [
        [
          {
            "node": "Demo mode?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Demo mode?": {
      "main": [
        [
          {
            "node": "Package demo result",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Create calendar event",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create calendar event": {
      "main": [
        [
          {
            "node": "Create Gmail draft",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Gmail draft": {
      "main": [
        [
          {
            "node": "Append Interviews",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "meta": {
    "templateCredsSetupCompleted": false,
    "description": "A candidate who already scored as a screen is offered a calendar hold and a confirmation draft."
  },
  "active": false
}
