{
  "updatedAt": "2026-03-28T13:20:57.344Z",
  "createdAt": "2026-03-25T02:30:47.500Z",
  "id": "IIdYtJO8C3nmbeXK",
  "name": "New Formbricks Submission",
  "description": null,
  "active": true,
  "isArchived": false,
  "nodes": [
    {
      "id": "webhook-1",
      "name": "Formbricks Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        200,
        300
      ],
      "parameters": {
        "path": "formbricks-lead",
        "httpMethod": "POST",
        "responseMode": "lastNode",
        "options": {}
      },
      "webhookId": "d689aadd-9866-4c5a-bace-a92786b51033"
    },
    {
      "id": "code-1",
      "name": "Extract Lead Data",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        420,
        300
      ],
      "parameters": {
        "jsCode": "const body = $input.first().json.body || $input.first().json;\nconst data = body.data || body;\nconst responses = data.data || data.responses || {};\nconst surveyId = data.surveyId || '';\n\nlet firstName = '', lastName = '', email = '', phone = '', company = '', message = '', context = 'WHTNXT';\nlet newsletterOptIn = false;\n\n// Check for newsletter consent\nfor (const [key, val] of Object.entries(responses)) {\n  if (val === 'accepted') newsletterOptIn = true;\n  if (typeof val === 'object' && val !== null && val.accepted === true) newsletterOptIn = true;\n}\n\n// Detect context by survey ID\nconst CP_SURVEY_IDS = ['cmn6allgr0002s301uillrhbh', 'cmn68f5rf000is301fpxuxtr7', 'cp-website-contact-form'];\nconst isCP = CP_SURVEY_IDS.includes(surveyId);\nif (isCP) context = 'CHALUPA_PRODUCTIONS';\n\n// Extract contact data from any format\nfor (const [key, val] of Object.entries(responses)) {\n  if (typeof val === 'object' && val !== null && (val.firstName || val.email)) {\n    firstName = val.firstName || firstName;\n    lastName = val.lastName || lastName;\n    email = val.email || email;\n    phone = val.phone || phone;\n    company = val.company || company;\n  }\n  if (typeof val === 'string' && val.length > 10 && key !== 'consent' && !newsletterOptIn) {\n    // Only set message from text fields, not consent\n    const isConsent = val === 'accepted' || val === 'dismissed';\n    if (!isConsent) message = val;\n  }\n}\n\n// Fallback: old-style named fields\nif (!firstName && responses.first_name) {\n  firstName = responses.first_name || '';\n  lastName = responses.last_name || '';\n  email = responses.email || '';\n  phone = responses.phone || '';\n  company = responses.company_name || '';\n  message = responses.tell_us_more || '';\n}\nif (!firstName && responses.contact_name) {\n  const parts = (responses.contact_name || '').split(' ');\n  firstName = parts[0] || '';\n  lastName = parts.slice(1).join(' ') || '';\n  email = responses.contact_email || '';\n  phone = responses.contact_phone || '';\n  company = responses.company_name || '';\n  message = [responses.project_type, responses.project_description, responses.budget_range].filter(Boolean).join(' | ');\n}\n\nreturn [{ json: {\n  firstName, lastName, email, phone,\n  company: company || 'Unknown',\n  message, context, newsletterOptIn,\n  source: isCP ? 'Chalupa Productions Website' : 'Formbricks',\n  responseId: data.id || data.responseId || '',\n  surveyId\n} }];"
      }
    },
    {
      "id": "http-1",
      "name": "Create Twenty Company",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        640,
        200
      ],
      "parameters": {
        "method": "POST",
        "url": "https://YOUR_TWENTY_URL",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer YOUR_JWT_TOKEN"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ name: $json.company, context: $json.context }) }}"
      }
    },
    {
      "id": "http-2",
      "name": "Create Twenty Person",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        860,
        200
      ],
      "parameters": {
        "method": "POST",
        "url": "https://YOUR_TWENTY_URL",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer YOUR_JWT_TOKEN"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ name: { firstName: $('Extract Lead Data').first().json.firstName, lastName: $('Extract Lead Data').first().json.lastName }, emails: { primaryEmail: $('Extract Lead Data').first().json.email }, context: $('Extract Lead Data').first().json.context, marketingConsent: $('Extract Lead Data').first().json.newsletterOptIn }) }}"
      }
    },
    {
      "id": "http-3",
      "name": "Add to Listmonk Nurture",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        860,
        400
      ],
      "parameters": {
        "method": "POST",
        "url": "https://YOUR_LISTMONK_URL",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Basic V2h0bnh0QVBJOlJEZE5pWTdYSVhkZmI4cmdRRG5vcmx5cUtJT1NnSUlH"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ email: $('Extract Lead Data').first().json.email, name: $('Extract Lead Data').first().json.firstName + ' ' + $('Extract Lead Data').first().json.lastName, lists: $('Extract Lead Data').first().json.context === 'CHALUPA_PRODUCTIONS' ? [3, 7] : [3, 5], status: 'enabled', preconfirm_subscriptions: true }) }}",
        "options": {
          "redirect": {
            "redirect": {
              "value": ""
            }
          }
        }
      }
    },
    {
      "id": "gmail-1",
      "name": "Notify Edward",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        1080,
        300
      ],
      "parameters": {
        "sendTo": "your-email@example.com",
        "subject": "={{ 'New Lead: ' + $('Extract Lead Data').first().json.firstName + ' ' + $('Extract Lead Data').first().json.lastName + ' - ' + $('Extract Lead Data').first().json.company }}",
        "message": "={{ '<h3>New Lead from Formbricks</h3><p><strong>Name:</strong> ' + $('Extract Lead Data').first().json.firstName + ' ' + $('Extract Lead Data').first().json.lastName + '</p><p><strong>Email:</strong> ' + $('Extract Lead Data').first().json.email + '</p><p><strong>Company:</strong> ' + $('Extract Lead Data').first().json.company + '</p><p><strong>Message:</strong> ' + $('Extract Lead Data').first().json.message + '</p><p><strong>Source:</strong> Formbricks</p>' }}",
        "options": {}
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "YOUR_CREDENTIAL_ID",
          "name": "YOUR_CREDENTIAL_NAME"
        }
      }
    },
    {
      "id": "if-consent",
      "name": "Consent Given?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        640,
        400
      ],
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "id": "c1",
              "leftValue": "={{ $('Extract Lead Data').first().json.newsletterOptIn }}",
              "rightValue": true,
              "operator": {
                "type": "boolean",
                "operation": "true"
              }
            }
          ],
          "combinator": "and"
        }
      }
    }
  ],
  "connections": {
    "Formbricks Webhook": {
      "main": [
        [
          {
            "node": "Extract Lead Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Lead Data": {
      "main": [
        [
          {
            "node": "Create Twenty Company",
            "type": "main",
            "index": 0
          },
          {
            "node": "Consent Given?",
            "type": "0",
            "index": 0
          }
        ]
      ]
    },
    "Create Twenty Company": {
      "main": [
        [
          {
            "node": "Create Twenty Person",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Twenty Person": {
      "main": [
        [
          {
            "node": "Notify Edward",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add to Listmonk Nurture": {
      "main": [
        [
          {
            "node": "Notify Edward",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Consent Given?": {
      "main": [
        [
          {
            "node": "Add to Listmonk Nurture",
            "type": "0",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "timezone": "America/Chicago",
    "callerPolicy": "workflowsFromSameOwner",
    "availableInMCP": false
  },
  "staticData": null,
  "pinData": null,
  "versionId": "2fdb028e-020f-49bc-b81f-5d9f9002b8d1",
  "activeVersionId": "2fdb028e-020f-49bc-b81f-5d9f9002b8d1",
  "versionCounter": 50,
  "triggerCount": 1,
  "shared": [
    {
      "updatedAt": "2026-03-25T02:30:47.500Z",
      "createdAt": "2026-03-25T02:30:47.500Z",
      "role": "workflow:owner",
      "workflowId": "IIdYtJO8C3nmbeXK",
      "projectId": "6RTJ3ead58ncl4Hy",
      "project": {
        "updatedAt": "2025-01-23T18:31:39.020Z",
        "createdAt": "2025-01-23T05:37:52.794Z",
        "id": "6RTJ3ead58ncl4Hy",
        "name": "Edward Chalupa <your-email@example.com>",
        "type": "personal",
        "icon": null,
        "description": null,
        "creatorId": "e67b6366-69ec-43f2-91cb-2e5098f53def"
      }
    }
  ],
  "tags": [],
  "activeVersion": {
    "updatedAt": "2026-03-28T13:20:57.348Z",
    "createdAt": "2026-03-28T13:20:57.348Z",
    "versionId": "2fdb028e-020f-49bc-b81f-5d9f9002b8d1",
    "workflowId": "IIdYtJO8C3nmbeXK",
    "nodes": [
      {
        "id": "webhook-1",
        "name": "Formbricks Webhook",
        "type": "n8n-nodes-base.webhook",
        "typeVersion": 2,
        "position": [
          200,
          300
        ],
        "parameters": {
          "path": "formbricks-lead",
          "httpMethod": "POST",
          "responseMode": "lastNode",
          "options": {}
        },
        "webhookId": "d689aadd-9866-4c5a-bace-a92786b51033"
      },
      {
        "id": "code-1",
        "name": "Extract Lead Data",
        "type": "n8n-nodes-base.code",
        "typeVersion": 2,
        "position": [
          420,
          300
        ],
        "parameters": {
          "jsCode": "const body = $input.first().json.body || $input.first().json;\nconst data = body.data || body;\nconst responses = data.data || data.responses || {};\nconst surveyId = data.surveyId || '';\n\nlet firstName = '', lastName = '', email = '', phone = '', company = '', message = '', context = 'WHTNXT';\nlet newsletterOptIn = false;\n\n// Check for newsletter consent\nfor (const [key, val] of Object.entries(responses)) {\n  if (val === 'accepted') newsletterOptIn = true;\n  if (typeof val === 'object' && val !== null && val.accepted === true) newsletterOptIn = true;\n}\n\n// Detect context by survey ID\nconst CP_SURVEY_IDS = ['cmn6allgr0002s301uillrhbh', 'cmn68f5rf000is301fpxuxtr7', 'cp-website-contact-form'];\nconst isCP = CP_SURVEY_IDS.includes(surveyId);\nif (isCP) context = 'CHALUPA_PRODUCTIONS';\n\n// Extract contact data from any format\nfor (const [key, val] of Object.entries(responses)) {\n  if (typeof val === 'object' && val !== null && (val.firstName || val.email)) {\n    firstName = val.firstName || firstName;\n    lastName = val.lastName || lastName;\n    email = val.email || email;\n    phone = val.phone || phone;\n    company = val.company || company;\n  }\n  if (typeof val === 'string' && val.length > 10 && key !== 'consent' && !newsletterOptIn) {\n    // Only set message from text fields, not consent\n    const isConsent = val === 'accepted' || val === 'dismissed';\n    if (!isConsent) message = val;\n  }\n}\n\n// Fallback: old-style named fields\nif (!firstName && responses.first_name) {\n  firstName = responses.first_name || '';\n  lastName = responses.last_name || '';\n  email = responses.email || '';\n  phone = responses.phone || '';\n  company = responses.company_name || '';\n  message = responses.tell_us_more || '';\n}\nif (!firstName && responses.contact_name) {\n  const parts = (responses.contact_name || '').split(' ');\n  firstName = parts[0] || '';\n  lastName = parts.slice(1).join(' ') || '';\n  email = responses.contact_email || '';\n  phone = responses.contact_phone || '';\n  company = responses.company_name || '';\n  message = [responses.project_type, responses.project_description, responses.budget_range].filter(Boolean).join(' | ');\n}\n\nreturn [{ json: {\n  firstName, lastName, email, phone,\n  company: company || 'Unknown',\n  message, context, newsletterOptIn,\n  source: isCP ? 'Chalupa Productions Website' : 'Formbricks',\n  responseId: data.id || data.responseId || '',\n  surveyId\n} }];"
        }
      },
      {
        "id": "http-1",
        "name": "Create Twenty Company",
        "type": "n8n-nodes-base.httpRequest",
        "typeVersion": 4.2,
        "position": [
          640,
          200
        ],
        "parameters": {
          "method": "POST",
          "url": "https://YOUR_TWENTY_URL",
          "sendHeaders": true,
          "headerParameters": {
            "parameters": [
              {
                "name": "Authorization",
                "value": "Bearer YOUR_JWT_TOKEN"
              }
            ]
          },
          "sendBody": true,
          "specifyBody": "json",
          "jsonBody": "={{ JSON.stringify({ name: $json.company, context: $json.context }) }}"
        }
      },
      {
        "id": "http-2",
        "name": "Create Twenty Person",
        "type": "n8n-nodes-base.httpRequest",
        "typeVersion": 4.2,
        "position": [
          860,
          200
        ],
        "parameters": {
          "method": "POST",
          "url": "https://YOUR_TWENTY_URL",
          "sendHeaders": true,
          "headerParameters": {
            "parameters": [
              {
                "name": "Authorization",
                "value": "Bearer YOUR_JWT_TOKEN"
              }
            ]
          },
          "sendBody": true,
          "specifyBody": "json",
          "jsonBody": "={{ JSON.stringify({ name: { firstName: $('Extract Lead Data').first().json.firstName, lastName: $('Extract Lead Data').first().json.lastName }, emails: { primaryEmail: $('Extract Lead Data').first().json.email }, context: $('Extract Lead Data').first().json.context, marketingConsent: $('Extract Lead Data').first().json.newsletterOptIn }) }}"
        }
      },
      {
        "id": "http-3",
        "name": "Add to Listmonk Nurture",
        "type": "n8n-nodes-base.httpRequest",
        "typeVersion": 4.2,
        "position": [
          860,
          400
        ],
        "parameters": {
          "method": "POST",
          "url": "https://YOUR_LISTMONK_URL",
          "sendHeaders": true,
          "headerParameters": {
            "parameters": [
              {
                "name": "Authorization",
                "value": "Basic V2h0bnh0QVBJOlJEZE5pWTdYSVhkZmI4cmdRRG5vcmx5cUtJT1NnSUlH"
              }
            ]
          },
          "sendBody": true,
          "specifyBody": "json",
          "jsonBody": "={{ JSON.stringify({ email: $('Extract Lead Data').first().json.email, name: $('Extract Lead Data').first().json.firstName + ' ' + $('Extract Lead Data').first().json.lastName, lists: $('Extract Lead Data').first().json.context === 'CHALUPA_PRODUCTIONS' ? [3, 7] : [3, 5], status: 'enabled', preconfirm_subscriptions: true }) }}",
          "options": {
            "redirect": {
              "redirect": {
                "value": ""
              }
            }
          }
        }
      },
      {
        "id": "gmail-1",
        "name": "Notify Edward",
        "type": "n8n-nodes-base.gmail",
        "typeVersion": 2.1,
        "position": [
          1080,
          300
        ],
        "parameters": {
          "sendTo": "your-email@example.com",
          "subject": "={{ 'New Lead: ' + $('Extract Lead Data').first().json.firstName + ' ' + $('Extract Lead Data').first().json.lastName + ' - ' + $('Extract Lead Data').first().json.company }}",
          "message": "={{ '<h3>New Lead from Formbricks</h3><p><strong>Name:</strong> ' + $('Extract Lead Data').first().json.firstName + ' ' + $('Extract Lead Data').first().json.lastName + '</p><p><strong>Email:</strong> ' + $('Extract Lead Data').first().json.email + '</p><p><strong>Company:</strong> ' + $('Extract Lead Data').first().json.company + '</p><p><strong>Message:</strong> ' + $('Extract Lead Data').first().json.message + '</p><p><strong>Source:</strong> Formbricks</p>' }}",
          "options": {}
        },
        "credentials": {
          "gmailOAuth2": {
            "id": "YOUR_CREDENTIAL_ID",
            "name": "YOUR_CREDENTIAL_NAME"
          }
        }
      },
      {
        "id": "if-consent",
        "name": "Consent Given?",
        "type": "n8n-nodes-base.if",
        "typeVersion": 2,
        "position": [
          640,
          400
        ],
        "parameters": {
          "conditions": {
            "options": {
              "caseSensitive": true,
              "leftValue": "",
              "typeValidation": "strict"
            },
            "conditions": [
              {
                "id": "c1",
                "leftValue": "={{ $('Extract Lead Data').first().json.newsletterOptIn }}",
                "rightValue": true,
                "operator": {
                  "type": "boolean",
                  "operation": "true"
                }
              }
            ],
            "combinator": "and"
          }
        }
      }
    ],
    "connections": {
      "Formbricks Webhook": {
        "main": [
          [
            {
              "node": "Extract Lead Data",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "Extract Lead Data": {
        "main": [
          [
            {
              "node": "Create Twenty Company",
              "type": "main",
              "index": 0
            },
            {
              "node": "Consent Given?",
              "type": "0",
              "index": 0
            }
          ]
        ]
      },
      "Create Twenty Company": {
        "main": [
          [
            {
              "node": "Create Twenty Person",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "Create Twenty Person": {
        "main": [
          [
            {
              "node": "Notify Edward",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "Add to Listmonk Nurture": {
        "main": [
          [
            {
              "node": "Notify Edward",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "Consent Given?": {
        "main": [
          [
            {
              "node": "Add to Listmonk Nurture",
              "type": "0",
              "index": 0
            }
          ]
        ]
      }
    },
    "authors": "Edward Chalupa",
    "name": null,
    "description": null,
    "autosaved": false,
    "workflowPublishHistory": [
      {
        "createdAt": "2026-03-28T13:20:57.478Z",
        "id": 227,
        "workflowId": "IIdYtJO8C3nmbeXK",
        "versionId": "2fdb028e-020f-49bc-b81f-5d9f9002b8d1",
        "event": "deactivated",
        "userId": "e67b6366-69ec-43f2-91cb-2e5098f53def"
      },
      {
        "createdAt": "2026-03-28T13:20:57.506Z",
        "id": 228,
        "workflowId": "IIdYtJO8C3nmbeXK",
        "versionId": "2fdb028e-020f-49bc-b81f-5d9f9002b8d1",
        "event": "activated",
        "userId": "e67b6366-69ec-43f2-91cb-2e5098f53def"
      },
      {
        "createdAt": "2026-03-28T13:21:17.204Z",
        "id": 229,
        "workflowId": "IIdYtJO8C3nmbeXK",
        "versionId": "2fdb028e-020f-49bc-b81f-5d9f9002b8d1",
        "event": "deactivated",
        "userId": "e67b6366-69ec-43f2-91cb-2e5098f53def"
      },
      {
        "createdAt": "2026-03-28T13:21:17.222Z",
        "id": 230,
        "workflowId": "IIdYtJO8C3nmbeXK",
        "versionId": "2fdb028e-020f-49bc-b81f-5d9f9002b8d1",
        "event": "activated",
        "userId": "e67b6366-69ec-43f2-91cb-2e5098f53def"
      }
    ]
  }
}