{
  "name": "Cold email Agent",
  "nodes": [
    {
      "parameters": {
        "path": "unsubscribe",
        "responseMode": "responseNode",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        -3904,
        -1120
      ],
      "id": "16616cb7-6640-48a5-9cab-3e35f679dfcf",
      "name": "Webhook"
    },
    {
      "parameters": {
        "respondWith": "redirect",
        "redirectURL": "https://your-privacy-is-importan-n27zrwo.gamma.site/",
        "options": {}
      },
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        -3200,
        -1120
      ],
      "id": "f5cdc6ad-e831-4cfd-9893-61c2bea3868b",
      "name": "Respond to Webhook"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "2ab238a7-b568-428d-a6d7-f855b8adcdf8",
              "name": "token",
              "value": "={{ $json.query.tkn }}",
              "type": "number"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -3680,
        -1120
      ],
      "id": "911704f5-fb02-4a99-b2d3-dc30b1e8747b",
      "name": "Edit Fields2"
    },
    {
      "parameters": {
        "operation": "update",
        "documentId": {
          "__rl": true,
          "value": "1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk",
          "mode": "list",
          "cachedResultName": "Research",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Token": "={{ $json.token }}",
            "Opted Out": "Yes"
          },
          "matchingColumns": [
            "Token"
          ],
          "schema": [
            {
              "id": "First Name",
              "displayName": "First Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Last Name",
              "displayName": "Last Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email Address",
              "displayName": "Email Address",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Phone Number",
              "displayName": "Phone Number",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Country ",
              "displayName": "Country ",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Location",
              "displayName": "Location",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Industry",
              "displayName": "Industry",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Company Name",
              "displayName": "Company Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Job Title",
              "displayName": "Job Title",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Seniority",
              "displayName": "Seniority",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Website URL",
              "displayName": "Website URL",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "LinkedIn URL",
              "displayName": "LinkedIn URL",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Analysed",
              "displayName": "Analysed",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Research Report",
              "displayName": "Research Report",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#1 Body",
              "displayName": "Email#1 Body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#1 Subject",
              "displayName": "Email#1 Subject",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email #2 Body",
              "displayName": "Email #2 Body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#3 Body",
              "displayName": "Email#3 Body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#3 Subject",
              "displayName": "Email#3 Subject",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Sender Email",
              "displayName": "Sender Email",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Time Zone",
              "displayName": "Time Zone",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#1 Sent",
              "displayName": "Email#1 Sent",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#2 Sent",
              "displayName": "Email#2 Sent",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#3 Sent",
              "displayName": "Email#3 Sent",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Message ID",
              "displayName": "Message ID",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Replied",
              "displayName": "Replied",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Token",
              "displayName": "Token",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Opted Out",
              "displayName": "Opted Out",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "displayName": "row_number",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "readOnly": true,
              "removed": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        -3408,
        -1120
      ],
      "id": "16241a8e-2eb4-4d36-8335-71665a22d2f0",
      "name": "Google Sheets2",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 11 * * Mon"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        -1376,
        -1472
      ],
      "id": "8d8642a2-25fd-468e-9289-d06121dd86c0",
      "name": "Schedule Trigger"
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json['Sender Email'] }}",
                    "rightValue": "kiaghasem.dev@gmail.com",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "id": "b895fd00-6f66-41d1-ab55-b1337e744a7f"
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "kgd"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "b90ae81e-e015-4138-955b-f8efae253fba",
                    "leftValue": "={{ $json['Sender Email'] }}",
                    "rightValue": "kia@kamexa.ai",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "k"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "93b60147-610f-4c3c-adf6-a7f8b2159096",
                    "leftValue": "={{ $json['Sender Email'] }}",
                    "rightValue": "youremail@gmail.com",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "h"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        -944,
        -1488
      ],
      "id": "9072ed19-175f-4a98-bdd1-43fa57782b9f",
      "name": "Switch"
    },
    {
      "parameters": {
        "sendTo": "=kiaghasem.dev@gmail.com",
        "subject": "={{ $json['Email#1 Subject'] }}",
        "message": "={{ $json['Email#1 Body'] }}<br><br>\n<a href=\"https://kiaghasem.app.n8n.cloud/webhook/unsubscribe?tkn={{ $json.Token }}\">Click Here to Unsubscribe</a>",
        "options": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        -128,
        -1712
      ],
      "id": "d60bd46b-b4aa-48f8-b1fb-b3a3e60d362a",
      "name": "Gmail",
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "appendOrUpdate",
        "documentId": {
          "__rl": true,
          "value": "1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk",
          "mode": "list",
          "cachedResultName": "Research",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "LinkedIn URL": "={{ $('Switch').item.json['LinkedIn URL'] }}",
            "Email#1 Sent": "Yes",
            "Message ID": "={{ $json.id }}"
          },
          "matchingColumns": [
            "LinkedIn URL"
          ],
          "schema": [
            {
              "id": "First Name",
              "displayName": "First Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Last Name",
              "displayName": "Last Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email Address",
              "displayName": "Email Address",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Phone Number",
              "displayName": "Phone Number",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Country ",
              "displayName": "Country ",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Location",
              "displayName": "Location",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Industry",
              "displayName": "Industry",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Company Name",
              "displayName": "Company Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Job Title",
              "displayName": "Job Title",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Seniority",
              "displayName": "Seniority",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Website URL",
              "displayName": "Website URL",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "LinkedIn URL",
              "displayName": "LinkedIn URL",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Analysed",
              "displayName": "Analysed",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Research Report",
              "displayName": "Research Report",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#1 Body",
              "displayName": "Email#1 Body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#1 Subject",
              "displayName": "Email#1 Subject",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email #2 Body",
              "displayName": "Email #2 Body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#3 Body",
              "displayName": "Email#3 Body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#3 Subject",
              "displayName": "Email#3 Subject",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Sender Email",
              "displayName": "Sender Email",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Time Zone",
              "displayName": "Time Zone",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#1 Sent",
              "displayName": "Email#1 Sent",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#2 Sent",
              "displayName": "Email#2 Sent",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#3 Sent",
              "displayName": "Email#3 Sent",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Message ID",
              "displayName": "Message ID",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Replied",
              "displayName": "Replied",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Token",
              "displayName": "Token",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Opted Out",
              "displayName": "Opted Out",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        0,
        -1920
      ],
      "id": "4ff62505-8aa7-42e4-82b3-08d8b9c65572",
      "name": "Google Sheets4",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        -352,
        -1792
      ],
      "id": "75aa8419-d246-4eaf-89bc-556ad4147ee1",
      "name": "Loop Over Items"
    },
    {
      "parameters": {
        "amount": "={{ Math.floor(Math.random() * (7 - 2 + 1)) + 2 }}\n"
      },
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        48,
        -1648
      ],
      "id": "76dc9f74-16f8-4ec3-a832-f5951e0a946a",
      "name": "Wait"
    },
    {
      "parameters": {
        "sendTo": "=kiaghasem.dev@gmail.com",
        "subject": "={{ $json['Email#1 Subject'] }}",
        "message": "={{ $json['Email#1 Body'] }}<br><br>\n<a href=\"https://kiaghasem.app.n8n.cloud/webhook/unsubscribe?tkn={{ $json.Token }}\">Click Here to Unsubscribe</a>",
        "options": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        752,
        -1312
      ],
      "id": "bcb4deb2-926c-4b97-9ca4-b3d8214d3310",
      "name": "Gmail3",
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "appendOrUpdate",
        "documentId": {
          "__rl": true,
          "value": "1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk",
          "mode": "list",
          "cachedResultName": "Research",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "LinkedIn URL": "={{ $('Switch').item.json['LinkedIn URL'] }}",
            "Email#1 Sent": "Yes",
            "Message ID": "={{ $json.id }}"
          },
          "matchingColumns": [
            "LinkedIn URL"
          ],
          "schema": [
            {
              "id": "First Name",
              "displayName": "First Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Last Name",
              "displayName": "Last Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email Address",
              "displayName": "Email Address",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Phone Number",
              "displayName": "Phone Number",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Country ",
              "displayName": "Country ",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Location",
              "displayName": "Location",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Industry",
              "displayName": "Industry",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Company Name",
              "displayName": "Company Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Job Title",
              "displayName": "Job Title",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Seniority",
              "displayName": "Seniority",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Website URL",
              "displayName": "Website URL",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "LinkedIn URL",
              "displayName": "LinkedIn URL",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Analysed",
              "displayName": "Analysed",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Research Report",
              "displayName": "Research Report",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#1 Body",
              "displayName": "Email#1 Body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#1 Subject",
              "displayName": "Email#1 Subject",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email #2 Body",
              "displayName": "Email #2 Body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#3 Body",
              "displayName": "Email#3 Body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#3 Subject",
              "displayName": "Email#3 Subject",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Sender Email",
              "displayName": "Sender Email",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Time Zone",
              "displayName": "Time Zone",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#1 Sent",
              "displayName": "Email#1 Sent",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#2 Sent",
              "displayName": "Email#2 Sent",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#3 Sent",
              "displayName": "Email#3 Sent",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Message ID",
              "displayName": "Message ID",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Replied",
              "displayName": "Replied",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Token",
              "displayName": "Token",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Opted Out",
              "displayName": "Opted Out",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        832,
        -1600
      ],
      "id": "b402e30b-7062-46ae-bee5-0e16423a0a4a",
      "name": "Google Sheets6",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        496,
        -1472
      ],
      "id": "ec1b9e32-d92f-4e07-ad29-20096bb52eac",
      "name": "Loop Over Items1"
    },
    {
      "parameters": {
        "amount": "={{ Math.floor(Math.random() * (7 - 2 + 1)) + 2 }}\n",
        "unit": "minutes"
      },
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        960,
        -1312
      ],
      "id": "7a61e395-f142-4b98-a41e-93e69347d2d1",
      "name": "Wait1"
    },
    {
      "parameters": {
        "sendTo": "=kiaghasem.dev@gmail.com",
        "subject": "={{ $json['Email#1 Subject'] }}",
        "message": "={{ $json['Email#1 Body'] }}<br><br>\n<a href=\"https://kiaghasem.app.n8n.cloud/webhook/unsubscribe?tkn={{ $json.Token }}\">Click Here to Unsubscribe</a>",
        "options": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        -48,
        -1088
      ],
      "id": "c3690df4-db62-4646-9200-8e45a40f09d9",
      "name": "Gmail4",
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "appendOrUpdate",
        "documentId": {
          "__rl": true,
          "value": "1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk",
          "mode": "list",
          "cachedResultName": "Research",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "LinkedIn URL": "={{ $('Switch').item.json['LinkedIn URL'] }}",
            "Email#1 Sent": "Yes",
            "Message ID": "={{ $json.id }}"
          },
          "matchingColumns": [
            "LinkedIn URL"
          ],
          "schema": [
            {
              "id": "First Name",
              "displayName": "First Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Last Name",
              "displayName": "Last Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email Address",
              "displayName": "Email Address",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Phone Number",
              "displayName": "Phone Number",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Country ",
              "displayName": "Country ",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Location",
              "displayName": "Location",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Industry",
              "displayName": "Industry",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Company Name",
              "displayName": "Company Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Job Title",
              "displayName": "Job Title",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Seniority",
              "displayName": "Seniority",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Website URL",
              "displayName": "Website URL",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "LinkedIn URL",
              "displayName": "LinkedIn URL",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Analysed",
              "displayName": "Analysed",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Research Report",
              "displayName": "Research Report",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#1 Body",
              "displayName": "Email#1 Body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#1 Subject",
              "displayName": "Email#1 Subject",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email #2 Body",
              "displayName": "Email #2 Body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#3 Body",
              "displayName": "Email#3 Body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#3 Subject",
              "displayName": "Email#3 Subject",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Sender Email",
              "displayName": "Sender Email",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Time Zone",
              "displayName": "Time Zone",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#1 Sent",
              "displayName": "Email#1 Sent",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#2 Sent",
              "displayName": "Email#2 Sent",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#3 Sent",
              "displayName": "Email#3 Sent",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Message ID",
              "displayName": "Message ID",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Replied",
              "displayName": "Replied",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Token",
              "displayName": "Token",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Opted Out",
              "displayName": "Opted Out",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        0,
        -1376
      ],
      "id": "fd7cfbae-b701-4737-aedf-9b7a1f30fbf6",
      "name": "Google Sheets7",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        -352,
        -1248
      ],
      "id": "0abbd89c-fed7-45dd-97d9-7a9607f42244",
      "name": "Loop Over Items2"
    },
    {
      "parameters": {
        "amount": "={{ Math.floor(Math.random() * (7 - 2 + 1)) + 2 }}\n"
      },
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        144,
        -1088
      ],
      "id": "fb6118ee-0cdb-45ab-9a6b-e3da302b5040",
      "name": "Wait2"
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "value": "1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk",
          "mode": "list",
          "cachedResultName": "Research",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk/edit#gid=0"
        },
        "filtersUI": {
          "values": [
            {
              "lookupColumn": "Email#1 Sent",
              "lookupValue": "No"
            },
            {
              "lookupColumn": "Time Zone",
              "lookupValue": "T2"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        -1152,
        -1472
      ],
      "id": "6655d108-1c6c-4bb7-b738-f2244a20eb89",
      "name": "Google Sheets3",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json['Sender Email'] }}",
                    "rightValue": "kiaghasem.dev@gmail.com",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "id": "b895fd00-6f66-41d1-ab55-b1337e744a7f"
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "kgd"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "b90ae81e-e015-4138-955b-f8efae253fba",
                    "leftValue": "={{ $json['Sender Email'] }}",
                    "rightValue": "kia@kamexa.ai",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "k"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "93b60147-610f-4c3c-adf6-a7f8b2159096",
                    "leftValue": "={{ $json['Sender Email'] }}",
                    "rightValue": "youremail@gmail.com",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "h"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        -4400,
        240
      ],
      "id": "53a29af7-1ac7-4501-8863-a1624dca71ab",
      "name": "Switch1"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "177601be-b2c3-45cc-8e15-cd064fbaf578",
              "leftValue": "={{ $json.replied }}",
              "rightValue": "Yes",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -2848,
        272
      ],
      "id": "b6f4ec01-21e3-4aa8-bc1d-6d9e2b1fdc91",
      "name": "If1"
    },
    {
      "parameters": {
        "mode": "combine",
        "combineBy": "combineByPosition",
        "options": {}
      },
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3.1,
      "position": [
        -3088,
        272
      ],
      "id": "79a66ac2-3b89-4d92-8204-931a0e1a3a17",
      "name": "Merge1"
    },
    {
      "parameters": {
        "operation": "getAll",
        "limit": 1,
        "filters": {
          "sender": "={{ $json['Email Address'] }}"
        }
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        -3552,
        416
      ],
      "id": "2fff5559-2bb0-4dc1-a957-3b7000faa3a5",
      "name": "Replied?1",
      "alwaysOutputData": true,
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "appendOrUpdate",
        "documentId": {
          "__rl": true,
          "value": "1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk",
          "mode": "list",
          "cachedResultName": "Research",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "LinkedIn URL": "={{ $json[\"LinkedIn URL\"] }}",
            "Replied": "Yes"
          },
          "matchingColumns": [
            "LinkedIn URL"
          ],
          "schema": [
            {
              "id": "First Name",
              "displayName": "First Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Last Name",
              "displayName": "Last Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email Address",
              "displayName": "Email Address",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Phone Number",
              "displayName": "Phone Number",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Country ",
              "displayName": "Country ",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Location",
              "displayName": "Location",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Industry",
              "displayName": "Industry",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Company Name",
              "displayName": "Company Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Job Title",
              "displayName": "Job Title",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Seniority",
              "displayName": "Seniority",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Website URL",
              "displayName": "Website URL",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "LinkedIn URL",
              "displayName": "LinkedIn URL",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Analysed",
              "displayName": "Analysed",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Research Report",
              "displayName": "Research Report",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#1 Body",
              "displayName": "Email#1 Body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#1 Subject",
              "displayName": "Email#1 Subject",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email #2 Body",
              "displayName": "Email #2 Body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#3 Body",
              "displayName": "Email#3 Body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#3 Subject",
              "displayName": "Email#3 Subject",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Sender Email",
              "displayName": "Sender Email",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Time Zone",
              "displayName": "Time Zone",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#1 Sent",
              "displayName": "Email#1 Sent",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#2 Sent",
              "displayName": "Email#2 Sent",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#3 Sent",
              "displayName": "Email#3 Sent",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Message ID",
              "displayName": "Message ID",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Replied",
              "displayName": "Replied",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Token",
              "displayName": "Token",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Opted Out",
              "displayName": "Opted Out",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        -2656,
        416
      ],
      "id": "46169780-f529-4f7a-b552-715595a87578",
      "name": "Replied = Yes1",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "appendOrUpdate",
        "documentId": {
          "__rl": true,
          "value": "1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk",
          "mode": "list",
          "cachedResultName": "Research",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "LinkedIn URL": "={{ $('Switch1').item.json['LinkedIn URL'] }}",
            "Email#2 Sent": "Yes"
          },
          "matchingColumns": [
            "LinkedIn URL"
          ],
          "schema": [
            {
              "id": "First Name",
              "displayName": "First Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Last Name",
              "displayName": "Last Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email Address",
              "displayName": "Email Address",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Phone Number",
              "displayName": "Phone Number",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Country ",
              "displayName": "Country ",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Location",
              "displayName": "Location",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Industry",
              "displayName": "Industry",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Company Name",
              "displayName": "Company Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Job Title",
              "displayName": "Job Title",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Seniority",
              "displayName": "Seniority",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Website URL",
              "displayName": "Website URL",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "LinkedIn URL",
              "displayName": "LinkedIn URL",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Analysed",
              "displayName": "Analysed",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Research Report",
              "displayName": "Research Report",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#1 Body",
              "displayName": "Email#1 Body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#1 Subject",
              "displayName": "Email#1 Subject",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email #2 Body",
              "displayName": "Email #2 Body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#3 Body",
              "displayName": "Email#3 Body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#3 Subject",
              "displayName": "Email#3 Subject",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Sender Email",
              "displayName": "Sender Email",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Time Zone",
              "displayName": "Time Zone",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#1 Sent",
              "displayName": "Email#1 Sent",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#2 Sent",
              "displayName": "Email#2 Sent",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#3 Sent",
              "displayName": "Email#3 Sent",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Message ID",
              "displayName": "Message ID",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Replied",
              "displayName": "Replied",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Token",
              "displayName": "Token",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Opted Out",
              "displayName": "Opted Out",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        -3536,
        80
      ],
      "id": "f4f1df45-f9af-4361-81c6-958fbc6bf032",
      "name": "Google Sheets9",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        -3872,
        240
      ],
      "id": "055b2c3f-7707-4233-b631-700c68542611",
      "name": "Loop Over Items3"
    },
    {
      "parameters": {
        "amount": "={{ Math.floor(Math.random() * (7 - 2 + 1)) + 2 }}\n"
      },
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        -2080,
        416
      ],
      "id": "3cd0c276-be64-4e49-9c63-827e4ed53cab",
      "name": "Wait3"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://www.googleapis.com/gmail/v1/users/me/messages/send",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "gmailOAuth2",
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "raw",
              "value": "={{ $json.raw }}"
            },
            {
              "name": "=threadId",
              "value": "={{ $json.threadId }}"
            }
          ]
        },
        "options": {
          "redirect": {
            "redirect": {}
          }
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -2320,
        288
      ],
      "id": "74017721-d919-4467-976e-3dd611b4f2e7",
      "name": "HTTP Request3",
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "// JavaScript code for n8n Code node to prepare HTML email for Gmail API\nconst emailData = {\n  messageId: $input.item.json['Message ID'],\n  threadId: $input.item.json['Thread ID'] || $input.item.json['Message ID'],\n  subject: $input.item.json['Email#1 Subject'],\n  senderEmail: $input.item.json['Sender Email'],\n  recipientEmail: $input.item.json['Email Address'],\n  token: $input.item.json['Token']\n};\n\n// Check available input keys to help diagnose the issue\nconst inputKeys = Object.keys($input.item.json);\nconsole.log('Available input keys:', inputKeys);\n\n// Try to find the email body in different possible formats\nlet emailBodyContent = '';\n// First try the exact key name\nif ($input.item.json['Email#2 Body'] !== undefined) {\n  emailBodyContent = $input.item.json['Email#2 Body'];\n} \n// Try with a space after the hash\nelse if ($input.item.json['Email #2 Body'] !== undefined) {\n  emailBodyContent = $input.item.json['Email #2 Body'];\n} \n// Try other possible variations\nelse if ($input.item.json['EmailBody'] !== undefined) {\n  emailBodyContent = $input.item.json['EmailBody'];\n} \n// Default fallback message if none found\nelse {\n  emailBodyContent = \"Thank you for your attention to this matter.\";\n  console.log(\"No email body found, using default text\");\n}\n\n// Ensure message ID is properly formatted\nconst formattedMessageId = emailData.messageId.startsWith('<') ? \n  emailData.messageId : \n  `<${emailData.messageId}>`;\n\n// Create HTML email body with unsubscribe link\nconst htmlBody = `${emailBodyContent}<br><br>\n<a href=\"https://kiaghasem.app.n8n.cloud/webhook/unsubscribe?tkn=${emailData.token}\">Click Here to Unsubscribe</a>`;\n\n// Create email in RFC 2822 format with HTML content type\nconst emailContent = \n  `In-Reply-To: ${formattedMessageId}\\n` +\n  `References: ${formattedMessageId}\\n` +\n  `Subject: Re: ${emailData.subject}\\n` +\n  `From: ${emailData.senderEmail}\\n` +\n  `To: ${emailData.recipientEmail}\\n` +\n  `Content-Type: text/html; charset=\"UTF-8\"\\n\\n` +\n  `${htmlBody}`;\n\n// Base64 encode and convert to base64url format\nconst base64EncodedEmail = Buffer.from(emailContent)\n  .toString('base64')\n  .replace(/\\+/g, '-')\n  .replace(/\\//g, '_')\n  .replace(/=+$/, '');\n\n// Return an object with the encoded email and thread ID\nreturn {\n  json: {\n    raw: base64EncodedEmail,\n    threadId: emailData.threadId\n  }\n};\n"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -2560,
        288
      ],
      "id": "4c84e1e7-7a9a-4057-84f3-88a6d769af08",
      "name": "Code3"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "177601be-b2c3-45cc-8e15-cd064fbaf578",
              "leftValue": "={{ $json.replied }}",
              "rightValue": "Yes",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -2864,
        -400
      ],
      "id": "653adbc5-01db-465c-a42d-15b19b51f42f",
      "name": "If2"
    },
    {
      "parameters": {
        "mode": "combine",
        "combineBy": "combineByPosition",
        "options": {}
      },
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3.1,
      "position": [
        -3088,
        -400
      ],
      "id": "be573783-2cf6-43ec-91f9-4571da360d55",
      "name": "Merge2"
    },
    {
      "parameters": {
        "operation": "getAll",
        "limit": 3,
        "filters": {
          "sender": "={{ $json['Email Address'] }}"
        }
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        -3584,
        -224
      ],
      "id": "2f715b14-e530-4efc-8ad8-d795036aa14d",
      "name": "Replied?2",
      "alwaysOutputData": true,
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "appendOrUpdate",
        "documentId": {
          "__rl": true,
          "value": "1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk",
          "mode": "list",
          "cachedResultName": "Research",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "LinkedIn URL": "={{ $json[\"LinkedIn URL\"] }}",
            "Replied": "Yes"
          },
          "matchingColumns": [
            "LinkedIn URL"
          ],
          "schema": [
            {
              "id": "First Name",
              "displayName": "First Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Last Name",
              "displayName": "Last Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email Address",
              "displayName": "Email Address",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Phone Number",
              "displayName": "Phone Number",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Country ",
              "displayName": "Country ",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Location",
              "displayName": "Location",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Industry",
              "displayName": "Industry",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Company Name",
              "displayName": "Company Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Job Title",
              "displayName": "Job Title",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Seniority",
              "displayName": "Seniority",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Website URL",
              "displayName": "Website URL",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "LinkedIn URL",
              "displayName": "LinkedIn URL",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Analysed",
              "displayName": "Analysed",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Research Report",
              "displayName": "Research Report",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#1 Body",
              "displayName": "Email#1 Body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#1 Subject",
              "displayName": "Email#1 Subject",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email #2 Body",
              "displayName": "Email #2 Body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#3 Body",
              "displayName": "Email#3 Body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#3 Subject",
              "displayName": "Email#3 Subject",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Sender Email",
              "displayName": "Sender Email",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Time Zone",
              "displayName": "Time Zone",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#1 Sent",
              "displayName": "Email#1 Sent",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#2 Sent",
              "displayName": "Email#2 Sent",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#3 Sent",
              "displayName": "Email#3 Sent",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Message ID",
              "displayName": "Message ID",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Replied",
              "displayName": "Replied",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Token",
              "displayName": "Token",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Opted Out",
              "displayName": "Opted Out",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        -2672,
        -208
      ],
      "id": "a2f7eeeb-f2b5-4a09-9aee-2a82852ff970",
      "name": "Replied = Yes2",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "appendOrUpdate",
        "documentId": {
          "__rl": true,
          "value": "1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk",
          "mode": "list",
          "cachedResultName": "Research",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "LinkedIn URL": "={{ $('Switch1').item.json['LinkedIn URL'] }}",
            "Email#2 Sent": "Yes"
          },
          "matchingColumns": [
            "LinkedIn URL"
          ],
          "schema": [
            {
              "id": "First Name",
              "displayName": "First Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Last Name",
              "displayName": "Last Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email Address",
              "displayName": "Email Address",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Phone Number",
              "displayName": "Phone Number",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Country ",
              "displayName": "Country ",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Location",
              "displayName": "Location",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Industry",
              "displayName": "Industry",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Company Name",
              "displayName": "Company Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Job Title",
              "displayName": "Job Title",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Seniority",
              "displayName": "Seniority",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Website URL",
              "displayName": "Website URL",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "LinkedIn URL",
              "displayName": "LinkedIn URL",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Analysed",
              "displayName": "Analysed",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Research Report",
              "displayName": "Research Report",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#1 Body",
              "displayName": "Email#1 Body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#1 Subject",
              "displayName": "Email#1 Subject",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email #2 Body",
              "displayName": "Email #2 Body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#3 Body",
              "displayName": "Email#3 Body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#3 Subject",
              "displayName": "Email#3 Subject",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Sender Email",
              "displayName": "Sender Email",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Time Zone",
              "displayName": "Time Zone",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#1 Sent",
              "displayName": "Email#1 Sent",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#2 Sent",
              "displayName": "Email#2 Sent",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#3 Sent",
              "displayName": "Email#3 Sent",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Message ID",
              "displayName": "Message ID",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Replied",
              "displayName": "Replied",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Token",
              "displayName": "Token",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Opted Out",
              "displayName": "Opted Out",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        -3616,
        -560
      ],
      "id": "2762a770-f432-426b-a360-7a9b4e988c5a",
      "name": "Google Sheets10",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        -3904,
        -448
      ],
      "id": "c0cd7def-d49f-41f7-bf80-6ec4c4ede177",
      "name": "Loop Over Items4"
    },
    {
      "parameters": {
        "amount": "={{ Math.floor(Math.random() * (7 - 2 + 1)) + 2 }}\n"
      },
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        -2080,
        -208
      ],
      "id": "668b98d5-2ea2-4c23-913c-1059d4c2403e",
      "name": "Wait4"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://www.googleapis.com/gmail/v1/users/me/messages/send",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "gmailOAuth2",
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "raw",
              "value": "={{ $json.raw }}"
            },
            {
              "name": "=threadId",
              "value": "={{ $json.threadId }}"
            }
          ]
        },
        "options": {
          "redirect": {
            "redirect": {}
          }
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -2352,
        -384
      ],
      "id": "dca5e5f4-5f49-4bc1-9669-e87a24e1df9c",
      "name": "HTTP Request4",
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "// JavaScript code for n8n Code node to prepare HTML email for Gmail API\nconst emailData = {\n  messageId: $input.item.json['Message ID'],\n  threadId: $input.item.json['Thread ID'] || $input.item.json['Message ID'],\n  subject: $input.item.json['Email#1 Subject'],\n  senderEmail: $input.item.json['Sender Email'],\n  recipientEmail: $input.item.json['Email Address'],\n  token: $input.item.json['Token']\n};\n\n// Check available input keys to help diagnose the issue\nconst inputKeys = Object.keys($input.item.json);\nconsole.log('Available input keys:', inputKeys);\n\n// Try to find the email body in different possible formats\nlet emailBodyContent = '';\n// First try the exact key name\nif ($input.item.json['Email#2 Body'] !== undefined) {\n  emailBodyContent = $input.item.json['Email#2 Body'];\n} \n// Try with a space after the hash\nelse if ($input.item.json['Email #2 Body'] !== undefined) {\n  emailBodyContent = $input.item.json['Email #2 Body'];\n} \n// Try other possible variations\nelse if ($input.item.json['EmailBody'] !== undefined) {\n  emailBodyContent = $input.item.json['EmailBody'];\n} \n// Default fallback message if none found\nelse {\n  emailBodyContent = \"Thank you for your attention to this matter.\";\n  console.log(\"No email body found, using default text\");\n}\n\n// Ensure message ID is properly formatted\nconst formattedMessageId = emailData.messageId.startsWith('<') ? \n  emailData.messageId : \n  `<${emailData.messageId}>`;\n\n// Create HTML email body with unsubscribe link\nconst htmlBody = `${emailBodyContent}<br><br>\n<a href=\"https://kiaghasem.app.n8n.cloud/webhook/unsubscribe?tkn=${emailData.token}\">Click Here to Unsubscribe</a>`;\n\n// Create email in RFC 2822 format with HTML content type\nconst emailContent = \n  `In-Reply-To: ${formattedMessageId}\\n` +\n  `References: ${formattedMessageId}\\n` +\n  `Subject: Re: ${emailData.subject}\\n` +\n  `From: ${emailData.senderEmail}\\n` +\n  `To: ${emailData.recipientEmail}\\n` +\n  `Content-Type: text/html; charset=\"UTF-8\"\\n\\n` +\n  `${htmlBody}`;\n\n// Base64 encode and convert to base64url format\nconst base64EncodedEmail = Buffer.from(emailContent)\n  .toString('base64')\n  .replace(/\\+/g, '-')\n  .replace(/\\//g, '_')\n  .replace(/=+$/, '');\n\n// Return an object with the encoded email and thread ID\nreturn {\n  json: {\n    raw: base64EncodedEmail,\n    threadId: emailData.threadId\n  }\n};\n"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -2560,
        -384
      ],
      "id": "59ca323b-d116-4bae-9662-b0a7ec81b274",
      "name": "Code4"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "2d1b89f0-661b-4b21-9bb2-cb8419b22035",
              "name": "replied",
              "value": "={{ Object.keys($json).length > 0 ? \"Yes\" : \"No\" }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -3312,
        1040
      ],
      "id": "fc733935-9c6c-4b19-b0df-1346cab351c6",
      "name": "Edit Fields3"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "177601be-b2c3-45cc-8e15-cd064fbaf578",
              "leftValue": "={{ $json.replied }}",
              "rightValue": "Yes",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -2832,
        896
      ],
      "id": "c179d109-9736-4a2e-90cd-e4490a417bc9",
      "name": "If3"
    },
    {
      "parameters": {
        "mode": "combine",
        "combineBy": "combineByPosition",
        "options": {}
      },
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3.1,
      "position": [
        -3056,
        896
      ],
      "id": "4c84b2b0-4b5f-4be2-8b44-2a574cc0d9e1",
      "name": "Merge3"
    },
    {
      "parameters": {
        "operation": "getAll",
        "limit": 3,
        "filters": {
          "sender": "={{ $json['Email Address'] }}"
        }
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        -3520,
        1040
      ],
      "id": "da75e7e1-3fc8-41bc-9f66-eb4ad25298c1",
      "name": "Replied?3",
      "alwaysOutputData": true,
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "appendOrUpdate",
        "documentId": {
          "__rl": true,
          "value": "1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk",
          "mode": "list",
          "cachedResultName": "Research",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "LinkedIn URL": "={{ $json[\"LinkedIn URL\"] }}",
            "Replied": "Yes"
          },
          "matchingColumns": [
            "LinkedIn URL"
          ],
          "schema": [
            {
              "id": "First Name",
              "displayName": "First Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Last Name",
              "displayName": "Last Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email Address",
              "displayName": "Email Address",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Phone Number",
              "displayName": "Phone Number",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Country ",
              "displayName": "Country ",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Location",
              "displayName": "Location",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Industry",
              "displayName": "Industry",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Company Name",
              "displayName": "Company Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Job Title",
              "displayName": "Job Title",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Seniority",
              "displayName": "Seniority",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Website URL",
              "displayName": "Website URL",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "LinkedIn URL",
              "displayName": "LinkedIn URL",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Analysed",
              "displayName": "Analysed",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Research Report",
              "displayName": "Research Report",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#1 Body",
              "displayName": "Email#1 Body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#1 Subject",
              "displayName": "Email#1 Subject",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email #2 Body",
              "displayName": "Email #2 Body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#3 Body",
              "displayName": "Email#3 Body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#3 Subject",
              "displayName": "Email#3 Subject",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Sender Email",
              "displayName": "Sender Email",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Time Zone",
              "displayName": "Time Zone",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#1 Sent",
              "displayName": "Email#1 Sent",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#2 Sent",
              "displayName": "Email#2 Sent",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#3 Sent",
              "displayName": "Email#3 Sent",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Message ID",
              "displayName": "Message ID",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Replied",
              "displayName": "Replied",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Token",
              "displayName": "Token",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Opted Out",
              "displayName": "Opted Out",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        -2640,
        1056
      ],
      "id": "476ade11-4d36-4d5d-9ebf-82bd593d8595",
      "name": "Replied = Yes3",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "appendOrUpdate",
        "documentId": {
          "__rl": true,
          "value": "1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk",
          "mode": "list",
          "cachedResultName": "Research",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "LinkedIn URL": "={{ $('Switch1').item.json['LinkedIn URL'] }}",
            "Email#2 Sent": "Yes"
          },
          "matchingColumns": [
            "LinkedIn URL"
          ],
          "schema": [
            {
              "id": "First Name",
              "displayName": "First Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Last Name",
              "displayName": "Last Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email Address",
              "displayName": "Email Address",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Phone Number",
              "displayName": "Phone Number",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Country ",
              "displayName": "Country ",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Location",
              "displayName": "Location",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Industry",
              "displayName": "Industry",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Company Name",
              "displayName": "Company Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Job Title",
              "displayName": "Job Title",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Seniority",
              "displayName": "Seniority",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Website URL",
              "displayName": "Website URL",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "LinkedIn URL",
              "displayName": "LinkedIn URL",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Analysed",
              "displayName": "Analysed",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Research Report",
              "displayName": "Research Report",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#1 Body",
              "displayName": "Email#1 Body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#1 Subject",
              "displayName": "Email#1 Subject",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email #2 Body",
              "displayName": "Email #2 Body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#3 Body",
              "displayName": "Email#3 Body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#3 Subject",
              "displayName": "Email#3 Subject",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Sender Email",
              "displayName": "Sender Email",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Time Zone",
              "displayName": "Time Zone",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#1 Sent",
              "displayName": "Email#1 Sent",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#2 Sent",
              "displayName": "Email#2 Sent",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#3 Sent",
              "displayName": "Email#3 Sent",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Message ID",
              "displayName": "Message ID",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Replied",
              "displayName": "Replied",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Token",
              "displayName": "Token",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Opted Out",
              "displayName": "Opted Out",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        -3520,
        736
      ],
      "id": "fa46638a-711c-4432-b7fc-11f61a94f246",
      "name": "Google Sheets12",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        -3840,
        880
      ],
      "id": "9abb7120-4994-4abe-bd27-a8160308cea3",
      "name": "Loop Over Items6"
    },
    {
      "parameters": {
        "amount": "={{ Math.floor(Math.random() * (7 - 2 + 1)) + 2 }}\n"
      },
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        -2096,
        1056
      ],
      "id": "915d28dc-431d-45f5-aaca-d0fd560756a5",
      "name": "Wait6"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://www.googleapis.com/gmail/v1/users/me/messages/send",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "gmailOAuth2",
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "raw",
              "value": "={{ $json.raw }}"
            },
            {
              "name": "=threadId",
              "value": "={{ $json.threadId }}"
            }
          ]
        },
        "options": {
          "redirect": {
            "redirect": {}
          }
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -2352,
        912
      ],
      "id": "8c32e1ea-1184-4243-bd56-acb6c37cd1dc",
      "name": "HTTP Request6",
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "// JavaScript code for n8n Code node to prepare HTML email for Gmail API\nconst emailData = {\n  messageId: $input.item.json['Message ID'],\n  threadId: $input.item.json['Thread ID'] || $input.item.json['Message ID'],\n  subject: $input.item.json['Email#1 Subject'],\n  senderEmail: $input.item.json['Sender Email'],\n  recipientEmail: $input.item.json['Email Address'],\n  token: $input.item.json['Token']\n};\n\n// Check available input keys to help diagnose the issue\nconst inputKeys = Object.keys($input.item.json);\nconsole.log('Available input keys:', inputKeys);\n\n// Try to find the email body in different possible formats\nlet emailBodyContent = '';\n// First try the exact key name\nif ($input.item.json['Email#2 Body'] !== undefined) {\n  emailBodyContent = $input.item.json['Email#2 Body'];\n} \n// Try with a space after the hash\nelse if ($input.item.json['Email #2 Body'] !== undefined) {\n  emailBodyContent = $input.item.json['Email #2 Body'];\n} \n// Try other possible variations\nelse if ($input.item.json['EmailBody'] !== undefined) {\n  emailBodyContent = $input.item.json['EmailBody'];\n} \n// Default fallback message if none found\nelse {\n  emailBodyContent = \"Thank you for your attention to this matter.\";\n  console.log(\"No email body found, using default text\");\n}\n\n// Ensure message ID is properly formatted\nconst formattedMessageId = emailData.messageId.startsWith('<') ? \n  emailData.messageId : \n  `<${emailData.messageId}>`;\n\n// Create HTML email body with unsubscribe link\nconst htmlBody = `${emailBodyContent}<br><br>\n<a href=\"https://kiaghasem.app.n8n.cloud/webhook/unsubscribe?tkn=${emailData.token}\">Click Here to Unsubscribe</a>`;\n\n// Create email in RFC 2822 format with HTML content type\nconst emailContent = \n  `In-Reply-To: ${formattedMessageId}\\n` +\n  `References: ${formattedMessageId}\\n` +\n  `Subject: Re: ${emailData.subject}\\n` +\n  `From: ${emailData.senderEmail}\\n` +\n  `To: ${emailData.recipientEmail}\\n` +\n  `Content-Type: text/html; charset=\"UTF-8\"\\n\\n` +\n  `${htmlBody}`;\n\n// Base64 encode and convert to base64url format\nconst base64EncodedEmail = Buffer.from(emailContent)\n  .toString('base64')\n  .replace(/\\+/g, '-')\n  .replace(/\\//g, '_')\n  .replace(/=+$/, '');\n\n// Return an object with the encoded email and thread ID\nreturn {\n  json: {\n    raw: base64EncodedEmail,\n    threadId: emailData.threadId\n  }\n};\n"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -2560,
        912
      ],
      "id": "c31f6884-cec8-4371-9fa1-2cd365223942",
      "name": "Code6"
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 11 * * Wed"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        -4896,
        256
      ],
      "id": "8eaf6730-b0d5-4008-a827-a97a9d92b614",
      "name": "Schedule Trigger1"
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "value": "1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk",
          "mode": "list",
          "cachedResultName": "Research",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk/edit#gid=0"
        },
        "filtersUI": {
          "values": [
            {
              "lookupColumn": "Email#1 Sent",
              "lookupValue": "Yes"
            },
            {
              "lookupColumn": "Email#2 Sent",
              "lookupValue": "No"
            },
            {
              "lookupColumn": "Time Zone",
              "lookupValue": "T2"
            },
            {
              "lookupColumn": "Replied",
              "lookupValue": "No"
            },
            {
              "lookupColumn": "Opted Out",
              "lookupValue": "No"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        -4640,
        256
      ],
      "id": "9acf3f3f-5428-4afb-8997-71b87102e1f3",
      "name": "Google Sheets5",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "2d1b89f0-661b-4b21-9bb2-cb8419b22035",
              "name": "replied",
              "value": "={{ Object.keys($json).length > 0 ? \"Yes\" : \"No\" }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -3344,
        416
      ],
      "id": "f0fb8bf1-1d9b-447d-8b5a-7638592d2dca",
      "name": "Edit Fields4"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "2d1b89f0-661b-4b21-9bb2-cb8419b22035",
              "name": "replied",
              "value": "={{ Object.keys($json).length > 0 ? \"Yes\" : \"No\" }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -3376,
        -224
      ],
      "id": "7a48e094-d50a-43b9-937e-9b8d5fb9343f",
      "name": "Edit Fields5"
    },
    {
      "parameters": {
        "sendTo": "kiaghasem.dev@gmail.com",
        "subject": "={{ $json[\"Email#3 Subject\"] }}",
        "message": "={{ $json['Email#3 Body'] }}<br><br>\n<a href=\"https://kiaghasem.app.n8n.cloud/webhook/unsubscribe?tkn={{ $json.Token }}\">Click Here to Unsubscribe</a>",
        "options": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        928,
        240
      ],
      "id": "1d356a71-0fb6-4a2f-a64c-5f0984c0eb1b",
      "name": "Gmail1",
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "177601be-b2c3-45cc-8e15-cd064fbaf578",
              "leftValue": "={{ $json.replied }}",
              "rightValue": "Yes",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        592,
        -320
      ],
      "id": "95a2e8dc-1b01-41a4-8453-3fac576f714a",
      "name": "If"
    },
    {
      "parameters": {
        "mode": "combine",
        "combineBy": "combineByPosition",
        "options": {}
      },
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3.1,
      "position": [
        352,
        -384
      ],
      "id": "6cbda1b7-783f-47b3-b9ae-fb0d719e4459",
      "name": "Merge"
    },
    {
      "parameters": {
        "operation": "getAll",
        "limit": 3,
        "filters": {
          "sender": "={{ $json['Email Address'] }}"
        }
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        -80,
        -256
      ],
      "id": "58026f4c-3f26-4d76-a2d5-dc43d4cfbf9f",
      "name": "Replied?",
      "alwaysOutputData": true,
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "appendOrUpdate",
        "documentId": {
          "__rl": true,
          "value": "1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk",
          "mode": "list",
          "cachedResultName": "Research",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "LinkedIn URL": "={{ $json[\"LinkedIn URL\"] }}",
            "Replied": "Yes"
          },
          "matchingColumns": [
            "LinkedIn URL"
          ],
          "schema": [
            {
              "id": "First Name",
              "displayName": "First Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Last Name",
              "displayName": "Last Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email Address",
              "displayName": "Email Address",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Phone Number",
              "displayName": "Phone Number",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Country ",
              "displayName": "Country ",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Location",
              "displayName": "Location",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Industry",
              "displayName": "Industry",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Company Name",
              "displayName": "Company Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Job Title",
              "displayName": "Job Title",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Seniority",
              "displayName": "Seniority",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Website URL",
              "displayName": "Website URL",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "LinkedIn URL",
              "displayName": "LinkedIn URL",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Analysed",
              "displayName": "Analysed",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Research Report",
              "displayName": "Research Report",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#1 Body",
              "displayName": "Email#1 Body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#1 Subject",
              "displayName": "Email#1 Subject",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email #2 Body",
              "displayName": "Email #2 Body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#3 Body",
              "displayName": "Email#3 Body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#3 Subject",
              "displayName": "Email#3 Subject",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Sender Email",
              "displayName": "Sender Email",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Time Zone",
              "displayName": "Time Zone",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#1 Sent",
              "displayName": "Email#1 Sent",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#2 Sent",
              "displayName": "Email#2 Sent",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#3 Sent",
              "displayName": "Email#3 Sent",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Message ID",
              "displayName": "Message ID",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Replied",
              "displayName": "Replied",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Token",
              "displayName": "Token",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Opted Out",
              "displayName": "Opted Out",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        800,
        -160
      ],
      "id": "96b3518f-caf6-48ed-8d8f-98b6fc8fca6d",
      "name": "Replied = Yes",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "sendTo": "kiaghasem.dev@gmail.com",
        "subject": "={{ $json[\"Email#3 Subject\"] }}",
        "message": "={{ $json['Email#3 Body'] }}<br><br>\n<a href=\"https://kiaghasem.app.n8n.cloud/webhook/unsubscribe?tkn={{ $json.Token }}\">Click Here to Unsubscribe</a>",
        "options": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        928,
        -304
      ],
      "id": "3b977c7d-75bf-407b-86b2-1a2633d46d0f",
      "name": "Gmail2",
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "appendOrUpdate",
        "documentId": {
          "__rl": true,
          "value": "1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk",
          "mode": "list",
          "cachedResultName": "Research",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "LinkedIn URL": "={{ $('Switch1').item.json['LinkedIn URL'] }}",
            "Email#2 Sent": "Yes"
          },
          "matchingColumns": [
            "LinkedIn URL"
          ],
          "schema": [
            {
              "id": "First Name",
              "displayName": "First Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Last Name",
              "displayName": "Last Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email Address",
              "displayName": "Email Address",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Phone Number",
              "displayName": "Phone Number",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Country ",
              "displayName": "Country ",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Location",
              "displayName": "Location",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Industry",
              "displayName": "Industry",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Company Name",
              "displayName": "Company Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Job Title",
              "displayName": "Job Title",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Seniority",
              "displayName": "Seniority",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Website URL",
              "displayName": "Website URL",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "LinkedIn URL",
              "displayName": "LinkedIn URL",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Analysed",
              "displayName": "Analysed",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Research Report",
              "displayName": "Research Report",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#1 Body",
              "displayName": "Email#1 Body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#1 Subject",
              "displayName": "Email#1 Subject",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email #2 Body",
              "displayName": "Email #2 Body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#3 Body",
              "displayName": "Email#3 Body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#3 Subject",
              "displayName": "Email#3 Subject",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Sender Email",
              "displayName": "Sender Email",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Time Zone",
              "displayName": "Time Zone",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#1 Sent",
              "displayName": "Email#1 Sent",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#2 Sent",
              "displayName": "Email#2 Sent",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#3 Sent",
              "displayName": "Email#3 Sent",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Message ID",
              "displayName": "Message ID",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Replied",
              "displayName": "Replied",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Token",
              "displayName": "Token",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Opted Out",
              "displayName": "Opted Out",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        -48,
        736
      ],
      "id": "6c4cd994-8c51-40fa-94b3-a54c458f8044",
      "name": "Google Sheets11",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 11 * * Fri"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        -1216,
        192
      ],
      "id": "25c5326e-d686-4d48-9335-cda4f0659eb9",
      "name": "Schedule Trigger2"
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "value": "1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk",
          "mode": "list",
          "cachedResultName": "Research",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk/edit#gid=0"
        },
        "filtersUI": {
          "values": [
            {
              "lookupColumn": "Email#1 Sent",
              "lookupValue": "Yes"
            },
            {
              "lookupColumn": "Email#2 Sent",
              "lookupValue": "Yes"
            },
            {
              "lookupColumn": "Email#3 Sent",
              "lookupValue": "No"
            },
            {
              "lookupColumn": "Time Zone",
              "lookupValue": "T2"
            },
            {
              "lookupColumn": "Replied",
              "lookupValue": "No"
            },
            {
              "lookupColumn": "Opted Out",
              "lookupValue": "No"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        -1008,
        192
      ],
      "id": "0a03efb1-3107-434e-a2bd-d33528c92975",
      "name": "Google Sheets8",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json['Sender Email'] }}",
                    "rightValue": "kiaghasem.dev@gmail.com",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "id": "b895fd00-6f66-41d1-ab55-b1337e744a7f"
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "kgd"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "b90ae81e-e015-4138-955b-f8efae253fba",
                    "leftValue": "={{ $json['Sender Email'] }}",
                    "rightValue": "kia@kamexa.ai",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "k"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "93b60147-610f-4c3c-adf6-a7f8b2159096",
                    "leftValue": "={{ $json['Sender Email'] }}",
                    "rightValue": "youremail@gmail.com",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "h"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        -768,
        192
      ],
      "id": "9fd28f8e-0bd3-48ee-ac42-4ba94ec2bc16",
      "name": "Switch2"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "2d1b89f0-661b-4b21-9bb2-cb8419b22035",
              "name": "replied",
              "value": "={{ Object.keys($json).length > 0 ? \"Yes\" : \"No\" }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        224,
        368
      ],
      "id": "b6efffe6-9e48-4df4-b3b5-8e4c816bf768",
      "name": "Edit Fields6"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "177601be-b2c3-45cc-8e15-cd064fbaf578",
              "leftValue": "={{ $json.replied }}",
              "rightValue": "Yes",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        672,
        224
      ],
      "id": "aaa664ad-ebec-4e6e-a03d-0b5b49c24876",
      "name": "If4"
    },
    {
      "parameters": {
        "mode": "combine",
        "combineBy": "combineByPosition",
        "options": {}
      },
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3.1,
      "position": [
        480,
        224
      ],
      "id": "19f01a57-e6f7-46f2-afa2-4e8b8daacad8",
      "name": "Merge4"
    },
    {
      "parameters": {
        "operation": "getAll",
        "limit": 3,
        "filters": {
          "sender": "={{ $json['Email Address'] }}"
        }
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        16,
        368
      ],
      "id": "26972021-cfeb-43bd-bf06-d3f453041ea1",
      "name": "Replied?4",
      "alwaysOutputData": true,
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "appendOrUpdate",
        "documentId": {
          "__rl": true,
          "value": "1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk",
          "mode": "list",
          "cachedResultName": "Research",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "LinkedIn URL": "={{ $json[\"LinkedIn URL\"] }}",
            "Replied": "Yes"
          },
          "matchingColumns": [
            "LinkedIn URL"
          ],
          "schema": [
            {
              "id": "First Name",
              "displayName": "First Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Last Name",
              "displayName": "Last Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email Address",
              "displayName": "Email Address",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Phone Number",
              "displayName": "Phone Number",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Country ",
              "displayName": "Country ",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Location",
              "displayName": "Location",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Industry",
              "displayName": "Industry",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Company Name",
              "displayName": "Company Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Job Title",
              "displayName": "Job Title",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Seniority",
              "displayName": "Seniority",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Website URL",
              "displayName": "Website URL",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "LinkedIn URL",
              "displayName": "LinkedIn URL",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Analysed",
              "displayName": "Analysed",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Research Report",
              "displayName": "Research Report",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#1 Body",
              "displayName": "Email#1 Body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#1 Subject",
              "displayName": "Email#1 Subject",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email #2 Body",
              "displayName": "Email #2 Body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#3 Body",
              "displayName": "Email#3 Body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#3 Subject",
              "displayName": "Email#3 Subject",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Sender Email",
              "displayName": "Sender Email",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Time Zone",
              "displayName": "Time Zone",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#1 Sent",
              "displayName": "Email#1 Sent",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#2 Sent",
              "displayName": "Email#2 Sent",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#3 Sent",
              "displayName": "Email#3 Sent",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Message ID",
              "displayName": "Message ID",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Replied",
              "displayName": "Replied",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Token",
              "displayName": "Token",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Opted Out",
              "displayName": "Opted Out",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        848,
        400
      ],
      "id": "442aa08e-462d-415a-b880-2f7cb392d82d",
      "name": "Replied = Yes4",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "appendOrUpdate",
        "documentId": {
          "__rl": true,
          "value": "1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk",
          "mode": "list",
          "cachedResultName": "Research",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "LinkedIn URL": "={{ $('Switch1').item.json['LinkedIn URL'] }}",
            "Email#2 Sent": "Yes"
          },
          "matchingColumns": [
            "LinkedIn URL"
          ],
          "schema": [
            {
              "id": "First Name",
              "displayName": "First Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Last Name",
              "displayName": "Last Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email Address",
              "displayName": "Email Address",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Phone Number",
              "displayName": "Phone Number",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Country ",
              "displayName": "Country ",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Location",
              "displayName": "Location",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Industry",
              "displayName": "Industry",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Company Name",
              "displayName": "Company Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Job Title",
              "displayName": "Job Title",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Seniority",
              "displayName": "Seniority",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Website URL",
              "displayName": "Website URL",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "LinkedIn URL",
              "displayName": "LinkedIn URL",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Analysed",
              "displayName": "Analysed",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Research Report",
              "displayName": "Research Report",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#1 Body",
              "displayName": "Email#1 Body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#1 Subject",
              "displayName": "Email#1 Subject",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email #2 Body",
              "displayName": "Email #2 Body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#3 Body",
              "displayName": "Email#3 Body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#3 Subject",
              "displayName": "Email#3 Subject",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Sender Email",
              "displayName": "Sender Email",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Time Zone",
              "displayName": "Time Zone",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#1 Sent",
              "displayName": "Email#1 Sent",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#2 Sent",
              "displayName": "Email#2 Sent",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#3 Sent",
              "displayName": "Email#3 Sent",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Message ID",
              "displayName": "Message ID",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Replied",
              "displayName": "Replied",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Token",
              "displayName": "Token",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Opted Out",
              "displayName": "Opted Out",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        -32,
        80
      ],
      "id": "689a5cdd-1058-4cdd-8ae8-86e683af6fdc",
      "name": "Google Sheets13",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        -304,
        208
      ],
      "id": "cd1abff7-cccf-4447-b665-e6b3da60bafd",
      "name": "Loop Over Items5"
    },
    {
      "parameters": {
        "amount": "={{ Math.floor(Math.random() * (7 - 2 + 1)) + 2 }}\n"
      },
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        1168,
        400
      ],
      "id": "05fffeda-3c0e-4533-8914-ad13d319dc92",
      "name": "Wait5"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "2d1b89f0-661b-4b21-9bb2-cb8419b22035",
              "name": "replied",
              "value": "={{ Object.keys($json).length > 0 ? \"Yes\" : \"No\" }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        128,
        -256
      ],
      "id": "9cdee812-0a38-4102-bb6c-dd89451e97f4",
      "name": "Edit Fields7"
    },
    {
      "parameters": {
        "operation": "appendOrUpdate",
        "documentId": {
          "__rl": true,
          "value": "1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk",
          "mode": "list",
          "cachedResultName": "Research",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "LinkedIn URL": "={{ $('Switch1').item.json['LinkedIn URL'] }}",
            "Email#2 Sent": "Yes"
          },
          "matchingColumns": [
            "LinkedIn URL"
          ],
          "schema": [
            {
              "id": "First Name",
              "displayName": "First Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Last Name",
              "displayName": "Last Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email Address",
              "displayName": "Email Address",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Phone Number",
              "displayName": "Phone Number",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Country ",
              "displayName": "Country ",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Location",
              "displayName": "Location",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Industry",
              "displayName": "Industry",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Company Name",
              "displayName": "Company Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Job Title",
              "displayName": "Job Title",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Seniority",
              "displayName": "Seniority",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Website URL",
              "displayName": "Website URL",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "LinkedIn URL",
              "displayName": "LinkedIn URL",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Analysed",
              "displayName": "Analysed",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Research Report",
              "displayName": "Research Report",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#1 Body",
              "displayName": "Email#1 Body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#1 Subject",
              "displayName": "Email#1 Subject",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email #2 Body",
              "displayName": "Email #2 Body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#3 Body",
              "displayName": "Email#3 Body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#3 Subject",
              "displayName": "Email#3 Subject",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Sender Email",
              "displayName": "Sender Email",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Time Zone",
              "displayName": "Time Zone",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#1 Sent",
              "displayName": "Email#1 Sent",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#2 Sent",
              "displayName": "Email#2 Sent",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#3 Sent",
              "displayName": "Email#3 Sent",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Message ID",
              "displayName": "Message ID",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Replied",
              "displayName": "Replied",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Token",
              "displayName": "Token",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Opted Out",
              "displayName": "Opted Out",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        -128,
        -624
      ],
      "id": "949c861e-b1e3-4c83-a0cd-f83cd8789941",
      "name": "Google Sheets14",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        -400,
        -416
      ],
      "id": "23137839-8180-423b-b2c7-56c30bc120ca",
      "name": "Loop Over Items7"
    },
    {
      "parameters": {
        "amount": "={{ Math.floor(Math.random() * (7 - 2 + 1)) + 2 }}\n"
      },
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        1264,
        -160
      ],
      "id": "f0dfc8cb-9adc-4e48-9e9d-f2ae658b889f",
      "name": "Wait7"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "2d1b89f0-661b-4b21-9bb2-cb8419b22035",
              "name": "replied",
              "value": "={{ Object.keys($json).length > 0 ? \"Yes\" : \"No\" }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        176,
        1024
      ],
      "id": "4afda699-8c1f-448a-a146-b513650014d3",
      "name": "Edit Fields8"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "177601be-b2c3-45cc-8e15-cd064fbaf578",
              "leftValue": "={{ $json.replied }}",
              "rightValue": "Yes",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        560,
        896
      ],
      "id": "feff830f-6053-4569-9aae-7f90351f3334",
      "name": "If5"
    },
    {
      "parameters": {
        "mode": "combine",
        "combineBy": "combineByPosition",
        "options": {}
      },
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3.1,
      "position": [
        336,
        896
      ],
      "id": "fc6653c7-ed32-47d5-a1b0-9c8fd8a736c5",
      "name": "Merge5"
    },
    {
      "parameters": {
        "operation": "getAll",
        "limit": 3,
        "filters": {
          "sender": "={{ $json['Email Address'] }}"
        }
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        -32,
        1024
      ],
      "id": "5e3c318c-7651-41b4-b3e5-88d52381ce8e",
      "name": "Replied?5",
      "alwaysOutputData": true,
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "appendOrUpdate",
        "documentId": {
          "__rl": true,
          "value": "1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk",
          "mode": "list",
          "cachedResultName": "Research",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "LinkedIn URL": "={{ $json[\"LinkedIn URL\"] }}",
            "Replied": "Yes"
          },
          "matchingColumns": [
            "LinkedIn URL"
          ],
          "schema": [
            {
              "id": "First Name",
              "displayName": "First Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Last Name",
              "displayName": "Last Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email Address",
              "displayName": "Email Address",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Phone Number",
              "displayName": "Phone Number",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Country ",
              "displayName": "Country ",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Location",
              "displayName": "Location",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Industry",
              "displayName": "Industry",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Company Name",
              "displayName": "Company Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Job Title",
              "displayName": "Job Title",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Seniority",
              "displayName": "Seniority",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Website URL",
              "displayName": "Website URL",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "LinkedIn URL",
              "displayName": "LinkedIn URL",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Analysed",
              "displayName": "Analysed",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Research Report",
              "displayName": "Research Report",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#1 Body",
              "displayName": "Email#1 Body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#1 Subject",
              "displayName": "Email#1 Subject",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email #2 Body",
              "displayName": "Email #2 Body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#3 Body",
              "displayName": "Email#3 Body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#3 Subject",
              "displayName": "Email#3 Subject",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Sender Email",
              "displayName": "Sender Email",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Time Zone",
              "displayName": "Time Zone",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#1 Sent",
              "displayName": "Email#1 Sent",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#2 Sent",
              "displayName": "Email#2 Sent",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#3 Sent",
              "displayName": "Email#3 Sent",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Message ID",
              "displayName": "Message ID",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Replied",
              "displayName": "Replied",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Token",
              "displayName": "Token",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Opted Out",
              "displayName": "Opted Out",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        720,
        1088
      ],
      "id": "76899396-dc8a-46ab-8d51-178ac9ffddfb",
      "name": "Replied = Yes5",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        -352,
        864
      ],
      "id": "0a7f7547-f253-474a-ba51-11ea5ce63ebc",
      "name": "Loop Over Items8"
    },
    {
      "parameters": {
        "amount": "={{ Math.floor(Math.random() * (7 - 2 + 1)) + 2 }}\n"
      },
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        1120,
        1088
      ],
      "id": "6f483cb6-18c8-41db-8e09-72406485f2b2",
      "name": "Wait8"
    },
    {
      "parameters": {
        "sendTo": "kiaghasem.dev@gmail.com",
        "subject": "={{ $json[\"Email#3 Subject\"] }}",
        "message": "={{ $json['Email#3 Body'] }}<br><br>\n<a href=\"https://kiaghasem.app.n8n.cloud/webhook/unsubscribe?tkn={{ $json.Token }}\">Click Here to Unsubscribe</a>",
        "options": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        800,
        912
      ],
      "id": "ee0536cf-fdab-437d-9d09-c7be29d4eb5f",
      "name": "Gmail5",
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api-f1db6c.stack.tryrelevance.com/latest/studios/a68f4a21-2330-496d-ad76-42b5a712f357/trigger_webhook?project=4f639ecd3fda-432b-a293-0115f9a16558",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "4f639ecd3fda-432b-a293-0115f9a16558:<redacted-credential>"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n\"linkedin_url\":\"{{ $json[\"LinkedIn URL\"] }}\",\n\"last_x_days\":30\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -3664,
        -2224
      ],
      "id": "411afff6-0e92-4cfa-84e3-f097e3891561",
      "name": "Scrape Profiles + Posts - Relevance AI1",
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.perplexity.ai/chat/completions",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"model\": \"sonar\",\n  \"messages\": [\n    {\n      \"role\": \"system\",\n      \"content\": \"You are a researcher in a business development team. Your job is to find as much research as you can about a prospect company. You must ensure your research is for the correct company and is highly accurate. Your research must always include what the prospect company does in detail. Your research should also highlight any recent news or accomplishments from the company.\"\n    },\n    {\n      \"role\": \"user\",\n      \"content\": \"Find as much info as you can about {{ $('Scrape Profiles + Posts - Relevance AI1').last().json.linkedin_profile_details_data.company }} }} This is their website URL: {{ $('Scrape Profiles + Posts - Relevance AI1').last().json.linkedin_profile_details_data.company_website }}. Make sure your research is 100% related to them.\"\n    }\n  ]\n}\n",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -3360,
        -2224
      ],
      "id": "50f92cbd-62ed-4f7b-b532-352438122578",
      "name": "Research Company - Perplexity1",
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "value": "gpt-4.1-mini",
          "mode": "list",
          "cachedResultName": "GPT-4.1-MINI"
        },
        "messages": {
          "values": [
            {
              "content": "=# Overview\nYou are part of the cold email team at Rapple Media, which is an AI Automation & marketing Agency. \n\nRapple Media offers the following services: \n- Business Automation: Automating internal business processes to save time, money or reduce error. \n- Marketing Solutions: Building marketing solutions like funnels, Developing landing pages, etc to generate leads with minimal investment of time or money. \n- Automation Consulting: Advice on automating various processes. \n\n# Task\nYour job is to analyse the research found on a prospect, in preparation for a cold email. \nFor each prospect you must find the following: \n\n*1. Personalization opportunity:* Cold emails perform much better when personalized. You must analyse the research found on the prospect to identify the top personalization opportunities. The personalization can be one of the following: \n- Referencing content they\u2019ve posted [best one].\n- Mentioning a specific achievement or news related to themselves or their business.\n- personalized compliment or observation about the recipient\u2019s work.\n- Mentioning unique aspects of their professional background. \nThe references must be highly specific that couldn't be mass-generated. Adding each reference to the cold email should feel like a 1 to 1 communication, showing we've done our research on the prospect. Aim: Reader thinks \u201cWhoa, this is for me.\u201d If you can't find any good personalization opportunities, then leave this blank. \n\n\n*2. Pain points and solutions:* Analyse the research to identify the prospects biggest pain points. Take into consideration their role, their company details and all other research to predict what their biggest bottle necks are. Then think of these pain points in terms of Kamexa's services - Which ones can we solve? List the 2 biggest pain points that we can help with and define the actionable solution we can offer them. Turn the actionable solution into a clear and concise offer. \n- The solutions should be specific offerings, not broad services. So instead of saying \"automation\", you must clearly define exactly what process will be automated.\n\n\n# Output Format \nYour output must be in the following format: \n\n*Personalization*\n1. Opportunity: HERE\nSupporting Evidence: HERE\n\n2. Opportunity: HERE\nSupporting Evidence: HERE\n\n(\u2026add more as needed)\n\n\u2e3b\n\n*Pain Points & Solutions*\n1. Pain Point: HERE\nSupporting Evidence: HERE\nOffer: HERE\n\n2. Pain Point: HERE\nSupporting Evidence: HERE\nOffer: HERE\n\nWhere supporting evidence is where you must include specific examples and evidence from the research that support your findings. You must give enough detail in the HERE sections so the reader does not need to revisit the research to create a cold email.\nThe opportunities should also be explained in detail, so the reader has enough context to understand the opportunity. So for example, instead of saying \"news A\", you must explain exactly what \"news A\" entitles and why it's significant. \n\n- Don't output anything else.\n- Replace HERE with the relevant string.\n- If there are no clear personalization opportunities, then replace HERE with null. \n- Make sure your outputs are well thought out. \n\n# Complete the analysis for the following prospect. \n\nResearch: \n\n1. Scraped LinkedIn profile in JSON format: \n{{ $('Scrape Profiles + Posts - Relevance AI1').item.json.linkedin_profile_details_data.toJsonString() }}\n\n2. Company research from searching the web: \n{{ $json.choices[0].message.content }}"
            }
          ]
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        -3088,
        -2224
      ],
      "id": "479c325f-e02b-465f-afba-be6ab78cd952",
      "name": "Analyse",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "value": "anthropic/claude-3.7-sonnet",
          "mode": "list",
          "cachedResultName": "ANTHROPIC/CLAUDE-3.7-SONNET"
        },
        "messages": {
          "values": [
            {
              "content": "=You are part of the cold email team for Rapple Media, which is an AI Automation Agency offering process automation, marketing automation and automation consulting to businesses around the world. \n\nYour job is to create 3 emails given the following info about a new cold lead: \n\n1. Research: Findings about the prospect by researching them on social media and the web. \n2. Analysis: Insights extracted from analysing the research. \n3. Tactic: Strategy to create the cold emails. \n\nYour job is to create a cold email sequence of 3 emails which will be sent 2 days apart. The tactic for each email should closely follow the instructions below, whilst the content of each email must follow the research and analysis. \n\n\n# Tactic: \n\n1. Email#1: \n\n1.1 Subject line: \n\nThe email subject line should : \n- Be maximum 4 words \n- Include the prospects name or company name (choose based on context) when possible without sounding unnatural \n- Never include spam trigger words like \u201cfree,\u201d \u201cguarantee,\u201d \u201cno obligation,\u201d \"price,\" \"100%\" \"sale,\" and excessive punctuation, which can trigger spam filters. \n- Create curiousity without sounding spammy or like we're selling them anything \n\n\n1.2 Body\n\nStructure: The email must follow this structure closely:\na) Hook: The first 2 or 3 sentences of the email is a hook. The hook should be the personalization part of the email, capturing the prospects attention so they don't scroll. \nb) Pain point: After the hook, you must outline a pain point that was analysed about the prospect. This shouldn't sound salesy, but should be directly related to their business. The goal is to capture the readers attention, not sell them a solution. \nc) CTA: Say you've been working on solving that problem and would love to share your insights over a quick 15 minute call on {{ ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'][(new Date().getDay() + 2) % 7] }}. Have a clear next step for them (for example \"Should I book you in?).\n\nGuidelines -  The email body should:\n\n- Be short (maximum 100 words).\n- Have short paragraphs (1 or 2 sentences in each) to include white space. \n- Use a conversational tone to keep the email casual. \n- Be \"You\" focused, incorporating \"you\" as much as possible.\n- Be in 6th-grade reading level with simple language. \n- Avoid images, attachments, videos, custom code, spammy words above, bullet points, punctuation.\n- Not have absurd claims (it should be believable).\n- Should always start with \"Hey {{ $('Limit1').item.json['First Name'] }} ,\"\n- Should be concise. \n- Never start with formal openers like \"Hope you're doing well\" (Get right into the email every time).\n- Be nice and inviting.\n- End with \"Kind regards, Rapple Media\"\n\n2. Email#3: \n\nThis email should follow the same structure and guidelines and Email#1, with the following differences: \n- It should mention a different pain point identified. \n- The call to action should include the following calender link so the prospect can book a time that suits: https://cal.com/ankitrai/30min\n- Should be like you already know them from the previous conversation, so it shouldn't include any personalisation other than the prospects name. Can start with a variation of I was thinking about {Prospect Company Name} again and...\n\n\n3. Email#2: \nThis email will be in the same thread as email#1 and is considered a followup email (so it doesn't need a subject line).\nThe email should be a close variant of this email: \n\"Hey {{ $('Scrape Profiles + Posts - Relevance AI1').item.json.linkedin_profile_details_data.first_name }}, \nJust pushing this back up your inbox incased you missed it. \nLook forward to hearing from you. \nKind regards, \nRapple Media\" \n\n# Rules - Other things to consider: \n- Your goal is to create an engaging email that will get us a reply. Choose the best pain points and personalization opportunities from the analysis to achieve this objective. \n- You must closely follow the guidelines provided for each email. \n- Never come across condescending or rude when mentioning the pain point. \n- When using the personalization opportunities from the analysis, always mention where the info was found - usually  \"Online\" or \"LinkedIn\" (look at Supporting Evidence for this).\n\n# Output format\nYour output must follow this JSON format: \n\n{\n  \"email1\": {\n    \"subject\": \"TEXT-HERE\",\n    \"body\": \"HTML-HERE\"\n  },\n  \"email2\": {\n    \"body\": \"HTML-HERE\"\n  },\n  \"email3\": {\n    \"subject\": \"HERE\",\n    \"body\": \"HTML-HERE\"\n  }\n}\n\n- Don't wrap the output in ```json```. \n- Don't output anything else. \n- Keep the HTML code to a minimum by using only <br> for line breaks and nothing else.\n\n# Task: New prospect\nThere's a new prospect. Create the emails by considering the following details: \n\n1. Research: \nFirst name: {{ $('Limit1').item.json['First Name'] }} \nCompany name: {{ $('Scrape Profiles + Posts - Relevance AI1').item.json.linkedin_profile_details_data.company }} (ignore any legal suffixes like pty, ltd or llc) \n\n2. Analysis: \n{{ $json.message.content }} \n"
            }
          ]
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        -3520,
        -1968
      ],
      "id": "7f27a22b-92bc-4cb4-933a-6291473a9355",
      "name": "Email #1 #2 #3",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "mode": "raw",
        "jsonOutput": "=  {{ $json.message.content.replaceAll('```json','').replaceAll('```','') }}",
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -3120,
        -1968
      ],
      "id": "734c955c-1a56-4a59-87fe-03979a645740",
      "name": "Emails",
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "jsCode": "// Loop over each item passed from the Merge node\nfor (const item of items) {\n\t// Get the country value (make sure to match the field name exactly)\n\tconst countryRaw = item.json[\"Country \"];\n\tlet country = \"\";\n\tif (countryRaw) {\n\t\tcountry = countryRaw.toLowerCase().trim();\n\t}\n\n\t// Define arrays for the different time zone groups\n\tconst t1Countries = [\"usa\", \"united states\", \"canada\"];\n\tconst europeanCountries = [\n\t\t\"albania\", \"andorra\", \"armenia\", \"austria\", \"azerbaijan\", \"belarus\", \"belgium\",\n\t\t\"bosnia and herzegovina\", \"bulgaria\", \"croatia\", \"cyprus\", \"czech republic\", \"czechia\",\n\t\t\"denmark\", \"estonia\", \"finland\", \"france\", \"georgia\", \"germany\", \"greece\", \"hungary\",\n\t\t\"iceland\", \"ireland\", \"italy\", \"kosovo\", \"latvia\", \"liechtenstein\", \"lithuania\",\n\t\t\"luxembourg\", \"malta\", \"moldova\", \"monaco\", \"montenegro\", \"netherlands\", \"north macedonia\",\n\t\t\"norway\", \"poland\", \"portugal\", \"romania\", \"russia\", \"san marino\", \"serbia\", \"slovakia\",\n\t\t\"slovenia\", \"spain\", \"sweden\", \"switzerland\", \"turkey\", \"ukraine\", \"united kingdom\",\n\t\t\"vatican city\"\n\t];\n\tconst t3Countries = [\"australia\", \"new zealand\"];\n\n\t// Determine and populate the Time Zone based on the country value\n\tif (t1Countries.includes(country)) {\n\t\titem.json[\"Time Zone\"] = \"T1\";\n\t} else if (europeanCountries.includes(country)) {\n\t\titem.json[\"Time Zone\"] = \"T2\";\n\t} else if (t3Countries.includes(country)) {\n\t\titem.json[\"Time Zone\"] = \"T3\";\n\t} else {\n\t\t// For any other country not defined above, assign T4.\n\t\t// If you want to limit to T1, T2, or T3 only, you can decide to leave it blank or assign a default value.\n\t\titem.json[\"Time Zone\"] = \"T4\";\n\t}\n}\n\nreturn items;"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -3440,
        -1680
      ],
      "id": "2d98fc48-b15c-4b0c-9974-ee22d5e9456b",
      "name": "Time Zone"
    },
    {
      "parameters": {
        "jsCode": "// Array of sender emails to rotate through\nconst senderEmails = [\n  \"kiaghasem.dev@gmail.com\",\n  \"kia@kamexa.ai\",\n  \"youremail@gmail.com\"\n];\n\n// Get all input items from the Time Zone node\nconst items = $input.all();\n\n// Process each item\nfor (let i = 0; i < items.length; i++) {\n  // Calculate which email to use based on position (cycling through the array)\n  const emailIndex = i % senderEmails.length;\n  \n  // Assign the sender email to the current item\n  items[i].json[\"Sender Email\"] = senderEmails[emailIndex];\n}\n\n// Return the updated items\nreturn items;"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -3264,
        -1680
      ],
      "id": "5fc17555-7dc9-41bb-b676-8478798f982d",
      "name": "Sender Email"
    },
    {
      "parameters": {
        "jsCode": "// Function to generate a random 6-digit number\nfunction generateRandomToken() {\n  return Math.floor(100000 + Math.random() * 900000);\n}\n\n// Process each item from the Sender Email node\nfor (let i = 0; i < items.length; i++) {\n  // Add the token parameter to each item\n  items[i].json.token = generateRandomToken();\n}\n\n// Return the modified items\nreturn items;"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -3072,
        -1680
      ],
      "id": "0c8bebfe-65a2-4e3e-aacc-cea993266012",
      "name": "Opt Out Token"
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 23 * * SUN"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        -4208,
        -2032
      ],
      "id": "0228513c-43a9-43fe-8a80-4866b0c3ed16",
      "name": "Schedule Trigger3"
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "value": "1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk",
          "mode": "list",
          "cachedResultName": "Research",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk/edit#gid=0"
        },
        "filtersUI": {
          "values": [
            {
              "lookupColumn": "Analysed",
              "lookupValue": "No"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        -4000,
        -2032
      ],
      "id": "d1437bbe-6b76-44e2-bea1-8915b8265812",
      "name": "Google Sheets15",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "maxItems": 3
      },
      "type": "n8n-nodes-base.limit",
      "typeVersion": 1,
      "position": [
        -3984,
        -1808
      ],
      "id": "3006956d-3227-48f6-a852-d337b9fc613a",
      "name": "Limit1"
    },
    {
      "parameters": {
        "mode": "combine",
        "combineBy": "combineByPosition",
        "options": {}
      },
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3.1,
      "position": [
        -3632,
        -1680
      ],
      "id": "b3735f5d-9f25-4381-b6bf-19de80bc2df2",
      "name": "Merge6"
    },
    {
      "parameters": {
        "operation": "appendOrUpdate",
        "documentId": {
          "__rl": true,
          "value": "1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk",
          "mode": "list",
          "cachedResultName": "Research",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1pY5nJihyUUObA1LpbhdgANq0DSX7A9TLOTWlEr9PMBk/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "LinkedIn URL": "={{ $json[\"LinkedIn URL\"] }}",
            "Research Report": "={{ $('Analyse').item.json.message.content.replaceAll('\\n','<br>') }}",
            "Email#1 Body": "={{ $json.email1.body.replaceAll('\\n','<br>') }}",
            "Email#1 Subject": "={{ $json.email1.subject }}",
            "Email #2 Body": "={{ $json.email2.body.replaceAll('\\n','<br>') }}",
            "Email#3 Body": "={{ $json.email3.body.replaceAll('\\n','<br>') }}",
            "Email#3 Subject": "={{ $json.email3.subject }}",
            "Sender Email": "={{ $json['Sender Email'] }}",
            "Time Zone": "={{ $json['Time Zone'] }}",
            "Replied": "No",
            "Opted Out": "No",
            "Analysed": "Yes",
            "Email#1 Sent": "No",
            "Email#2 Sent": "No",
            "Email#3 Sent": "No",
            "Token": "={{ $json.token }}"
          },
          "matchingColumns": [
            "LinkedIn URL"
          ],
          "schema": [
            {
              "id": "First Name",
              "displayName": "First Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Last Name",
              "displayName": "Last Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email Address",
              "displayName": "Email Address",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Phone Number",
              "displayName": "Phone Number",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Country ",
              "displayName": "Country ",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Location",
              "displayName": "Location",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Industry",
              "displayName": "Industry",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Company Name",
              "displayName": "Company Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Job Title",
              "displayName": "Job Title",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Seniority",
              "displayName": "Seniority",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Website URL",
              "displayName": "Website URL",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "LinkedIn URL",
              "displayName": "LinkedIn URL",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Analysed",
              "displayName": "Analysed",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Research Report",
              "displayName": "Research Report",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#1 Body",
              "displayName": "Email#1 Body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#1 Subject",
              "displayName": "Email#1 Subject",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email #2 Body",
              "displayName": "Email #2 Body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#3 Body",
              "displayName": "Email#3 Body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#3 Subject",
              "displayName": "Email#3 Subject",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Sender Email",
              "displayName": "Sender Email",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Time Zone",
              "displayName": "Time Zone",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email#1 Sent",
              "displayName": "Email#1 Sent",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Email#2 Sent",
              "displayName": "Email#2 Sent",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Email#3 Sent",
              "displayName": "Email#3 Sent",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Message ID",
              "displayName": "Message ID",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Replied",
              "displayName": "Replied",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Token",
              "displayName": "Token",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Opted Out",
              "displayName": "Opted Out",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        -2912,
        -1680
      ],
      "id": "ae40eacc-79b0-47d9-80ad-3693057db8b8",
      "name": "Google Sheets16",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "content": "# Research Agent #",
        "height": 784,
        "width": 1600,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -4240,
        -2272
      ],
      "id": "e354c26f-bc19-4ea6-a68f-8e226745742b",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "content": "# Agent 1 #",
        "height": 1296,
        "width": 3184,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -1584,
        -2048
      ],
      "id": "27da3ac5-bbea-42fb-a5de-d12995d402f9",
      "name": "Sticky Note1"
    },
    {
      "parameters": {
        "content": "# Agent 2 #",
        "height": 2048,
        "width": 3184,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -4960,
        -720
      ],
      "id": "04a4b440-7c8a-4634-ba04-37f2fc8a6966",
      "name": "Sticky Note2"
    },
    {
      "parameters": {
        "content": "# Agent 3 #",
        "height": 2048,
        "width": 3184,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -1536,
        -688
      ],
      "id": "b9f6338c-523e-424c-a07a-ba06f178a50d",
      "name": "Sticky Note3"
    },
    {
      "parameters": {
        "content": "# Unsubscribe #",
        "height": 368,
        "width": 1072,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -4016,
        -1280
      ],
      "id": "5aeaea00-62be-4db5-b744-f72987672f9e",
      "name": "Sticky Note4"
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Edit Fields2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields2": {
      "main": [
        [
          {
            "node": "Google Sheets2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets2": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Google Sheets3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Loop Over Items1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Loop Over Items2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [
          {
            "node": "Google Sheets4",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Gmail",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail3": {
      "main": [
        [
          {
            "node": "Wait1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items1": {
      "main": [
        [
          {
            "node": "Google Sheets6",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Gmail3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait1": {
      "main": [
        [
          {
            "node": "Loop Over Items1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail4": {
      "main": [
        [
          {
            "node": "Wait2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items2": {
      "main": [
        [
          {
            "node": "Google Sheets7",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Gmail4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait2": {
      "main": [
        [
          {
            "node": "Loop Over Items2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets3": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch1": {
      "main": [
        [
          {
            "node": "Loop Over Items4",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Loop Over Items3",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Loop Over Items6",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If1": {
      "main": [
        [
          {
            "node": "Replied = Yes1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Code3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge1": {
      "main": [
        [
          {
            "node": "If1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Replied?1": {
      "main": [
        [
          {
            "node": "Edit Fields4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Replied = Yes1": {
      "main": [
        [
          {
            "node": "Loop Over Items3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items3": {
      "main": [
        [
          {
            "node": "Google Sheets9",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Replied?1",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait3": {
      "main": [
        [
          {
            "node": "Loop Over Items3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request3": {
      "main": [
        [
          {
            "node": "Wait3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code3": {
      "main": [
        [
          {
            "node": "HTTP Request3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If2": {
      "main": [
        [
          {
            "node": "Replied = Yes2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Code4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge2": {
      "main": [
        [
          {
            "node": "If2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Replied?2": {
      "main": [
        [
          {
            "node": "Edit Fields5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Replied = Yes2": {
      "main": [
        [
          {
            "node": "Loop Over Items4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items4": {
      "main": [
        [
          {
            "node": "Google Sheets10",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Replied?2",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait4": {
      "main": [
        [
          {
            "node": "Loop Over Items4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request4": {
      "main": [
        [
          {
            "node": "Wait4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code4": {
      "main": [
        [
          {
            "node": "HTTP Request4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields3": {
      "main": [
        [
          {
            "node": "Merge3",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "If3": {
      "main": [
        [
          {
            "node": "Replied = Yes3",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Code6",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge3": {
      "main": [
        [
          {
            "node": "If3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Replied?3": {
      "main": [
        [
          {
            "node": "Edit Fields3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Replied = Yes3": {
      "main": [
        [
          {
            "node": "Loop Over Items6",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items6": {
      "main": [
        [
          {
            "node": "Google Sheets12",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Replied?3",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait6": {
      "main": [
        [
          {
            "node": "Loop Over Items6",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request6": {
      "main": [
        [
          {
            "node": "Wait6",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code6": {
      "main": [
        [
          {
            "node": "HTTP Request6",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger1": {
      "main": [
        [
          {
            "node": "Google Sheets5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets5": {
      "main": [
        [
          {
            "node": "Switch1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields4": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Edit Fields5": {
      "main": [
        [
          {
            "node": "Merge2",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Gmail1": {
      "main": [
        [
          {
            "node": "Wait5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If": {
      "main": [
        [
          {
            "node": "Replied = Yes",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Gmail2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Replied?": {
      "main": [
        [
          {
            "node": "Edit Fields7",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Replied = Yes": {
      "main": [
        [
          {
            "node": "Loop Over Items7",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail2": {
      "main": [
        [
          {
            "node": "Wait7",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger2": {
      "main": [
        [
          {
            "node": "Google Sheets8",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets8": {
      "main": [
        [
          {
            "node": "Switch2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch2": {
      "main": [
        [
          {
            "node": "Loop Over Items7",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Loop Over Items5",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Loop Over Items8",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields6": {
      "main": [
        [
          {
            "node": "Merge4",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "If4": {
      "main": [
        [
          {
            "node": "Replied = Yes4",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Gmail1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge4": {
      "main": [
        [
          {
            "node": "If4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Replied?4": {
      "main": [
        [
          {
            "node": "Edit Fields6",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Replied = Yes4": {
      "main": [
        [
          {
            "node": "Loop Over Items5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items5": {
      "main": [
        [
          {
            "node": "Google Sheets13",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Replied?4",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait5": {
      "main": [
        [
          {
            "node": "Loop Over Items5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields7": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Loop Over Items7": {
      "main": [
        [
          {
            "node": "Google Sheets14",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Replied?",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait7": {
      "main": [
        [
          {
            "node": "Loop Over Items7",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields8": {
      "main": [
        [
          {
            "node": "Merge5",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "If5": {
      "main": [
        [
          {
            "node": "Replied = Yes5",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Gmail5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge5": {
      "main": [
        [
          {
            "node": "If5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Replied?5": {
      "main": [
        [
          {
            "node": "Edit Fields8",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Replied = Yes5": {
      "main": [
        [
          {
            "node": "Loop Over Items8",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items8": {
      "main": [
        [
          {
            "node": "Google Sheets11",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Replied?5",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait8": {
      "main": [
        [
          {
            "node": "Loop Over Items8",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail5": {
      "main": [
        [
          {
            "node": "Wait8",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Scrape Profiles + Posts - Relevance AI1": {
      "main": [
        [
          {
            "node": "Research Company - Perplexity1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Research Company - Perplexity1": {
      "main": [
        [
          {
            "node": "Analyse",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Analyse": {
      "main": [
        [
          {
            "node": "Email #1 #2 #3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Email #1 #2 #3": {
      "main": [
        [
          {
            "node": "Emails",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Emails": {
      "main": [
        [
          {
            "node": "Merge6",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Time Zone": {
      "main": [
        [
          {
            "node": "Sender Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Sender Email": {
      "main": [
        [
          {
            "node": "Opt Out Token",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Opt Out Token": {
      "main": [
        [
          {
            "node": "Google Sheets16",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger3": {
      "main": [
        [
          {
            "node": "Google Sheets15",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets15": {
      "main": [
        [
          {
            "node": "Limit1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Limit1": {
      "main": [
        [
          {
            "node": "Scrape Profiles + Posts - Relevance AI1",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge6",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Merge6": {
      "main": [
        [
          {
            "node": "Time Zone",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "ffb7593a-70a0-4264-8a1f-d73a9b4c035f",
  "id": "RZONtli7DKmTSeNw",
  "tags": []
}