Last active
June 26, 2024 06:04
-
-
Save Suleman-Elahi/e412eec49beb608546e28756e619cc23 to your computer and use it in GitHub Desktop.
A Simple Google Apps Script to Push Newly Added Contacts from GoHighLevel Automations to Sheet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function doPost(e) { | |
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Contacts'); //Change Sheet Name | |
var jsonData = JSON.parse(e.postData.contents); | |
var first_name = jsonData.first_name || ''; | |
var last_name = jsonData.last_name || ''; | |
var full_name = jsonData.full_name || ''; | |
var email = jsonData.email || ''; | |
var phone = jsonData.phone || ''; | |
var tags = jsonData.tags || ''; | |
var country = jsonData.country || ''; | |
var state = jsonData.state || ''; | |
var city = jsonData.city || ''; | |
var postalCode = jsonData.postal_code || ''; | |
var fullAddress = jsonData.full_address || ''; | |
var customDataValues = []; | |
if (jsonData.customData) { | |
for (var key in jsonData.customData) { | |
if (jsonData.customData.hasOwnProperty(key)) { | |
customDataValues.push(jsonData.customData[key]); | |
} | |
} | |
} | |
var row = [ | |
first_name, last_name, full_name, email, phone, tags, country, state, city, postalCode, fullAddress | |
].concat(customDataValues); | |
sheet.appendRow(row); | |
return ContentService.createTextOutput('Data received and added to sheet'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Send New Contact to Google Sheet from GHL using Automation. I created this for personal use and now sharing it here if someone else needs it 🙂👍