Last active
May 1, 2024 20:57
-
-
Save molavec/459ec83c8bd5b9ef64ed72a2ef501d60 to your computer and use it in GitHub Desktop.
[zapier - Prepare data] Script para ajustar datos de leads en zapier
This file contains hidden or 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
//Tarea: Ajusta el número de teléfono | |
let phone = { | |
"complete": null, | |
"no_plus": null | |
} | |
if(inputData.phone != null) { | |
var phoneString = inputData.phone.replace(/ /g,''); | |
if(phoneString.charAt(0) === '+') { | |
phone = { | |
"complete": phoneString, | |
"no_plus": phoneString.substr(1) | |
} | |
} else if (phoneString.substr(0,2) === '56') { | |
phone = { | |
"complete": "+" + phoneString, | |
"no_plus": phoneString | |
} | |
} else if (phoneString.length === 9 ) { | |
phone = { | |
"complete": "+56" + phoneString, | |
"no_plus": phoneString | |
} | |
} else if (phoneString.length === 8 ) { | |
phone = { | |
"complete": "+569" + phoneString, | |
"no_plus": phoneString | |
} | |
} else { | |
phone = { | |
"complete": null, | |
"no_plus": phoneString | |
} | |
} | |
} | |
let inputName = inputData.name || ''; | |
let firstname = inputName.trim().split(' ')[0]; | |
let lastname = inputName.trim().split(' ').slice(1).join(' '); | |
let whatsapp = null; | |
if(phone.complete !== null){ | |
whatsapp = "https://api.whatsapp.com/send?phone=" + phone.no_plus + "&text=Hola%20" + firstname; | |
} | |
let whatsappURLGoogleSheet = `=HYPERLINK("${whatsappSaludo}"; "Enviar Whatsapp")` | |
let callURLGoogleSheet= `=HYPERLINK("https://ctrlq.org/call/${phone.complete}","Llamar")` | |
let emailURLGoogleSheet= `=HYPERLINK("${inputData.email}","${inputData.email}")` | |
output = [{ | |
firstname, | |
lastname, | |
phone, | |
whatsappURLGoogleSheet, | |
callURLGoogleSheet, | |
emailURLGoogleSheet | |
}]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment