Appscript Dropcontact

Salut les Growths !

Pour éviter le processus fastidieux de passer par un zapier ou de faire des téléchargements de fichiers into dropcontact into excel/gsheets j’ai demandé à une IA de me faire un appscript pour enrichir des contacts directement dans Gsheets. J’aimerais l’avis de personnes avec un profil un peu plus tech’ que moi qui n’ai jamais rééllement touché à du code,est ce que le script est bon ? Des choses à optimiser ?
Merci d’avance !

Voici le script :

function enrichPeopleDatabase() {
// Replace « API_KEY » with your Dropcontact API key
var apiKey = « API_KEY »;

// Replace the « sheetName » with the name of your sheet where the people database is stored
var sheetName = « Sheet1 »;

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName(sheetName);
var lastRow = sheet.getLastRow();
var range = sheet.getRange(2, 1, lastRow - 1, 3); // Assuming the email, phone number, and other information are in columns A, B, and C respectively

var values = range.getValues();

// Loop through each row and enrich the data using Dropcontact API
for (var i = 0; i < values.length; i++) {
var email = values[i][0];
var phoneNumber = values[i][1];
var otherInfo = values[i][2];

// Make API request to enrich the data
var url = "https://api.dropcontact.io/enrich";
var payload = {
  "email": email,
  "phone": phoneNumber,
  "data": otherInfo
};
var headers = {
  "Authorization": "Bearer " + apiKey,
  "Content-Type": "application/json"
};
var options = {
  "method": "POST",
  "headers": headers,
  "payload": JSON.stringify(payload)
};

var response = UrlFetchApp.fetch(url, options);
var responseData = JSON.parse(response.getContentText());

// Retrieve the enriched data
var enrichedData = responseData.data;

// Update the enriched data in the sheet
var rowRange = sheet.getRange(i + 2, 4, 1, Object.keys(enrichedData).length);
var rowValues = Object.values(enrichedData);
rowRange.setValues([rowValues]);

}
}

1 « J'aime »

Hello @GrowthUneed Loic,
Merci c’est top cool :ok_hand:

Pour information, il n’y aura même plus besoin de faire de l’Appscript, nous avons l’Addon Dropcontact pour Google Sheet qui est actuellement en cours de validation par Google pour être directement disponible Google Workspace Marketplace.

2 clicks et c’est tous l’enrichissement Dropcontact dans un autre onglet qui est disponible.

Best

3 « J'aime »

Bonjour Denis !

ça a l’air super comme feature, l’addon est sorti depuis ? Désolé pour ma réponse tardive :slight_smile: