Airtable cold email automation
-
Demo
-
Code For Enrichment action (Snov.io)
-
// First, send an api request to get the token let tokenResponse = await remoteFetchAsync("https://api.snov.io/v1/oauth/access_token", { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ "grant_type": "client_credentials", "client_id": "YOUR_CLIENT_ID", "client_secret": "YOUR_CLIENT_SECRET" }) }) // create a variable from the response var data = await tokenResponse.json(); let token = data.access_token; // Get the url from the record let table = base.getTable('Leads'); let record = await input.recordAsync('Select a record to use', table); let url = record.getCellValue('Linkedin URL'); var requestOptions = { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${token}` }, body: JSON.stringify({ url: `${url}` }) }; let addForSearch = await remoteFetchAsync("https://api.snov.io/v1/add-url-for-search", requestOptions) let response = await remoteFetchAsync("https://api.snov.io/v1/get-emails-from-url", requestOptions) // Get lead first name from response (stored in data["firstName"]) var data = await response.json(); let firstName = data["data"]["firstName"]; let lastName = data["data"]["lastName"]; let companyName = data["data"]["currentJob"][0]["companyName"] var email = "" try { var email = data["data"]["emails"][0]["email"] } catch (error) { } console.log(data["data"]) // Update the record with the new values table.updateRecordAsync(record, { "First Name": firstName, "Last Name": lastName, "Email": email, "Company Name": companyName });
-
Code For "Send to Instantly"
-
//Airtable script to send a contact to the instantly.ai API let table = base.getTable('Leads'); // This is triggered when a button is pressed. Get the value of the record that was passed in let record = await input.recordAsync('Select a record to use', table); // Get the variables content from the "Message Sets" table belonging to the record let email = record.getCellValue('Email'); let firstName = record.getCellValue('First Name'); let lastName = record.getCellValue('Last Name'); let companyName = record.getCellValue('Company Name'); // create a function which takes a string and replaces {{firstName}} and {{lastName}} with the first and last name of the contact function replaceNames(text) { if (typeof text === 'string') { return text.replace("{{firstName}}", firstName) .replace("{{lastName}}", lastName) .replace("{{companyName}}", companyName); } else { // Handle the case where text is not a string // You might want to return an empty string, the original text, // or log an error message, depending on your needs console.error( typeof text ) console.error("Input to replaceNames is not a string:", text); return ""; // or return text; } } // Get the content of the emails from the "Message Sets" table belonging to the record let firstEmailContent = replaceNames(record.getCellValue('First Email Content')[0]); let secondEmailContent = replaceNames(record.getCellValue('Second Email Content')[0]); let thirdEmailContent = replaceNames(record.getCellValue('Third Email Content')[0]); // Now, create the request to the API var myHeaders = new Headers(); var raw = JSON.stringify({ "api_key": "YOURKEY", "campaign_id": "YOURCAMPAIGNID", "skip_if_in_workspace": "true", "leads": [ { "email": `${email}`, "first_name": `${firstName}`, "last_name": `${lastName}`, "company_name": `${companyName}`, "custom_variables": { "firstEmailContent": `${firstEmailContent}`, "secondEmailContent": `${secondEmailContent}`, "thirdEmailContent": `${thirdEmailContent}` } } ] }); var requestOptions = { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: raw, redirect: 'error' }; let response = await remoteFetchAsync("https://api.instantly.ai/api/v1/lead/add", requestOptions) console.log(await response.text());
-