{
  "name": "Generic Universal Contact Form Pipeline",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "contact-submit",
        "options": {}
      },
      "id": "1",
      "name": "Form Webhook Trigger",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [150, 400]
    },
    {
      "parameters": {
        "jsCode": "return {\n  // Administrator Configuration Switches\n  enableGoogleSheets: true,\n  enableTelegram: true,\n  enableEmailNotification: true,\n  enableUserConfirmationEmail: true,\n  \n  // Credentials & Routing Destinations\n  googleSheetId: \"your_google_sheet_id_here\",\n  adminNotificationEmail: \"admin@yourcompany.com\",\n  telegramChatId: \"your_telegram_chat_id_here\"\n};"
      },
      "id": "2",
      "name": "Workflow Settings",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [350, 400]
    },
    {
      "parameters": {
        "jsCode": "const payload = $node[\"Form Webhook Trigger\"].json.body || {};\nconst config = $node[\"Workflow Settings\"].json;\n\n// Ensure all expected fields have standard fallbacks\nreturn {\n  firstName: payload.first_name || \"\",\n  lastName: payload.last_name || \"\",\n  email: payload.email || \"\",\n  phone: payload.phone || \"Not Provided\",\n  company: payload.company || \"Not Provided\",\n  website: payload.website || \"Not Provided\",\n  budget: payload.budget || \"Not Specified\",\n  referralSource: payload.referral_source || \"Not Specified\",\n  message: payload.message || \"No Message\",\n  config: config\n};"
      },
      "id": "3",
      "name": "Process Payload",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [550, 400]
    },
    {
      "parameters": {
        "conditions": {
          "boolean": [
            {
              "value1": "={{ $json.config.enableGoogleSheets }}",
              "value2": true
            }
          ]
        }
      },
      "id": "4",
      "name": "Sync to Sheets?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [750, 400]
    },
    {
      "parameters": {
        "resource": "spreadsheet",
        "operation": "append",
        "spreadsheetId": "={{ $json.config.googleSheetId }}",
        "values": {
          "mappingMode": "defineEverything",
          "value": {
            "Date": "={{ new Date().toISOString() }}",
            "First Name": "={{ $json.firstName }}",
            "Last Name": "={{ $json.lastName }}",
            "Email": "={{ $json.email }}",
            "Phone": "={{ $json.phone }}",
            "Company": "={{ $json.company }}",
            "Website": "={{ $json.website }}",
            "Budget": "={{ $json.budget }}",
            "Referral Source": "={{ $json.referralSource }}",
            "Message": "={{ $json.message }}"
          }
        }
      },
      "id": "5",
      "name": "Google Sheets Log",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4,
      "position": [950, 300]
    },
    {
      "parameters": {
        "conditions": {
          "boolean": [
            {
              "value1": "={{ $node[\"Process Payload\"].json.config.enableTelegram }}",
              "value2": true
            }
          ]
        }
      },
      "id": "6",
      "name": "Send Telegram?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [1150, 400]
    },
    {
      "parameters": {
        "chatId": "={{ $node[\"Process Payload\"].json.config.telegramChatId }}",
        "text": "📬 *New Website Contact Form Submission!*\n\n*Name:* {{ $node[\"Process Payload\"].json.firstName }} {{ $node[\"Process Payload\"].json.lastName }}\n*Company:* {{ $node[\"Process Payload\"].json.company }} ({{ $node[\"Process Payload\"].json.website }})\n*Email:* {{ $node[\"Process Payload\"].json.email }}\n*Phone:* {{ $node[\"Process Payload\"].json.phone }}\n*Budget:* {{ $node[\"Process Payload\"].json.budget }}\n*Referral:* {{ $node[\"Process Payload\"].json.referralSource }}\n\n*Message:* \n```\n{{ $node[\"Process Payload\"].json.message }}\n```",
        "additionalFields": {
          "parse_mode": "Markdown"
        }
      },
      "id": "7",
      "name": "Telegram Notification",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.1,
      "position": [1350, 300]
    },
    {
      "parameters": {
        "conditions": {
          "boolean": [
            {
              "value1": "={{ $node[\"Process Payload\"].json.config.enableEmailNotification }}",
              "value2": true
            }
          ]
        }
      },
      "id": "8",
      "name": "Send Email Alert?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [1550, 400]
    },
    {
      "parameters": {
        "fromEmail": "notifications@yourcompany.com",
        "toEmail": "={{ $node[\"Process Payload\"].json.config.adminNotificationEmail }}",
        "subject": "📬 New Contact Form Submission: {{ $node[\"Process Payload\"].json.firstName }} {{ $node[\"Process Payload\"].json.lastName }}",
        "text": "New website contact submission:\n\nName: {{ $node[\"Process Payload\"].json.firstName }} {{ $node[\"Process Payload\"].json.lastName }}\nEmail: {{ $node[\"Process Payload\"].json.email }}\nPhone: {{ $node[\"Process Payload\"].json.phone }}\nCompany: {{ $node[\"Process Payload\"].json.company }}\nWebsite: {{ $node[\"Process Payload\"].json.website }}\nBudget: {{ $node[\"Process Payload\"].json.budget }}\nReferral Source: {{ $node[\"Process Payload\"].json.referralSource }}\n\nMessage:\n{{ $node[\"Process Payload\"].json.message }}",
        "options": {}
      },
      "id": "9",
      "name": "Admin Email Notification",
      "type": "n8n-nodes-base.emailSend",
      "typeVersion": 1,
      "position": [1750, 300]
    },
    {
      "parameters": {
        "conditions": {
          "boolean": [
            {
              "value1": "={{ $node[\"Process Payload\"].json.config.enableUserConfirmationEmail }}",
              "value2": true
            }
          ]
        }
      },
      "id": "10",
      "name": "Send User Confirmation?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [1950, 400]
    },
    {
      "parameters": {
        "fromEmail": "hello@yourcompany.com",
        "toEmail": "={{ $node[\"Process Payload\"].json.email }}",
        "subject": "Thanks for reaching out! We've received your request",
        "text": "Hi {{ $node[\"Process Payload\"].json.firstName }},\n\nThanks for contacting us! We've received your request and our team is already reviewing it.\n\nHere's a summary of the details you submitted:\nCompany: {{ $node[\"Process Payload\"].json.company }}\nWebsite: {{ $node[\"Process Payload\"].json.website }}\nMessage: {{ $node[\"Process Payload\"].json.message }}\n\nOne of our specialists will get back to you shortly.\n\nBest regards,\nThe Team",
        "options": {}
      },
      "id": "11",
      "name": "User Auto-Response",
      "type": "n8n-nodes-base.emailSend",
      "typeVersion": 1,
      "position": [2150, 300]
    }
  ],
  "connections": {
    "Form Webhook Trigger": {
      "main": [
        [
          {
            "node": "Workflow Settings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Workflow Settings": {
      "main": [
        [
          {
            "node": "Process Payload",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Process Payload": {
      "main": [
        [
          {
            "node": "Sync to Sheets?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Sync to Sheets?": {
      "main": [
        [
          {
            "node": "Google Sheets Log",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send Telegram?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets Log": {
      "main": [
        [
          {
            "node": "Send Telegram?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Telegram?": {
      "main": [
        [
          {
            "node": "Telegram Notification",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send Email Alert?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Notification": {
      "main": [
        [
          {
            "node": "Send Email Alert?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Email Alert?": {
      "main": [
        [
          {
            "node": "Admin Email Notification",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send User Confirmation?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Admin Email Notification": {
      "main": [
        [
          {
            "node": "Send User Confirmation?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send User Confirmation?": {
      "main": [
        [
          {
            "node": "User Auto-Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
