{
  "id": "Z2eJyq6uEAO24JOc",
  "name": "Client Onboarding Packet Generator",
  "tags": [],
  "nodes": [
    {
      "id": "d425a090-753a-4de3-b207-f0bb4b56e266",
      "name": "Setup Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -848,
        -336
      ],
      "parameters": {
        "color": 5,
        "width": 788,
        "height": 1620,
        "content": "## \ud83d\udccb Client Onboarding Packet Generator\n\nReceives client intake data via webhook, generates a structured AI onboarding packet using GPT-4.1-mini, and saves a ready-to-review kickoff email as a Gmail draft.\n\n---\n\n## \u2699\ufe0f How It Works\n\n**1. Webhook - Client Intake**\nListens for a `POST` request from your intake form (Typeform, Tally, your website, etc.) carrying the client's details.\n\n**2. Prepare Client Intake**\nNormalises incoming fields into a clean object. Handles alternate field names gracefully \u2014 e.g. `name` \u2192 `client_name`, `email` \u2192 `client_email`.\n\n**3. OpenAI - Build Onboarding Packet**\nSends the cleaned intake to GPT-4.1-mini and returns a structured JSON packet with:\n- `project_brief` \u2014 a short summary paragraph\n- `success_metrics` \u2014 3 measurable outcomes\n- `kickoff_checklist` \u2014 5 actionable steps\n- `missing_information` \u2014 clarifying questions to ask\n- `first_week_plan` \u2014 Day 1, 2, 3 task breakdown\n- `kickoff_email` \u2014 subject line + plain text body\n\n**4. Parse Packet JSON**\nStrips markdown fences from the AI output and parses it into clean JSON. Falls back gracefully if parsing fails \u2014 preserves `raw_output` for debugging.\n\n**5. Gmail - Create Kickoff Draft**\nCreates a draft email in your Gmail addressed to the client's email. Ready for your review before sending \u2014 nothing is auto-sent.\n\n**6. Respond with Packet**\nReturns the full packet as a JSON response to the webhook caller, including `status`, `company`, and the complete `packet` object.\n\n---\n\n## \ud83d\udd27 Setup Checklist\n\n- [ ] Add your **OpenAI** credential to the OpenAI node\n- [ ] Connect your **Gmail OAuth2** credential to the Gmail node\n- [ ] Activate the workflow and copy the **webhook URL**\n- [ ] Point your intake form to the webhook URL as a `POST` request\n- [ ] Send a test submission with the fields listed below\n\n---\n\n## \ud83d\udce5 Webhook Input Fields\n\n| Field | Description |\n|---|---|\n| `client_name` | Full name of the client |\n| `client_email` | Client's email address |\n| `company` | Company or brand name |\n| `website` | Client's website URL |\n| `service` | Service or project type |\n| `goal` | Primary goal or objective |\n| `target_audience` | Who they're trying to reach |\n| `deadline` | Project deadline |\n| `budget` | Estimated budget |\n| `notes` | Any extra context |\n| `sender_name` | Your name (signs the email) |\n\n---\n\n## \u26a0\ufe0f Things to Know\n\n- AI temperature is set to `0.2` for consistent, structured output\n- If OpenAI returns malformed JSON, the raw output is preserved in `raw_output`\n- The Gmail draft is **never auto-sent** \u2014 always review before sending\n- You can swap the OpenAI node for Claude or Gemini with minimal changes."
      },
      "typeVersion": 1
    },
    {
      "id": "1518a249-7141-4ebb-ac22-7f2390935fe7",
      "name": "Webhook - Client Intake",
      "type": "n8n-nodes-base.webhook",
      "position": [
        320,
        320
      ],
      "parameters": {
        "path": "client-onboarding-packet",
        "options": {},
        "httpMethod": "POST",
        "responseMode": "responseNode"
      },
      "typeVersion": 2
    },
    {
      "id": "78292ba6-76de-4a6d-b9dd-2091845ac667",
      "name": "Prepare Client Intake",
      "type": "n8n-nodes-base.code",
      "position": [
        560,
        320
      ],
      "parameters": {
        "jsCode": "const body = $input.first().json.body || $input.first().json;\n\nconst intake = {\n  client_name: body.client_name || body.name || \"\",\n  client_email: body.client_email || body.email || \"\",\n  company: body.company || \"\",\n  website: body.website || \"\",\n  service: body.service || body.project_type || \"\",\n  goal: body.goal || body.primary_goal || \"\",\n  target_audience: body.target_audience || \"\",\n  deadline: body.deadline || \"\",\n  budget: body.budget || \"\",\n  notes: body.notes || body.context || \"\",\n  sender_name: body.sender_name || \"Your Name\"\n};\n\nreturn [{ json: { intake } }];"
      },
      "typeVersion": 2
    },
    {
      "id": "bb6dd5cc-0863-4d49-99d2-9c20f2a45a67",
      "name": "OpenAI - Build Onboarding Packet",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        752,
        320
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini",
          "cachedResultName": "gpt-4.1-mini"
        },
        "options": {
          "temperature": 0.2
        },
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "You create concise client onboarding packets for agencies and freelancers. Return only valid JSON. No markdown."
            },
            {
              "content": "=Create a client onboarding packet from this intake:\n{{ JSON.stringify($json.intake, null, 2) }}\n\nReturn this JSON shape:\n{\n  \"project_brief\": \"short paragraph\",\n  \"success_metrics\": [\"metric 1\", \"metric 2\", \"metric 3\"],\n  \"kickoff_checklist\": [\"step 1\", \"step 2\", \"step 3\", \"step 4\", \"step 5\"],\n  \"missing_information\": [\"question 1\", \"question 2\"],\n  \"first_week_plan\": [\n    {\"day\": \"Day 1\", \"task\": \"...\"},\n    {\"day\": \"Day 2\", \"task\": \"...\"},\n    {\"day\": \"Day 3\", \"task\": \"...\"}\n  ],\n  \"kickoff_email\": {\n    \"subject\": \"...\",\n    \"body\": \"plain text email with line breaks\"\n  }\n}"
            }
          ]
        }
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.4
    },
    {
      "id": "91e581f6-d2ee-4dc4-a556-fdd114fdb475",
      "name": "Parse Packet JSON",
      "type": "n8n-nodes-base.code",
      "position": [
        1088,
        320
      ],
      "parameters": {
        "jsCode": "const raw = $json.message?.content || $json.text || \"{}\";\nconst cleaned = raw.replace(/^```json\\s*/i, \"\").replace(/^```\\s*/i, \"\").replace(/```$/i, \"\").trim();\nlet packet;\ntry {\n  packet = JSON.parse(cleaned);\n} catch (error) {\n  packet = {\n    parse_warning: error.message,\n    raw_output: raw\n  };\n}\n\nconst intake = $(\"Prepare Client Intake\").first().json.intake;\nconst kickoffEmail = packet.kickoff_email || {};\nconst subject = kickoffEmail.subject || `Kickoff packet for ${intake.company || intake.client_name}`;\nconst message = kickoffEmail.body || raw;\n\nreturn [{\n  json: {\n    ...packet,\n    client_email: intake.client_email,\n    company: intake.company,\n    subject,\n    gmail_html: message.replace(/\\n/g, \"<br>\"),\n    publish_note: \"Replace the webhook test body with your own client intake form fields.\"\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "d79c1857-dbc9-4016-b389-dfcd89c5071c",
      "name": "Gmail - Create Kickoff Draft",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1344,
        320
      ],
      "parameters": {
        "message": "={{ .gmail_html }}",
        "options": {
          "sendTo": "={{ .client_email }}"
        },
        "subject": "={{ .subject }}",
        "resource": "draft",
        "emailType": "html"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "ae99de1c-b4dd-4b10-9fd4-14c092661730",
      "name": "Respond with Packet",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        1600,
        320
      ],
      "parameters": {
        "options": {},
        "respondWith": "json",
        "responseBody": "={{ { status: 'packet_created', company: Parse Packet JSON.first().json.company, draft_created: true, packet: Parse Packet JSON.first().json } }}"
      },
      "typeVersion": 1
    },
    {
      "id": "d0d4be70-890c-4ea6-8091-f5ebb54ffb46",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        256,
        256
      ],
      "parameters": {
        "color": 6,
        "width": 448,
        "height": 208,
        "content": "## Recieve client information"
      },
      "typeVersion": 1
    },
    {
      "id": "7592b5e7-037b-4d7e-9102-0e9ca339ec59",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        736,
        240
      ],
      "parameters": {
        "color": 6,
        "width": 304,
        "height": 208,
        "content": "## Create client onboarding packet\n"
      },
      "typeVersion": 1
    },
    {
      "id": "541c2f0d-75b9-49ae-b941-b01e40adecfc",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1264,
        272
      ],
      "parameters": {
        "color": 6,
        "width": 512,
        "height": 224,
        "content": "## Draft client Email and respond accordingly\n"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "executionOrder": "v1"
  },
  "versionId": "b8f05956-13a5-4ed2-bf5e-1b465cd69a58",
  "connections": {
    "Parse Packet JSON": {
      "main": [
        [
          {
            "node": "Gmail - Create Kickoff Draft",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Client Intake": {
      "main": [
        [
          {
            "node": "OpenAI - Build Onboarding Packet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook - Client Intake": {
      "main": [
        [
          {
            "node": "Prepare Client Intake",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail - Create Kickoff Draft": {
      "main": [
        [
          {
            "node": "Respond with Packet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI - Build Onboarding Packet": {
      "main": [
        [
          {
            "node": "Parse Packet JSON",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}