{
  "nodes": [
    {
      "id": "a937adda-e5bb-49ab-a760-4cd6c779edf5",
      "name": "google-sheet-name",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        3472,
        1504
      ],
      "parameters": {
        "columns": {
          "value": {
            "Email": "={{ $json.email }}",
            "Phone": "={{ $json.phone }}",
            "Status": "={{ $json.status }}",
            "Lead Name": "={{ $json.lead_name }}",
            "Timestamp": "={{ $json.response_time_ist }}",
            "AI Response": "={{ $json.ai_response }}",
            "Day of Week": "={{ $json.day_of_week }}",
            "Lead Message": "={{ $json.lead_message }}",
            "Response Time": "={{ $json.response_sent_at }}",
            "Working Hours": "={{ $json.working_hours }}",
            "Source Channel": "={{ $json.source_channel }}"
          },
          "schema": [
            {
              "id": "Lead Name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Lead Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Email",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Phone",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Phone",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Lead Message",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Lead Message",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Timestamp",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Timestamp",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Source Channel",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Source Channel",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Working Hours",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Working Hours",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Day of Week",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Day of Week",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Response Time",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Response Time",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "AI Response",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "AI Response",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Status",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "Email"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "your-google-sheet-url",
          "cachedResultName": "google-sheet-name"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "your-google-sheet-id",
          "cachedResultUrl": "your-google-sheet-url",
          "cachedResultName": "google-sheet-name"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "339a501b-3dba-4629-b7a4-67fbed7874c2",
      "name": "Normalize Lead Data5",
      "type": "n8n-nodes-base.set",
      "position": [
        944,
        1776
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "2137974a-5c02-40ea-be6d-c9425b01904c",
              "name": "body.lead_name",
              "type": "string",
              "value": "={{ $json.body.lead_name }}"
            },
            {
              "id": "a310ee2c-e6b6-4dd4-b1a4-bde117c40b33",
              "name": "body.contact_phone",
              "type": "string",
              "value": "={{ $json.body.contact_phone }}"
            },
            {
              "id": "e22725dc-74d6-45e0-9dcd-9ace4a0833f9",
              "name": "body.message_text",
              "type": "string",
              "value": "={{ $json.body.message_text }}"
            },
            {
              "id": "e99886d6-6e9e-4cac-b472-66a78228307a",
              "name": "body.source_channel",
              "type": "string",
              "value": "={{ $json.body.source_channel }}"
            },
            {
              "id": "28ea85de-6fcc-4bcf-b6b2-018176809f36",
              "name": "body.submitted_at",
              "type": "string",
              "value": "={{ new Date().toISOString() }}\n"
            },
            {
              "id": "d7086c75-511e-40db-8844-78285bc59c97",
              "name": "body.contact_email",
              "type": "string",
              "value": "={{ $json.body.contact_email }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "9b0e167e-b6e7-4bc6-8d95-32c5c3736858",
      "name": "Switch2",
      "type": "n8n-nodes-base.switch",
      "position": [
        1216,
        1472
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "f295bd0c-5930-4ded-9d28-60984b32d3c0",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.body.source_channel }}",
                    "rightValue": "whatsapp"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "2baa52d9-4a5c-4e4a-bc34-ad2a9e544895",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.body.source_channel }}",
                    "rightValue": "Instagram"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "efe57f59-b870-4901-9618-0e7eaab3c5ca",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.body.source_channel }}",
                    "rightValue": "Facebook"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "d73f0c5a-2ef8-483e-a6e6-dabf9d4ae783",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.body.source_channel }}",
                    "rightValue": "LinkedIn"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "ca354fdf-5d47-4469-9d64-3ce3fbb85537",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.body.source_channel }}",
                    "rightValue": "website"
                  }
                ]
              }
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.4
    },
    {
      "id": "e61c8682-46a8-470d-ab73-ef5b02f2ca46",
      "name": "Switch3",
      "type": "n8n-nodes-base.switch",
      "position": [
        2560,
        1472
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "f295bd0c-5930-4ded-9d28-60984b32d3c0",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.body.source_channel }}",
                    "rightValue": "whatsapp"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "2baa52d9-4a5c-4e4a-bc34-ad2a9e544895",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.body.source_channel }}",
                    "rightValue": "Instagram"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "efe57f59-b870-4901-9618-0e7eaab3c5ca",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.body.source_channel }}",
                    "rightValue": "Facebook"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "d73f0c5a-2ef8-483e-a6e6-dabf9d4ae783",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.body.source_channel }}",
                    "rightValue": "LinkedIn"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "ddab0d27-1f1e-47f6-a06b-bf050a32c528",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.body.source_channel }}",
                    "rightValue": "website"
                  }
                ]
              }
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.4
    },
    {
      "id": "cf5b0f33-4005-4b65-ab58-127e5bfd8253",
      "name": "Send Instagram Message1",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2912,
        1376
      ],
      "parameters": {
        "url": "your-instagram-api-endpoint",
        "options": {}
      },
      "typeVersion": 4.3
    },
    {
      "id": "faaa7f61-3222-4474-9006-cd76a111cbba",
      "name": "Send Facebook Messages1",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2912,
        1504
      ],
      "parameters": {
        "url": "your-facebook-api-endpoint",
        "options": {}
      },
      "typeVersion": 4.3
    },
    {
      "id": "7f501e2d-bac7-4473-987f-6441d6b38c48",
      "name": "Send Linkdin Messages1",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2912,
        1632
      ],
      "parameters": {
        "url": "your-linkdin-api-endpoint",
        "options": {}
      },
      "typeVersion": 4.3
    },
    {
      "id": "9b2eb0f0-2cc7-4a20-bcb6-df0a8cea019e",
      "name": "Send a message1",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2912,
        1776
      ],
      "parameters": {
        "sendTo": "={{ $json.body.contact_email }}",
        "message": "={{ $json.ai_response }}",
        "options": {},
        "subject": "Website developement Pricing Inquiry"
      },
      "typeVersion": 2.2
    },
    {
      "id": "69c124cd-1151-4f56-8e0d-f921538ae313",
      "name": "Extract Day and Hours1",
      "type": "n8n-nodes-base.code",
      "position": [
        1440,
        1520
      ],
      "parameters": {
        "jsCode": "// Original UTC date\nconst utcDate = new Date($json.body.submitted_at.trim());\n\n// Convert UTC \u2192 IST (+5:30)\nconst istOffsetMinutes = 330; // 5 * 60 + 30\nconst istDate = new Date(utcDate.getTime() + istOffsetMinutes * 60 * 1000);\n\n// Extract IST values\nconst dayOfWeek = istDate.getDay();\nconst hours = istDate.getHours();\nconst minutes = istDate.getMinutes();\n\n// HH:MM format\nconst timeHHMM =\n  String(hours).padStart(2, '0') +\n  ':' +\n  String(minutes).padStart(2, '0');\n\n// Total minutes since midnight (IST)\nconst totalMinutes = hours * 60 + minutes;\n\n// Working hours boundaries (IST)\nconst startMinutes = 9 * 60 + 30;   // 09:30\nconst endMinutes = 18 * 60 + 30;    // 18:30\n\nconst isWorkingDay = dayOfWeek >= 1 && dayOfWeek <= 5;\nconst isWorkingHours =\n  isWorkingDay &&\n  totalMinutes >= startMinutes &&\n  totalMinutes < endMinutes;\n\nreturn [{\n  json: {\n    ...$json,\n\n    // IST-based values\n    ist_dayOfWeek: dayOfWeek,\n    ist_timeHHMM: timeHHMM,\n    ist_totalMinutes: totalMinutes,\n    isWorkingDay,\n    is_working_hours: isWorkingHours\n  }\n}];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "528f6426-89a3-486e-9601-7bca8fd8c501",
      "name": "Is Working Day and Working Hour?1",
      "type": "n8n-nodes-base.if",
      "position": [
        1664,
        1520
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "3c125404-c364-4d84-9571-9e625f485825",
              "operator": {
                "type": "number",
                "operation": "lt"
              },
              "leftValue": "={{ $json.ist_dayOfWeek }}",
              "rightValue": 6
            },
            {
              "id": "1e72ac7e-86e9-4e96-b1e6-ce34c30f7896",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ $json.isWorkingDay }}",
              "rightValue": 9
            },
            {
              "id": "8089603d-48a4-43b8-b714-216ae7942b4f",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ $json.is_working_hours }}",
              "rightValue": false
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "a3db709e-8f9c-44c6-992e-b68425524b9e",
      "name": "Code in JavaScript3",
      "type": "n8n-nodes-base.code",
      "position": [
        1888,
        1520
      ],
      "parameters": {
        "jsCode": "const body = {\n  model: \"llama-3.3-70b-versatile\",\n  messages: [\n    {\n      role: \"system\",\n      content: \"You are a professional SDR assistant. You respond like a helpful human, not an AI. Keep replies short, friendly, and clear.\"\n    },\n    {\n      role: \"user\",\n      content: `SOURCE CHANNEL: ${$input.item.json.body.source_channel}\nWORKING HOURS: ${$input.item.json.is_working_hours}\nLEAD NAME: ${$input.item.json.body.lead_name}\nLEAD MESSAGE: ${$input.item.json.body.message_text}\n\nRULES:\n- If SOURCE CHANNEL is website, write a professional business email.\n- Otherwise, write a short chat message.\n- If WORKING HOURS is false, mention office hours (9:30 AM\u20136:30 PM IST).\n- Do not mention AI.\n- Return only the final response text.`\n    }\n  ],\n  temperature: 0.6,\n  max_tokens: 160\n};\n\nreturn {\n  json: {\n    ...($input.item.json),\n    requestBody: body\n  }\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "ba18a7de-d274-4da7-99ca-d1a74192896f",
      "name": "Code in JavaScript4",
      "type": "n8n-nodes-base.code",
      "position": [
        2336,
        1520
      ],
      "parameters": {
        "jsCode": "// Get the AI response from current node (HTTP Request)\nconst aiResponse = $input.item.json.choices[0].message.content;\n\n// Get original data from the \"Code in JavaScript\" node\nconst originalData = $('Code in JavaScript3').item.json;\n\n// Merge everything together\nreturn {\n  json: {\n    body: originalData.body,\n    ai_response: aiResponse,\n    is_working_hours: originalData.is_working_hours,\n    ist_dayOfWeek: originalData.ist_dayOfWeek,\n    ist_timeHHMM: originalData.ist_timeHHMM,\n    isWorkingDay: originalData.isWorkingDay,\n    ist_totalMinutes: originalData.ist_totalMinutes\n  }\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "da9b7d3d-3702-4ccd-bd0d-6f0da765bd6e",
      "name": "Code in JavaScript5",
      "type": "n8n-nodes-base.code",
      "position": [
        3248,
        1504
      ],
      "parameters": {
        "jsCode": "// Get the send response from current node\nconst sendResponse = $input.item.json;\n\n// Since the send nodes don't preserve the original data,\n// we need to get it from an earlier node that definitely exists\n// Let's try to get from the node that comes before Switch1\nconst beforeSwitch = $('Code in JavaScript4').item.json;\n\n// Determine which channel was used based on the source_channel\nlet channelUsed = beforeSwitch.body.source_channel || 'Unknown';\nlet sendStatus = 'Processed';\n\n// Check if send was successful\nif (sendResponse) {\n  if (sendResponse.statusCode >= 200 && sendResponse.statusCode < 300) {\n    sendStatus = 'Sent Successfully';\n  } else if (sendResponse.id || sendResponse.messageId || sendResponse.labelIds) {\n    // Gmail successful response\n    sendStatus = 'Sent Successfully';\n  } else if (sendResponse.error) {\n    sendStatus = 'Failed: ' + (sendResponse.error.message || 'Unknown error');\n  }\n}\n\n// Return complete data for logging\nreturn {\n  json: {\n    // Lead information\n    timestamp: beforeSwitch.body.submitted_at,\n    lead_name: beforeSwitch.body.lead_name,\n    email: beforeSwitch.body.contact_email,\n    phone: beforeSwitch.body.contact_phone,\n    source_channel: beforeSwitch.body.source_channel,\n    lead_message: beforeSwitch.body.message_text,\n    \n    // AI Response\n    ai_response: beforeSwitch.ai_response,\n    \n    // Working hours context\n    working_hours: beforeSwitch.is_working_hours,\n    response_time_ist: beforeSwitch.ist_timeHHMM,\n    day_of_week: beforeSwitch.ist_dayOfWeek,\n    \n    // Status tracking\n    status: sendStatus,\n    channel_used: channelUsed,\n    response_sent_at: new Date().toISOString()\n  }\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "ee3b4efa-93b3-455d-ace2-321b7f4cce62",
      "name": "Incomming Lead whatsapp1",
      "type": "n8n-nodes-base.webhook",
      "position": [
        592,
        1264
      ],
      "parameters": {
        "path": "incoming-leads-whatsapp",
        "options": {},
        "httpMethod": "POST"
      },
      "typeVersion": 2.1
    },
    {
      "id": "63065ea1-8c5d-43aa-8633-48d3832c9c3f",
      "name": "Incomming Lead facebook1",
      "type": "n8n-nodes-base.webhook",
      "position": [
        592,
        1392
      ],
      "parameters": {
        "path": "incoming-leads-facebook",
        "options": {},
        "httpMethod": "POST"
      },
      "typeVersion": 2.1
    },
    {
      "id": "82b51674-503b-49ee-b7c4-d8b52e1f126a",
      "name": "Incomming Lead instagram1",
      "type": "n8n-nodes-base.webhook",
      "position": [
        592,
        1520
      ],
      "parameters": {
        "path": "incoming-leads-instagram",
        "options": {},
        "httpMethod": "POST"
      },
      "typeVersion": 2.1
    },
    {
      "id": "04401034-0ee1-47bc-9b74-79942275a234",
      "name": "Incomming Lead linkdin1",
      "type": "n8n-nodes-base.webhook",
      "position": [
        592,
        1648
      ],
      "parameters": {
        "path": "incoming-leads-linkdin",
        "options": {},
        "httpMethod": "POST"
      },
      "typeVersion": 2.1
    },
    {
      "id": "64405af6-6c6f-46e2-a121-27ed34de3f6c",
      "name": "Incomming Lead Website1",
      "type": "n8n-nodes-base.webhook",
      "position": [
        592,
        1776
      ],
      "parameters": {
        "path": "incoming-leads-website",
        "options": {},
        "httpMethod": "POST"
      },
      "typeVersion": 2.1
    },
    {
      "id": "e1df306c-005d-4297-b70b-84ec5eddb86d",
      "name": "Normalize Lead Data6",
      "type": "n8n-nodes-base.set",
      "position": [
        944,
        1264
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "2137974a-5c02-40ea-be6d-c9425b01904c",
              "name": "body.lead_name",
              "type": "string",
              "value": "={{ $json.body.ProfileName }}"
            },
            {
              "id": "a310ee2c-e6b6-4dd4-b1a4-bde117c40b33",
              "name": "body.contact_phone",
              "type": "string",
              "value": "={{ $json.body.From }}"
            },
            {
              "id": "e22725dc-74d6-45e0-9dcd-9ace4a0833f9",
              "name": "body.message_text",
              "type": "string",
              "value": "={{ $json.body.Body }}"
            },
            {
              "id": "e99886d6-6e9e-4cac-b472-66a78228307a",
              "name": "body.source_channel",
              "type": "string",
              "value": "whatsapp"
            },
            {
              "id": "28ea85de-6fcc-4bcf-b6b2-018176809f36",
              "name": "body.submitted_at",
              "type": "string",
              "value": "={{ new Date().toISOString() }}\n"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "de89802e-eae2-49c7-b91e-ecfff14a5528",
      "name": "Normalize Lead Data7",
      "type": "n8n-nodes-base.set",
      "position": [
        944,
        1392
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "2137974a-5c02-40ea-be6d-c9425b01904c",
              "name": "body.lead_name",
              "type": "string",
              "value": "={{ $json.body.ProfileName }}"
            },
            {
              "id": "a310ee2c-e6b6-4dd4-b1a4-bde117c40b33",
              "name": "body.contact_phone",
              "type": "string",
              "value": "={{ $json.body.From }}"
            },
            {
              "id": "e22725dc-74d6-45e0-9dcd-9ace4a0833f9",
              "name": "body.message_text",
              "type": "string",
              "value": "={{ $json.body.Body }}"
            },
            {
              "id": "e99886d6-6e9e-4cac-b472-66a78228307a",
              "name": "body.source_channel",
              "type": "string",
              "value": "facebook"
            },
            {
              "id": "28ea85de-6fcc-4bcf-b6b2-018176809f36",
              "name": "body.submitted_at",
              "type": "string",
              "value": "={{ new Date().toISOString() }}\n"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "4ce6a3f6-c87d-4059-b245-3d6ff574bca7",
      "name": "Normalize Lead Data8",
      "type": "n8n-nodes-base.set",
      "position": [
        944,
        1520
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "2137974a-5c02-40ea-be6d-c9425b01904c",
              "name": "body.lead_name",
              "type": "string",
              "value": "={{ $json.body.ProfileName }}"
            },
            {
              "id": "a310ee2c-e6b6-4dd4-b1a4-bde117c40b33",
              "name": "body.contact_phone",
              "type": "string",
              "value": "={{ $json.body.From }}"
            },
            {
              "id": "e22725dc-74d6-45e0-9dcd-9ace4a0833f9",
              "name": "body.message_text",
              "type": "string",
              "value": "={{ $json.body.Body }}"
            },
            {
              "id": "e99886d6-6e9e-4cac-b472-66a78228307a",
              "name": "body.source_channel",
              "type": "string",
              "value": "instagram"
            },
            {
              "id": "28ea85de-6fcc-4bcf-b6b2-018176809f36",
              "name": "body.submitted_at",
              "type": "string",
              "value": "={{ new Date().toISOString() }}\n"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "530fcf4c-9ce9-482f-bd75-0be22ce6be1d",
      "name": "Normalize Lead Data9",
      "type": "n8n-nodes-base.set",
      "position": [
        944,
        1648
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "2137974a-5c02-40ea-be6d-c9425b01904c",
              "name": "body.lead_name",
              "type": "string",
              "value": "={{ $json.body.ProfileName }}"
            },
            {
              "id": "a310ee2c-e6b6-4dd4-b1a4-bde117c40b33",
              "name": "body.contact_phone",
              "type": "string",
              "value": "={{ $json.body.From }}"
            },
            {
              "id": "e22725dc-74d6-45e0-9dcd-9ace4a0833f9",
              "name": "body.message_text",
              "type": "string",
              "value": "={{ $json.body.Body }}"
            },
            {
              "id": "e99886d6-6e9e-4cac-b472-66a78228307a",
              "name": "body.source_channel",
              "type": "string",
              "value": "linkdin"
            },
            {
              "id": "28ea85de-6fcc-4bcf-b6b2-018176809f36",
              "name": "body.submitted_at",
              "type": "string",
              "value": "={{ new Date().toISOString() }}\n"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "a6917e9d-29e1-4920-9ef5-71f39cdb5300",
      "name": "Get Ai Response1",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2112,
        1520
      ],
      "parameters": {
        "url": "https://api.groq.com/openai/v1/chat/completions",
        "method": "POST",
        "options": {},
        "jsonBody": "={{ $json.requestBody }}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "your-authorization-token"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "2a6212f9-91e7-4cb6-98a3-34588d59de86",
      "name": "Send message",
      "type": "n8n-nodes-base.whatsApp",
      "position": [
        2912,
        1264
      ],
      "parameters": {
        "textBody": "={{ $json.ai_response }}",
        "operation": "send",
        "phoneNumberId": "your phone-number-id",
        "additionalFields": {},
        "recipientPhoneNumber": "={{ $json.body.contact_phone }}"
      },
      "typeVersion": 1.1
    },
    {
      "id": "742a220e-1611-4de5-8510-e26440573888",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -32,
        1088
      ],
      "parameters": {
        "width": 592,
        "height": 896,
        "content": "## Instant Reply SDR Worker (Multi-Channel Lead Auto-Responder)\n\nThis workflow acts as a real-time SDR that instantly responds to incoming leads across WhatsApp, Website, Instagram, Facebook, and LinkedIn. It ensures every lead receives a fast, human-like reply while automatically tracking all interactions in one place.\n\n### How it works\n- Triggers when a new lead message is received via a channel-specific webhook  \n- Captures and normalizes lead data (name, contact details, message, source)  \n- Checks IST-based working day and working hours  \n- Generates a short, human-like AI response based on channel and timing  \n- Routes the response to the correct platform (chat or email)  \n- Sends the reply and prepares data for logging  \n\n### Setup steps\n- Create webhook nodes for WhatsApp, Website, Instagram, Facebook, and LinkedIn  \n- Connect each platform to its respective webhook URL  \n- Use Set nodes to normalize incoming lead data  \n- Add working-hours logic using Code and IF nodes (IST)  \n- Connect an AI provider endpoint for response generation  \n- Use Switch nodes to route replies to the correct channel  \n- Log lead details, AI response, timestamps, and status in Google Sheets  \n- Activate the workflow and test with sample leads  \n"
      },
      "typeVersion": 1
    },
    {
      "id": "ffc9b41b-03cc-4018-8d57-a98959c3edf6",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        576,
        1088
      ],
      "parameters": {
        "color": 7,
        "width": 816,
        "height": 896,
        "content": "## Step 1: Lead Intake & Normalization\nCaptures incoming leads from WhatsApp, Website, Instagram, Facebook, and LinkedIn, then standardizes all lead data into a single structure.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "5347f93b-6378-43d5-9c9e-eb7dc349cbc8",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1408,
        1088
      ],
      "parameters": {
        "color": 7,
        "width": 880,
        "height": 896,
        "content": "## Step 2: Working Hours & AI Response\nEvaluates IST working hours and generates a context-aware AI response suited to the channel and timing.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "ab354c64-38ac-44f4-bde2-6e786d53cd65",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2304,
        1088
      ],
      "parameters": {
        "color": 7,
        "width": 1376,
        "height": 896,
        "content": "## Step 3: Send Reply & Log Data\nRoutes the response to the correct channel, sends it to the lead, and logs the full interaction into Google Sheets.\n"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Switch2": {
      "main": [
        [
          {
            "node": "Extract Day and Hours1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Extract Day and Hours1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Extract Day and Hours1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Extract Day and Hours1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Extract Day and Hours1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch3": {
      "main": [
        [
          {
            "node": "Send message",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send Instagram Message1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send Facebook Messages1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send Linkdin Messages1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send a message1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send message": {
      "main": [
        [
          {
            "node": "Code in JavaScript5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send a message1": {
      "main": [
        [
          {
            "node": "Code in JavaScript5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Ai Response1": {
      "main": [
        [
          {
            "node": "Code in JavaScript4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript3": {
      "main": [
        [
          {
            "node": "Get Ai Response1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript4": {
      "main": [
        [
          {
            "node": "Switch3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript5": {
      "main": [
        [
          {
            "node": "google-sheet-name",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize Lead Data5": {
      "main": [
        [
          {
            "node": "Switch2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize Lead Data6": {
      "main": [
        [
          {
            "node": "Switch2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize Lead Data7": {
      "main": [
        [
          {
            "node": "Switch2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize Lead Data8": {
      "main": [
        [
          {
            "node": "Switch2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize Lead Data9": {
      "main": [
        [
          {
            "node": "Switch2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Day and Hours1": {
      "main": [
        [
          {
            "node": "Is Working Day and Working Hour?1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Linkdin Messages1": {
      "main": [
        [
          {
            "node": "Code in JavaScript5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Incomming Lead Website1": {
      "main": [
        [
          {
            "node": "Normalize Lead Data5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Incomming Lead linkdin1": {
      "main": [
        [
          {
            "node": "Normalize Lead Data9",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Facebook Messages1": {
      "main": [
        [
          {
            "node": "Code in JavaScript5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Instagram Message1": {
      "main": [
        [
          {
            "node": "Code in JavaScript5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Incomming Lead facebook1": {
      "main": [
        [
          {
            "node": "Normalize Lead Data7",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Incomming Lead whatsapp1": {
      "main": [
        [
          {
            "node": "Normalize Lead Data6",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Incomming Lead instagram1": {
      "main": [
        [
          {
            "node": "Normalize Lead Data8",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Is Working Day and Working Hour?1": {
      "main": [
        [
          {
            "node": "Code in JavaScript3",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Code in JavaScript3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}