Task: Intergrate Competitors Social proof to your outbound Email

n8n workflow:
{"id":"61","meta":{"instanceId":"8d2955498ee87246afc459bb62a3d347cde10c94cb545928b54c958a4953963d"},"name":"Competitors Social proof","tags":[{"id":"6","name":"LinkedIn","createdAt":"2023-05-31T19:35:40.386Z","updatedAt":"2023-05-31T19:35:40.386Z"}],"nodes":[{"id":"074759dc-aa4c-4a79-8f41-0731ddbaefa7","name":"GetHomepageHTML","type":"n8n-nodes-base.httpRequest","position":[1120,280],"parameters":{"url":"=https://{{ $json.Domain }}","options":{"timeout":10000,"redirect":{"redirect":{}}}},"typeVersion":4},{"id":"c91bb1d5-b577-4e2a-8a9d-7122b5269eee","name":"ExtractTextOnly","type":"n8n-nodes-base.code","position":[1360,280],"parameters":{"jsCode":"let html = items[0].json[\"data\"];  // Replace \"html\" with your HTML field\n\n// Remove all HTML tags, JavaScript scripts, and CSS styles\nlet text = html.replace(/<script[^>]*>([\\s\\S]*?)<\\/script>/gi, '');\ntext = text.replace(/<style[^>]*>([\\s\\S]*?)<\\/style>/gi, '');\ntext = text.replace(/<\\/?[^>]+(>|$)/g, \"\");\n\n// Replace multiple whitespace characters with a single space\ntext = text.replace(/\\s\\s+/g, ' ');\n\nreturn [{json: {text: text}}];\n"},"typeVersion":1},{"id":"a1e1f503-a67a-4771-8642-73996550c4a2","name":"Industry/Mission","type":"n8n-nodes-base.code","position":[1860,280],"parameters":{"jsCode":"let messageContent = items[0].json.message.content;\n\nlet industryIndex = messageContent.indexOf(\"Industry :\");\nlet missionIndex = messageContent.indexOf(\"Mission :\");\n\nlet industryText = messageContent.slice(industryIndex + 11, missionIndex).trim();\nlet missionText = messageContent.slice(missionIndex + 9).trim();\n\nreturn [\n  {\n    json: {\n      industry: industryText,\n      mission: missionText\n    }\n  }\n];\n"},"typeVersion":1},{"id":"b286d983-a0ac-4c7f-b122-b6a993ec6421","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[1300,60],"parameters":{"width":687.7850162866451,"height":514.6223984710504,"content":"## Integrating GPT to identify Competitors\n"},"typeVersion":1},{"id":"49e825f0-14bd-4f16-90ed-09e9a073c9f0","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[120,60],"parameters":{"width":1159.94175151233,"height":514.211313168916,"content":"## Prepare the input\nupdate the node \"Dummy Data\" by your input and map ir correctly to the node \"GetDeets\"\n"},"typeVersion":1},{"id":"896afcef-d193-44e2-af12-56d042a8cd16","name":"When clicking \"Execute Workflow\"","type":"n8n-nodes-base.manualTrigger","position":[180,280],"parameters":{},"typeVersion":1},{"id":"3ca47a0a-5c43-415a-8ce8-ba152cd4a3db","name":"DummyData","type":"n8n-nodes-base.code","position":[400,280],"parameters":{"jsCode":"return [{\njson: {\n\"email\":\"mahdi.ghazouani@expensya.com\",\n\"FirstName\":\"Mahdi\",\n\"Domain\":\"expensya.com\",\n\"CompanyName\": \"Expensya\",\n\"LinkedInUrl\":\"https://www.linkedin.com/in/mahdi-ghazouani-9b6032199\"\n}\n  }\n    ];"},"typeVersion":1},{"id":"b685a00c-a343-4a16-ba7f-787a7a1c012b","name":"GetDeets","type":"n8n-nodes-base.set","position":[840,280],"parameters":{"values":{"string":[{"name":"Domain","value":"={{ $json.Domain }}"},{"name":"CompanyName","value":"={{ $json.CompanyName }}"}]},"options":{},"keepOnlySet":true},"typeVersion":2},{"id":"54a4176e-2db7-4040-a401-20c56340156f","name":"FindCompetitors","type":"n8n-nodes-base.openAi","position":[2080,280],"parameters":{"model":"gpt-4","prompt":{"messages":[{"role":"system","content":"You're an advanced business oriented with a keen understanding of industries.\nYou're tasked with identifying the direct competitors of a company."},{"content":"=Given the following content from a company's industry and mission, please find the top 50 competitors.\nList the competitors starting with those that are most similar in terms of market, industry, and mission, then gradually include those that are less directly competitive.\nIf there are less than 50 such companies, only provide those that actually exist without guessing or extrapolating.\n\nCompanyName : {{ $node[\"DummyData\"].json[\"CompanyName\"] }}\nDomain : {{ $node[\"DummyData\"].json[\"Domain\"] }}\nCompanyMission : {{ $node[\"Industry/Mission\"].json[\"mission\"] }}\nCompany Indsutry : {{ $node[\"Industry/Mission\"].json[\"industry\"] }}\n\nReturn the list of competitors in this format : \nCompetitor1, Competitor2\n\nReturn the list separated by a comma then space"}]},"options":{},"resource":"chat"},"credentials":{"openAiApi":{"id":"48","name":"OpenAi account"}},"typeVersion":1},{"id":"58d362a2-6451-41a7-8048-170cadb22d44","name":"Separate Items","type":"n8n-nodes-base.code","position":[2300,280],"parameters":{"jsCode":"// The company names from JSON\nlet jsonCompanies = items[0].json.message.content.split(', ');\n\n// Convert each company name into an item\nlet companyItems = jsonCompanies.map(company => ({ json: { company } }));\n\nreturn companyItems;\n"},"typeVersion":1},{"id":"118c3b28-300f-42f2-bd8b-a2f566730b76","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[2240,60],"parameters":{"height":663.2914826187925,"content":"You can specify the fields to retrieve from your database to alleviate the query"},"typeVersion":1},{"id":"1d2a140e-209f-41ee-b74e-95a3b0ebc102","name":"GetClients","type":"n8n-nodes-base.airtable","position":[2300,560],"parameters":{"table":{"__rl":true,"mode":"url","value":"https://airtable.com/appd08IpwDozZ5ly5/tblMLkXodZVsEijet/viw5CBjYTRYZ3OK5j?blocks=hide","__regex":"https://airtable.com/[a-zA-Z0-9]{2,}/([a-zA-Z0-9]{2,})"},"operation":"list","application":{"__rl":true,"mode":"url","value":"https://airtable.com/appd08IpwDozZ5ly5/tblMLkXodZVsEijet/viw5CBjYTRYZ3OK5j?blocks=hide","__regex":"https://airtable.com/([a-zA-Z0-9]{2,})"},"additionalOptions":{"fields":[]}},"credentials":{"airtableApi":{"id":"4","name":"Airtable account"}},"typeVersion":1},{"id":"e0bcf6ee-4392-4375-80fb-91ca6fd0261d","name":"Compare Datasets","type":"n8n-nodes-base.compareDatasets","position":[2720,360],"parameters":{"options":{"multipleMatches":"first"},"resolve":"mix","fuzzyCompare":true,"mergeByFields":{"values":[{"field1":"company","field2":"fields.SLD"}]}},"typeVersion":2.2},{"id":"dbf5c34c-f19b-47c6-9005-4f31e7aec04e","name":"MatchedCompetitors","type":"n8n-nodes-base.code","position":[3080,360],"parameters":{"jsCode":"let output = [];\n\nif(items.length === 1){\n    // If there's only one item, return it.\n    output.push({ value: items[0].json.company });\n}\nelse if(items.length > 1){\n  \n    let firstThreeItems = items.slice(0, 3);  // This will take the first three items from the array.\n    let outputValue = firstThreeItems.map(item => item.json.company).join(\", \"); \n    output.push({ value: outputValue });\n}\n\nreturn output;  // Return the output.\n"},"typeVersion":1},{"id":"83aea921-deed-4da6-9cc1-e80d459c13de","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[3000,40],"parameters":{"height":685.4751292356,"content":"## Prepare CompaniesList to inject\n\nIf one item will be returned if more will take 3 maximum."},"typeVersion":1},{"id":"44e19012-0811-41e1-a0ba-23985f712787","name":"FindCompanyMission","type":"n8n-nodes-base.openAi","position":[1620,280],"parameters":{"model":"gpt-4","prompt":{"messages":[{"role":"system","content":"You're an advanced business oriented with a keen understanding of industries.\nYou're tasked with identifying the industry of a company from a content."},{"content":"=Given the following content from a company's homepage, please identify the industry\n\nWebsite content : {{ $json[\"text\"] }}\n\nReturn the industry in this format : \nIndustry : \n\nAfter that analyze the content and give me a brief description of the company focus and mission under 30 words, following this format \nMission : "}]},"options":{},"resource":"chat"},"credentials":{"openAiApi":{"id":"48","name":"OpenAi account"}},"typeVersion":1},{"id":"e60e6283-b3c0-4b34-97e3-077cfcb00c6e","name":"Split In Batches","type":"n8n-nodes-base.splitInBatches","position":[620,280],"parameters":{"options":{},"batchSize":1},"typeVersion":2},{"id":"dc35a711-3417-4b8c-a36d-0cbcabf8a617","name":"MatchingProof","type":"n8n-nodes-base.code","position":[3340,360],"parameters":{"jsCode":"let variable = items[0].json.value; // 'value' is the actual field name in your case\nlet outputText = `Want to see under the hood of how ${variable} are efficiently growing their marketing programs?`;\n\nreturn [{ json: { text: outputText } }];"},"typeVersion":1},{"id":"f6b5edb3-505d-4bde-91ed-cd039b8fcca2","name":"Sticky Note4","type":"n8n-nodes-base.stickyNote","position":[3520,40],"parameters":{"height":682.7021734084994,"content":"## Shoot to your outbound tool\n\nIn this example it's for **Lemlist** to add leads to a campaign, you can change an update if you want to populate leads that exists already in a campaign\n\n*Update* : \nCampaign ID \naccess token\nemail"},"typeVersion":1},{"id":"63007ef9-33d3-4413-afd4-5bde34a0b9e1","name":"Sticky Note6","type":"n8n-nodes-base.stickyNote","position":[2000,60],"parameters":{"width":219.20283129674397,"height":512.1653900418012,"content":"### Find top 50 competitors\nThis GPT4 will return for you the competitor in the proper format"},"typeVersion":1},{"id":"9f7a7e62-3f82-4479-8dbc-38e4ee552179","name":"Sticky Note7","type":"n8n-nodes-base.stickyNote","position":[3260,40],"parameters":{"height":684.0886513220496,"content":"## Prepare the icebreaker\n**Double click** to edit \nIntegrate the list of companies to the icebreaker test"},"typeVersion":1},{"id":"ee5585b0-f298-49ce-bb38-593cc5427270","name":"Send Lemlist campaign","type":"n8n-nodes-base.httpRequest","position":[3600,360],"parameters":{"url":"=https://api.lemlist.com/api/campaigns/{{CampaignID}}leads/{{ $node.DummyData.json.email }}","method":"POST","options":{},"sendBody":true,"sendQuery":true,"bodyParameters":{"parameters":[{"name":"firstName","value":"={{ $node.DummyData.json.FirstName }}"},{"name":"linkedinUrl","value":"={{ $node.DummyData.json.LinkedInUrl }}"},{"name":"companyName","value":"={{ $node.DummyData.json.CompanyName }}"},{"name":"MatchingProof","value":"={{ $json.text }}"}]},"queryParameters":{"parameters":[{"name":"access_token"}]}},"typeVersion":3,"continueOnFail":true}],"active":false,"pinData":{},"settings":{},"versionId":"a66e9699-a562-4f8e-883a-305472f6e1b7","connections":{"GetDeets":{"main":[[{"node":"GetHomepageHTML","type":"main","index":0}]]},"DummyData":{"main":[[{"node":"Split In Batches","type":"main","index":0}]]},"GetClients":{"main":[[{"node":"Compare Datasets","type":"main","index":1}]]},"MatchingProof":{"main":[[{"node":"Send Lemlist campaign","type":"main","index":0}]]},"Separate Items":{"main":[[{"node":"GetClients","type":"main","index":0},{"node":"Compare Datasets","type":"main","index":0}]]},"ExtractTextOnly":{"main":[[{"node":"FindCompanyMission","type":"main","index":0}]]},"FindCompetitors":{"main":[[{"node":"Separate Items","type":"main","index":0}]]},"GetHomepageHTML":{"main":[[{"node":"ExtractTextOnly","type":"main","index":0}]]},"Compare Datasets":{"main":[[],[],[{"node":"MatchedCompetitors","type":"main","index":0}]]},"Industry/Mission":{"main":[[{"node":"FindCompetitors","type":"main","index":0}]]},"Split In Batches":{"main":[[{"node":"GetDeets","type":"main","index":0}]]},"FindCompanyMission":{"main":[[{"node":"Industry/Mission","type":"main","index":0}]]},"MatchedCompetitors":{"main":[[{"node":"MatchingProof","type":"main","index":0}]]},"When clicking \"Execute Workflow\"":{"main":[[{"node":"DummyData","type":"main","index":0}]]}}}