{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Send WhatsApp Follow-up When a New Lead Submits a Form with MoltFlow",
  "tags": [
    {
      "name": "whatsapp"
    },
    {
      "name": "lead generation"
    },
    {
      "name": "forms"
    },
    {
      "name": "moltflow"
    },
    {
      "name": "google sheets"
    },
    {
      "name": "crm"
    }
  ],
  "nodes": [
    {
      "id": "f1000001-0000-4000-f000-000000000010",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -40,
        -300
      ],
      "parameters": {
        "color": 4,
        "width": 400,
        "height": 310,
        "content": "## Form \u2192 WhatsApp Lead Follow-up\nInstantly reach new leads on WhatsApp when they submit a form (Typeform, JotForm, Google Forms, or any webhook-enabled form) using [MoltFlow](https://molt.waiflow.app).\n\n**How it works:**\n1. A form submission triggers this webhook\n2. Contact info is extracted (name, phone, interest)\n3. A personalized WhatsApp message is sent\n4. Lead is logged to Google Sheets for CRM tracking"
      },
      "typeVersion": 1
    },
    {
      "id": "f1000001-0000-4000-f000-000000000011",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        420,
        -300
      ],
      "parameters": {
        "color": 5,
        "width": 400,
        "height": 260,
        "content": "## Setup (5 min)\n1. Create a [MoltFlow account](https://molt.waiflow.app) and connect WhatsApp\n2. Activate this workflow \u2014 copy the webhook URL\n3. Configure your form tool to POST to this webhook on submission\n4. Map your form field names in the Parse Form node\n5. Set `YOUR_SESSION_ID` in the Parse Form node\n6. (Optional) Connect Google Sheets to log leads\n7. Add MoltFlow API Key: Header Auth \u2192 `X-API-Key`"
      },
      "typeVersion": 1
    },
    {
      "id": "f1000001-0000-4000-f000-000000000001",
      "name": "Form Submission Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        0,
        0
      ],
      "parameters": {
        "path": "form-lead",
        "options": {},
        "httpMethod": "POST"
      },
      "typeVersion": 2
    },
    {
      "id": "f1000001-0000-4000-f000-000000000002",
      "name": "Parse Form Data",
      "type": "n8n-nodes-base.code",
      "position": [
        220,
        0
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "const SESSION_ID = 'YOUR_SESSION_ID';\n\nconst messageTemplate = 'Hi {{name}}! Thanks for reaching out. We received your inquiry about {{interest}} and will get back to you shortly. Is there anything specific you would like to know right away?';\n\nconst body = $input.first().json.body || $input.first().json;\n\nconst name = body.name || body.full_name || body.first_name || 'there';\nconst phone = String(body.phone || body.phone_number || body.mobile || '').replace(/[^0-9]/g, '');\nconst email = body.email || '';\nconst interest = body.interest || body.subject || body.service || body.message || 'your inquiry';\n\nif (!phone || phone.length < 7) {\n  return [{ json: { skip: true, reason: 'No valid phone number', name, email } }];\n}\n\nconst message = messageTemplate\n  .replace('{{name}}', name)\n  .replace('{{interest}}', interest);\n\nreturn [{\n  json: {\n    session_id: SESSION_ID,\n    chat_id: phone + '@c.us',\n    message: message,\n    name: name,\n    phone: phone,\n    email: email,\n    interest: interest,\n    submitted_at: new Date().toISOString(),\n    skip: false\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "f1000001-0000-4000-f000-000000000003",
      "name": "Valid Lead?",
      "type": "n8n-nodes-base.if",
      "position": [
        440,
        0
      ],
      "parameters": {
        "conditions": {
          "options": {
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "not-skip",
              "operator": {
                "type": "boolean",
                "operation": "equals"
              },
              "leftValue": "={{ $json.skip }}",
              "rightValue": false
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "f1000001-0000-4000-f000-000000000004",
      "name": "Send WhatsApp Follow-up",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        660,
        -100
      ],
      "parameters": {
        "url": "https://apiv2.waiflow.app/api/v2/messages/send",
        "method": "POST",
        "options": {},
        "jsonBody": "={{ JSON.stringify({ session_id: $json.session_id, chat_id: $json.chat_id, message: $json.message }) }}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "f1000001-0000-4000-f000-000000000005",
      "name": "Log Lead to Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        880,
        -100
      ],
      "parameters": {
        "columns": {
          "value": {
            "Date": "={{ $('Parse Form Data').first().json.submitted_at }}",
            "Name": "={{ $('Parse Form Data').first().json.name }}",
            "Email": "={{ $('Parse Form Data').first().json.email }}",
            "Phone": "={{ $('Parse Form Data').first().json.phone }}",
            "Interest": "={{ $('Parse Form Data').first().json.interest }}",
            "WhatsApp Sent": "Yes"
          },
          "mappingMode": "defineBelow"
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "Leads"
        },
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": "YOUR_GOOGLE_SHEET_URL"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.5
    }
  ],
  "settings": {
    "executionOrder": "v1"
  },
  "connections": {
    "Valid Lead?": {
      "main": [
        [
          {
            "node": "Send WhatsApp Follow-up",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "Parse Form Data": {
      "main": [
        [
          {
            "node": "Valid Lead?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Form Submission Webhook": {
      "main": [
        [
          {
            "node": "Parse Form Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send WhatsApp Follow-up": {
      "main": [
        [
          {
            "node": "Log Lead to Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}