{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "ec1d0463-087c-41e4-a4c9-e1672c1bee61",
      "name": "Create Salesforce Lead",
      "type": "n8n-nodes-base.salesforce",
      "position": [
        -380,
        -200
      ],
      "parameters": {
        "company": "=Web Lead {{ $json[\"Last Name\"] }}",
        "lastname": "={{ $json[\"Last Name\"] }}",
        "additionalFields": {
          "email": "={{ $json.Email }}",
          "firstname": "={{ $json[\"First Name\"] }}",
          "description": "={{ $json[\"Tell Us About Yourself (Description)\"] }}",
          "mobilePhone": "={{ $json[\"Phone (SMS)\"] }}"
        }
      },
      "credentials": {
        "salesforceOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "3595d4f3-b3c3-4aa7-ba99-398ff7ab6fad",
      "name": "On form submission",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -580,
        -200
      ],
      "parameters": {
        "options": {
          "buttonLabel": "Submit"
        },
        "formTitle": "Contact Us",
        "formFields": {
          "values": [
            {
              "fieldLabel": "First Name",
              "requiredField": true
            },
            {
              "fieldLabel": "Last Name",
              "requiredField": true
            },
            {
              "fieldType": "email",
              "fieldLabel": "Email"
            },
            {
              "fieldLabel": "Phone (SMS)"
            },
            {
              "fieldType": "textarea",
              "fieldLabel": "Tell Us About Yourself (Description)"
            },
            {
              "fieldType": "dropdown",
              "fieldLabel": "Contact Preference:",
              "fieldOptions": {
                "values": [
                  {
                    "option": "Email"
                  },
                  {
                    "option": "Phone"
                  }
                ]
              },
              "requiredField": true
            },
            {}
          ]
        },
        "formDescription": "We'll get back to you soon"
      },
      "typeVersion": 2.2
    },
    {
      "id": "4349f4a7-98a1-4805-a7b1-fcc475274eea",
      "name": "OpenAI",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        -160,
        -200
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1",
          "cachedResultName": "GPT-4.1"
        },
        "options": {},
        "messages": {
          "values": [
            {
              "content": "=Create a personalized welcome message for this lead:\n{{ JSON.stringify($('On form submission').item.json)}}\n\nTailor the message to their interest in booking an n8n form creation. Make it warm and helpful."
            },
            {
              "role": "system",
              "content": "You are a friendly, professional sales assistant for an automation and software development service specializing in n8n workflows, Salesforce integrations, and custom forms. Your goal is to create engaging, personalized welcome messages that respond directly to the user's description, encouraging them to proceed with booking or next steps. \n\nAdapt the message format based on the contact preference:\n- If preference is \"Email\": Make it detailed, positive, and action-oriented (under 200 words). Include a greeting, body with personalization, call-to-action (e.g., reply or schedule), and end with your company signature: \"Best regards, [Your Company Name] Team\" and  without the Subject.\n- If preference is \"Phone (SMS)\": Keep it very concise (under 160 characters), friendly, and direct. Include a short greeting, key offer, and simple call-to-action. No signature or links; focus on quick engagement; without the Subject.\n\nAlways personalize using the user's first name, last name, and description. If the description mentions booking or creating something (e.g., an n8n form), offer specific help and suggest packages."
            }
          ]
        }
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "cac8625a-bd57-48b1-b98f-70daa4561c7c",
      "name": "Switch",
      "type": "n8n-nodes-base.switch",
      "position": [
        200,
        -200
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "72c22b5b-16f6-424f-b3eb-e93da457e797",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('On form submission').item.json[\"Contact Preference:\"] }}",
                    "rightValue": "Phone (SMS)"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "8d42ed48-0064-4a5f-b924-a7968a91c919",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('On form submission').item.json[\"Contact Preference:\"] }}",
                    "rightValue": "Email"
                  }
                ]
              }
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "05b99b9d-a6ce-44a1-9269-508b7afce052",
      "name": "Send SMS",
      "type": "n8n-nodes-base.twilio",
      "notes": "Send SMS using Twilio",
      "position": [
        520,
        -300
      ],
      "parameters": {
        "to": "={{ $('On form submission').item.json[\"Phone (SMS)\"] }}",
        "from": "phoneNumber",
        "message": "={{ $('OpenAI').item.json.message.content }}",
        "options": {}
      },
      "credentials": {
        "twilioApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "5d392311-853e-4e97-a436-874cc891bc6b",
      "name": "Send Email",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        520,
        -80
      ],
      "parameters": {
        "text": "={{ $('OpenAI').item.json.message.content }}",
        "options": {},
        "subject": "=Welcome {{ $('On form submission').item.json[\"First Name\"] }}",
        "toEmail": "={{ $('On form submission').item.json.Email }}",
        "fromEmail": "emailPlaceholder",
        "emailFormat": "text"
      },
      "credentials": {
        "smtp": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "10d1bb22-1c6e-4762-937a-f4d1cbba7259",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -960,
        -480
      ],
      "parameters": {
        "width": 320,
        "height": 460,
        "content": "## n8n Web Lead Form Alternative to Salesforce Web-to-Lead\n \nThis workflow captures leads via n8n's form trigger, creates Salesforce records, personalizes responses with OpenAI, and sends via email/SMS based on preference. Avoids rigid Salesforce Web-to-Lead by adding logic, AI, and extensibility. Add file upload fields for AI processing (e.g., document analysis) to unlock potentials like lead scoring or content insights."
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "OpenAI": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "Send SMS",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "On form submission": {
      "main": [
        [
          {
            "node": "Create Salesforce Lead",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Salesforce Lead": {
      "main": [
        [
          {
            "node": "OpenAI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}