{
  "id": "tmNVvOTytBLe0IsO",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Extract Leads and add to instantly",
  "tags": [],
  "nodes": [
    {
      "id": "9854b4a2-8cc6-4a21-a505-27f6e07a0dd7",
      "name": "Get row(s) in sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -1312,
        48
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 621890324,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1T_Z8UFrgBf4DPw41pt7S_XoQ87cv8Ko7Hs8PZHC1f-w/edit#gid=621890324",
          "cachedResultName": "Sheet3"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1T_Z8UFrgBf4DPw41pt7S_XoQ87cv8Ko7Hs8PZHC1f-w",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1T_Z8UFrgBf4DPw41pt7S_XoQ87cv8Ko7Hs8PZHC1f-w/edit?usp=drivesdk",
          "cachedResultName": "Law Firm (Owner:Partner) scrapes Full"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "16f4af89-d852-4a41-a889-d4e95851615a",
      "name": "Append or update row in sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -752,
        32
      ],
      "parameters": {
        "columns": {
          "value": {
            "email": "={{ $json.email }}",
            "summary": "={{ $json.summary }}",
            "lastName": "={{ $json.lastName }}",
            "firstName": "={{ $json.firstName }}"
          },
          "schema": [
            {
              "id": "firstName",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "firstName",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "lastName",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "lastName",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "summary",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "summary",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "company",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "company",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "jobTitle",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "jobTitle",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "email",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "jobDescription",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "jobDescription",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "corporateLinkedinUrl",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "corporateLinkedinUrl",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "autoMapInputData",
          "matchingColumns": [
            "firstName"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1305071092,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1T_Z8UFrgBf4DPw41pt7S_XoQ87cv8Ko7Hs8PZHC1f-w/edit#gid=1305071092",
          "cachedResultName": "Law firm test sheet"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1T_Z8UFrgBf4DPw41pt7S_XoQ87cv8Ko7Hs8PZHC1f-w",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1T_Z8UFrgBf4DPw41pt7S_XoQ87cv8Ko7Hs8PZHC1f-w/edit?usp=drivesdk",
          "cachedResultName": "Law Firm (Owner:Partner) scrapes Full"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "1c1fd3d4-5b40-4f8c-9ed3-8edef97809ea",
      "name": "Notify Master",
      "type": "n8n-nodes-base.telegram",
      "position": [
        0,
        -96
      ],
      "parameters": {
        "text": "=Hello Master,\nYour n8n Instantly add leads From EMAIL SCRAPE Workflow is completed.",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "ba5af28a-b788-46e1-a281-408558906ed2",
      "name": "Limit",
      "type": "n8n-nodes-base.limit",
      "position": [
        -192,
        -96
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "19a2fc1a-56db-419c-ada1-7b4f497fc0d6",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -480,
        16
      ],
      "parameters": {
        "options": {
          "reset": false
        }
      },
      "typeVersion": 3
    },
    {
      "id": "116da4da-359e-48b9-b8c1-011ed86e0c15",
      "name": "IBC V3",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        144,
        192
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "chatgpt-4o-latest",
          "cachedResultName": "CHATGPT-4O-LATEST"
        },
        "options": {
          "topP": 1,
          "maxTokens": 248,
          "temperature": 1
        },
        "messages": {
          "values": [
            {
              "content": "={\n\n\"firstName\" : {{ $json.message.content.firstName }} ,\n\"lastName\" : {{ $json.message.content.lastName }} ,\n\"companyName\" : {{ $('Append or update row in sheet').item.json.company }} ,\n\"jobTitle\" : {{ $('Append or update row in sheet').item.json.jobTitle }} ,\n\"summary\" : {{ $('Append or update row in sheet').item.json.summary }}\n}"
            },
            {
              "content": "=Task\n\nCreate one unique, engaging sentence using the provided variables: firstName, lastName, summary, company, and jobTitle.\n\nSpecifics\n\nFocus on one specific achievement, interest, or detail mentioned in the summary.\n\nTone: confident, natural, and casual \u2014 not robotic or overly formal.\n\nUse the company name only if it fits naturally; avoid forced mentions.\n\nKeep the icebreaker one sentence maximum (compound is allowed, but no separate sentences).\n\nEnd with a variation of:\n\n\u201cso I figured I\u2019d reach out\u201d\n\n\u201cso I thought I\u2019d reach out\u201d\n\n\u201cso I wanted to reach out\u201d\n\nDo not use em dashes or endash (\u2014); use commas or periods instead.\n\nNotes\n\nThe icebreaker should feel like it was written by someone genuinely interested in the recipient\u2019s work.\n\nAvoid generic compliments (e.g., \u201cgreat background,\u201d \u201cimpressive experience\u201d).\n\nMake sure it connects to something specific in the summary (achievement, project, passion).\n\nRelate back to the sender\u2019s personal interest if possible.\n\nOutput must be valid JSON only, with all line breaks as \\\\n.\n\nDo not include the word \u201cJSON\u201d in the output.\n\nExample:\n{\n  \"firstName\": \"Rob\",\n  \"lastName\": \"Nelson\",\n  \"company\": \"Rob Nelson Connections LLC\",\n  \"jobTitle\": \"Co-Founder\",\n  \"summary\": \"Our team helped 14 brands win Vendor Agreements at AutoZone. They now have 6,900 stores and 112,000 employees. ... I love mentoring and helping others succeed.\"\n}\n\nExample output\n{\n  \"icebreaker\":\"Hey Rob,\\\\n\\\\nSeriously impressed by how you helped 14 brands win AutoZone vendor agreements, it\u2019s clear you know how to open doors in tough industries so I figured I\u2019d reach out.\"\n}\n\nAnother example:\n{ \"firstName\": \"Scott\",\n  \"lastName\" : \"Montgomery\"\n\"companyName\": \"CrankTank\", \n\"title\": \"CEO, Founder\", \n\"summary\": \"I have extensive experience in the outdoor, bike, and wintersports industries. We interact with the CEO/CMO on a host of issues including strategy, marketing with an emphasis on the migration to digital capabilities, sales, and in some cases succession planning. In late 2018, as CEO of Reynolds Cycling, we sold to Hayes Performance, a global leader in the manufacturing and production of bicycle components and other products. } what you will \n\noutput -> { \"icebreaker\":\"Hey Jeff,\\\\n\\\\nImpressed by how well the business building in your career has been, with all the startups under your belt very impressed! As someone who also enjoys the freedom of ebikes and where they can take you, I figured I'd connect.\" }"
            }
          ]
        },
        "jsonOutput": true
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "1173cb3a-4df7-49e5-9dc4-65569ded0472",
      "name": "Add leads to instantly",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueErrorOutput",
      "position": [
        608,
        192
      ],
      "parameters": {
        "url": "https://api.instantly.ai/api/v2/leads",
        "body": "={\n    \"campaign\": \"[YOUR INSTANTLY CAMPAIGN ID HERE]\",\n    \"email\": \"{{ $('Append or update row in sheet').item.json.email }}\",\n    \"first_name\": \"{{ $('Format Names').item.json.message.content.firstName }}\",\n    \"last_name\": \"{{ $('Format Names').item.json.message.content.lastName }}\",\n    \"company_name\": \"{{ $('Append or update row in sheet').item.json.company }}\",\n\n\"skip_if_in_workspace\": true,\n\"skip_if_in_campaign\": true,\n\"skip_if_in_list\": true,\n\"verify_leads_for_lead_finder\": true,\n\"verify_leads_on_import\": true,\n\"custom_variables\": {\n      \"icebreaker\": \"{{ $json.message.content.icebreaker }}\"\n    }\n}",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "raw",
        "sendHeaders": true,
        "rawContentType": "application/json",
        "headerParameters": {
          "parameters": [
            {}
          ]
        }
      },
      "notesInFlow": false,
      "typeVersion": 4.2,
      "alwaysOutputData": true
    },
    {
      "id": "584f8685-eda7-497d-b461-2f8983401d0f",
      "name": "Format Names",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        -192,
        192
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini",
          "cachedResultName": "GPT-4O-MINI"
        },
        "options": {
          "maxTokens": 128
        },
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "=Chat gpt Model will format names by stripping out unnescessary symbols titles extra period and dashes and punctuation while preserving the core name structure. Model will keep multi part sur names and accented /non latin  characters intact. The output should be a clean, plain english version of the name with the following rules and return firstName and lastName in new variables in JSON Format only:\n\nremove all symbols and emojies(e.g., \"-\" \".\" \"\ud83d\udcc9\" \"\ud83d\ude0e\"). \n\nStrip out professional titles \nExamples:(\"founder\" \"MSc\" \"interim cmo\".) \nRemove punctuation after initials \nExamples:(\"carl W.\" becomes \"carl W\".) \nPreserve multi-part or hyphenated surnames \nExamples: (\"Jean-Paul Sartre\" remains \"Jean-Paul Sartre\"). \n\nMaintain accented or non latin characters (e.g., \"major\u00e1n\"). \nExamples: (\"Kitti Major\u00e1n ,MSc\" to \"Kitti Major\u00e1n\" \"Zennor Robinson \ud83c\udf39\" will chance to \"Zennor Roinson\" \"Johnny j Pawlik - Founder,Conference Speaker,Interim CMO \ud83d\udcc9\" change into \"Johnny Pawlik\" \"Carl W.\" to \"Carl W\")\n\n"
            }
          ]
        },
        "jsonOutput": true
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "8f6afa72-e7d8-4570-98b4-b1d8622a5bf6",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1360,
        -176
      ],
      "parameters": {
        "color": 4,
        "width": 464,
        "height": 368,
        "content": "## Read Sheets and Filter Variables\n\nThis workflow begins with a Google Sheets file that contains your scraped lead data. Checks if it has all the necessary variables to proceed and filters out ones that done. \n\nMake sure you connect your google sheets API on google cloud console."
      },
      "typeVersion": 1
    },
    {
      "id": "3fcfb5cb-5b20-406d-8e8f-ef30af7f7780",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -288,
        -400
      ],
      "parameters": {
        "color": 2,
        "width": 576,
        "height": 448,
        "content": "## Notify \n\nWhen the loop is complete it will send a notification to telegram to notify you that your workflow is complete and you can start using the newly added campaign on instantly.\n\nThe Limit node is there because sometimes the \"loop over items\" node would output as much as it has looped which is problematic. \n\nAlso with Telegram make sure your able to create a seperate chat to receieve these notification there is a link here to create chat bots on the telegram ecosystem. \n\nhttps://core.telegram.org/bots/tutorial#obtain-your-bot-token\n"
      },
      "typeVersion": 1
    },
    {
      "id": "e164dbea-9e30-4f8a-98b6-4bcc46d33074",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -352,
        384
      ],
      "parameters": {
        "color": 3,
        "width": 352,
        "height": 336,
        "content": "## Format Names\nIn this node we focus on cleaning and standardizing the user's first and last name. This step improves the quality of the icebreaker by giving the AI a clean, natural name to work with.\n\nUnformatted names look robotic and unprofessional. For example, you do not want the AI generating an opener like:\n\n\u201cHey John E Riley III\u201d\n\nProper formatting helps the icebreaker feel more personal and less automated."
      },
      "typeVersion": 1
    },
    {
      "id": "e02fab04-a203-45c0-b4fc-4ac33268b196",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        32,
        384
      ],
      "parameters": {
        "color": 3,
        "width": 416,
        "height": 224,
        "content": "## Ice Breaker Generator\n\nUsing the person\u2019s first name, last name, email, bio, summary, and company name, we will generate a personalized icebreaker for cold email outreach or linkedin direct message outreach. and inside the node is the system prompt I use for creating ice breakers Feel free to test differnt prompt for different results of ice breakers. "
      },
      "typeVersion": 1
    },
    {
      "id": "d71a6f90-b912-4103-9300-4c0d10c9eeaf",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        512,
        384
      ],
      "parameters": {
        "color": 3,
        "width": 336,
        "height": 320,
        "content": "## Add leads to a campaign\n\nThis includes adding all required variables to the campaign. Refer to the documentation for the correct process of adding leads: \nhttps://developer.instantly.ai/api/v2/lead/bulkaddleads\n\nProvide first name, last name, email, and a description if needed. It\u2019s important to create the custom variables as shown in the documentation, as this is where the icebreaker variable will be stored in Instantly."
      },
      "typeVersion": 1
    },
    {
      "id": "3ba8e563-f33c-4f4f-ab3e-c2148fb2115b",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -864,
        -192
      ],
      "parameters": {
        "color": 4,
        "width": 304,
        "height": 384,
        "content": "## Creating and populating new sheet within your Google sheet\nWe are grabbing all the rows that can be useful to us and attaching it to a new sheet within the same google sheet document we previously used this way we can be more organized \n"
      },
      "typeVersion": 1
    },
    {
      "id": "1b6d0980-d550-487d-b9cc-06fba2b88a0c",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -528,
        -144
      ],
      "parameters": {
        "color": 7,
        "width": 192,
        "height": 288,
        "content": "## Loop over each name \nthat we are pulling from pervious node. "
      },
      "typeVersion": 1
    },
    {
      "id": "41dbf052-6287-4440-8a1a-4c33d81816bf",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2224,
        -224
      ],
      "parameters": {
        "width": 560,
        "height": 768,
        "content": "## Goal / Overview\n\nThe purpose of this workflow is to extract all the information from a excel sheet or excel any kind of .xlsx file type with rows of information which will contain infromation about leads that you extracted from a particular niche and use A.i to create a personalized icebreaker for a cold email outreach system on instantly and then add their name email and the generated ice breaker on to a Instantly campaign which can be used on a massive email outreach system. \n \n## How It Works\n## Collects Data:\nStart with a spreadsheet containing detailed lead information. Typical fields include:\n\nFirst Name\nLast Name\nSummary or Bio\nCompany Name\nThis you would have to obtain on your own or export from a lead scraper. Insure that the information that your scraping is up to date and contains information that the a.i can use to create customized personal ice breaker such as current job title , job history, recent achievements infomation the a.i can create some sort of relatability too. \n## Using A.I to create Ice Breakers\nas mentioned we are using Chat gpt to be able use the information from the google sheet to be able to curate a human like ice breaker and in which we will use it on instantly. \n\n## Pre requisites\nGoogle Sheets APi\nInstantly campaign ID\nOpen A.I API key\n(Optional) Telegram to notify you when workflow is complete. \nA very well written system prompt to tell the a.i how to create the ice breaker is key and this comes from trail and error. \n"
      },
      "typeVersion": 1
    },
    {
      "id": "01df4ece-5e34-437f-8112-0ab6985b9638",
      "name": "When clicking \u2018Execute workflow\u2019",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -1600,
        48
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "5f87c025-00e5-47b9-b249-d55efe5e2e08",
      "name": "If has all variables",
      "type": "n8n-nodes-base.if",
      "position": [
        -1072,
        48
      ],
      "parameters": {
        "options": {
          "ignoreCase": false
        },
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "b4bc337d-81b9-4fe7-a454-f831f1f02e02",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json.firstName }}",
              "rightValue": ""
            },
            {
              "id": "b71eed51-8c8c-4979-a2c8-7784af6fbe79",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json.lastName }}",
              "rightValue": ""
            },
            {
              "id": "e1463da7-9c51-4602-be85-6fc236e8e896",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json.summary }}",
              "rightValue": ""
            },
            {
              "id": "822a4f5c-3d20-4938-949f-5817a5db2599",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json.email }}",
              "rightValue": ""
            },
            {
              "id": "2057f3e7-6b86-4c1f-b6ac-6ee8ca464fc3",
              "operator": {
                "type": "string",
                "operation": "regex"
              },
              "leftValue": "={{ $json.email }}",
              "rightValue": "^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}$"
            }
          ]
        }
      },
      "typeVersion": 2.2
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "440b420c-b8f8-4536-a27c-fe636145bc8c",
  "connections": {
    "Limit": {
      "main": [
        [
          {
            "node": "Notify Master",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IBC V3": {
      "main": [
        [
          {
            "node": "Add leads to instantly",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Names": {
      "main": [
        [
          {
            "node": "IBC V3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [
          {
            "node": "Limit",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Format Names",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get row(s) in sheet": {
      "main": [
        [
          {
            "node": "If has all variables",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If has all variables": {
      "main": [
        [
          {
            "node": "Append or update row in sheet",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "Add leads to instantly": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "Append or update row in sheet": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking \u2018Execute workflow\u2019": {
      "main": [
        [
          {
            "node": "Get row(s) in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}