{
  "name": "Onboarding Automation",
  "nodes": [
    {
      "parameters": {
        "formTitle": "Feedback Form",
        "formDescription": "We would love to hear from you!",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Name",
              "requiredField": true
            },
            {
              "fieldLabel": "Email",
              "fieldType": "email",
              "requiredField": true
            },
            {
              "fieldLabel": "Company Industry",
              "requiredField": true
            },
            {
              "fieldLabel": "What do you want to achieve with us in 5 months?",
              "requiredField": true
            }
          ]
        },
        "options": {
          "appendAttribution": false
        }
      },
      "id": "a2fca756-f95b-4d6e-8170-412303e28b26",
      "name": "On form submission",
      "type": "n8n-nodes-base.formTrigger",
      "typeVersion": 2.6,
      "position": [
        0,
        0
      ],
      "webhookId": "RECONNECT_FORM_TRIGGER"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=Can you generate a warm and professional welcome email for a new client based on the information provided?\nThe message should be friendly, brief, and personalized—while still sounding professional.\nIt should reflect the client’s industry and their goals for our collaboration. Below is the client’s information:\nName: {{ $json.Name }}\nEmail: {{ $json.Email }}\nCompany Industry: {{ $json['Company Industry'] }}\nGoals for the Partnership: {{ $json['What do you want to achieve with us in 5 months?'] }}\nMake sure to always end the email with the following sign-off:\nBest regards,\nThe onboarding team\nClient success\n[Your organisation]\nDo not use placeholders like [Your Name] or\n[Your Contact Information] under any circumstances, even if some information is missing.\nReturn the result in 3 separate fields:\nSubject: The email’s subject line\nBody: The main email content\nEmail: {{ $json.Email }}",
        "options": {}
      },
      "id": "ddc63428-4a46-4098-8194-0e5f2cb4fb9e",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 3.1,
      "position": [
        224,
        -144
      ]
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=Use the client details below to generate a clear summary of their profile. Here is the information provided:{{ $json['What do you want to achieve with us in 5 months?'] }}\nName:{{ $json.Name }}\nCompany Industry:{{ $json['Company Industry'] }}\nGoals with Us: What they are hoping to achieve through our partnership\nReturn the following fields separately:\nName:{{ $json.Name }}\nEmail: {{ $json.Email }}\nSummary: A concise overview of the client based on the information provided above",
        "options": {}
      },
      "id": "33645d8c-c212-42fd-9bed-4850a1f211af",
      "name": "AI Agent1",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 3.1,
      "position": [
        224,
        144
      ]
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "value": "gpt-4.1",
          "mode": "list",
          "cachedResultName": "gpt-4.1",
          "cachedResultUrl": ""
        },
        "builtInTools": {},
        "options": {}
      },
      "id": "5f80eb6c-e195-427f-88cf-17f4e11d2083",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.3,
      "position": [
        224,
        16
      ],
      "credentials": {
        "openAiApi": {
          "id": null,
          "name": "",
          "__aiGatewayManaged": true
        }
      }
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "value": "gpt-4.1",
          "mode": "list",
          "cachedResultName": "gpt-4.1",
          "cachedResultUrl": ""
        },
        "builtInTools": {},
        "options": {}
      },
      "id": "6579a334-b5d8-46e1-956e-d9550eb3c405",
      "name": "OpenAI Chat Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.3,
      "position": [
        176,
        336
      ],
      "credentials": {
        "openAiApi": {
          "id": null,
          "name": "",
          "__aiGatewayManaged": true
        }
      }
    },
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "value": "gpt-4.1",
          "mode": "list",
          "cachedResultName": "GPT-4.1",
          "cachedResultUrl": ""
        },
        "responses": {
          "values": [
            {
              "content": "={{ $json.output }}"
            },
            {
              "role": "system",
              "content": "=You are a JSON extractor. From the input text, extract the email's subject line, the body, and the recipient email address.\n\nReturn ONLY a single valid JSON object, with no markdown, no code fences, and no extra commentary. Use exactly these keys:\n{\"name\": \"...\", \"email\": \"...\", \"summary\": \"...\"}\n\nPreserve line breaks in the body using \\n. Do not add any text before or after the JSON object."
            }
          ]
        },
        "builtInTools": {},
        "options": {}
      },
      "id": "df99b4b0-1aa9-45bb-8db8-a5ab98909625",
      "name": "Message a model1",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 2.3,
      "position": [
        512,
        144
      ],
      "credentials": {
        "openAiApi": {
          "id": null,
          "name": "",
          "__aiGatewayManaged": true
        }
      }
    },
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "value": "gpt-4.1",
          "mode": "list",
          "cachedResultName": "GPT-4.1",
          "cachedResultUrl": ""
        },
        "responses": {
          "values": [
            {
              "role": "system",
              "content": "You are a JSON extractor. From the input text, extract the email's subject line, the body, and the recipient email address.\n\nReturn ONLY a single valid JSON object, with no markdown, no code fences, and no extra commentary. Use exactly these keys:\n{\"subject\": \"...\", \"body\": \"...\", \"email\": \"...\"}\n\nPreserve line breaks in the body using \\n. Do not add any text before or after the JSON object."
            },
            {
              "content": "={{ $json.output }}"
            }
          ]
        },
        "builtInTools": {},
        "options": {}
      },
      "id": "6ffa97bb-68d3-41c6-9f8a-33f1e2ff8a4a",
      "name": "Message a model",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 2.3,
      "position": [
        592,
        -144
      ],
      "credentials": {
        "openAiApi": {
          "id": null,
          "name": "",
          "__aiGatewayManaged": true
        }
      }
    },
    {
      "parameters": {
        "jsCode": "const item = $input.first().json;\n\n// The OpenAI (Message a model) node returns text under output[0].content[0].text\nlet text = '';\nif (Array.isArray(item.output) && item.output[0] && Array.isArray(item.output[0].content) && item.output[0].content[0]) {\n  text = item.output[0].content[0].text || '';\n} else if (typeof item.output === 'string') {\n  text = item.output;\n} else if (typeof item.text === 'string') {\n  text = item.text;\n}\n\n// Strip any accidental markdown code fences\ntext = String(text).trim().replace(/^```(?:json)?/i, '').replace(/```$/, '').trim();\n\nlet parsed;\ntry {\n  parsed = JSON.parse(text);\n} catch (e) {\n  const match = text.match(/\\{[\\s\\S]*\\}/);\n  if (match) {\n    try { parsed = JSON.parse(match[0]); } catch (e2) { parsed = null; }\n  }\n}\n\nif (!parsed || typeof parsed !== 'object') {\n  return [{ json: { subject: '', body: '', email: '', parseError: true, raw: text } }];\n}\n\nreturn [{ json: {\n  subject: parsed.subject || '',\n  body: parsed.body || '',\n  email: parsed.email || ''\n} }];"
      },
      "id": "1a2b3c4d-0000-4000-8000-000000000001",
      "name": "Split Email Fields",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        848,
        -144
      ]
    },
    {
      "parameters": {
        "sendTo": "={{ $json.email }}",
        "subject": "={{ $json.subject }}",
        "emailType": "text",
        "message": "={{ $json.body }}",
        "options": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.2,
      "position": [
        1072,
        -144
      ],
      "id": "480e37ef-e293-489f-a99a-755102d938cb",
      "name": "Send a message",
      "webhookId": "RECONNECT_EMAIL_NODE",
      "credentials": {
        "gmailOAuth2": {
          "id": "",
          "name": "RECONNECT_GMAIL_CREDENTIAL"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "const item = $input.first().json;\n\n// The OpenAI (Message a model) node returns text under output[0].content[0].text\nlet text = '';\nif (Array.isArray(item.output) && item.output[0] && Array.isArray(item.output[0].content) && item.output[0].content[0]) {\n  text = item.output[0].content[0].text || '';\n} else if (typeof item.output === 'string') {\n  text = item.output;\n} else if (typeof item.text === 'string') {\n  text = item.text;\n}\n\n// Strip any accidental markdown code fences\ntext = String(text).trim().replace(/^```(?:json)?/i, '').replace(/```$/, '').trim();\n\nlet parsed;\ntry {\n  parsed = JSON.parse(text);\n} catch (e) {\n  const match = text.match(/\\{[\\s\\S]*\\}/);\n  if (match) {\n    try { parsed = JSON.parse(match[0]); } catch (e2) { parsed = null; }\n  }\n}\n\nif (!parsed || typeof parsed !== 'object') {\n  return [{ json: { name: '', email: '', summary: '', parseError: true, raw: text } }];\n}\n\nreturn [{ json: {\n  name: parsed.name || '',\n  email: parsed.email || '',\n  summary: parsed.summary || ''\n} }];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        832,
        144
      ],
      "id": "f618b0ac-a15f-4f58-8e27-2f525c676c8b",
      "name": "Code in JavaScript"
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "RECONNECT_SHEET_DOCUMENT",
          "mode": "list",
          "cachedResultName": "Client_onboarding",
          "cachedResultUrl": ""
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": ""
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Name": "={{ $json.name }}",
            "Email": "={{ $json.email }}",
            "Summary": "={{ $json.summary }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "Name",
              "displayName": "Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email",
              "displayName": "Email",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Summary",
              "displayName": "Summary",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        1056,
        144
      ],
      "id": "bf1f3c9d-5081-4c22-8433-290eb70207a1",
      "name": "Append row in sheet",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "",
          "name": "RECONNECT_SHEETS_CREDENTIAL"
        }
      }
    }
  ],
  "pinData": {},
  "connections": {
    "On form submission": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          },
          {
            "node": "AI Agent1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Message a model",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent1": {
      "main": [
        [
          {
            "node": "Message a model1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Message a model": {
      "main": [
        [
          {
            "node": "Split Email Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Email Fields": {
      "main": [
        [
          {
            "node": "Send a message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Message a model1": {
      "main": [
        [
          {
            "node": "Code in JavaScript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript": {
      "main": [
        [
          {
            "node": "Append row in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate",
    "availableInMCP": false
  },
  "versionId": "1a5bb2cd-ebd2-4604-a972-08b6876fbd3f",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": ""
  },
  "nodeGroups": [],
  "id": "zpBEXUo158gc28z5",
  "tags": []
}
