X

Kirim broadcast pesan whatsapp tiap penerima pesan berbeda file / gambar

Kirim broadcast pesan whatsapp tiap penerima pesan berbeda file / gambar dari google spreadsheet

video

appscript

function sendWhatsAppMessages() {
  var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  var dataRange = sheet.getDataRange();
  var data = dataRange.getValues();
   var startrow = sheet.getRange("C8").getValue(); // ganti sesuai letak cell awal bc
  var endrow = sheet.getRange("C9").getValue(); // ganti sesuai letak cell akhir bc

  
  for (var i = startrow; i <= endrow; i++) {
    var row = data[i];
    var name = row[1];
    var phoneNumber = row[2]; // Kolom nomor telepon
    var message = row[3]; // Kolom pesan
    var file = row[4]; // Kolom link file
    
    sendWaFile(phoneNumber, message, file); // jika file berupa pdf ada 2 kali fungsi kirim file dan text 
    sendWaText(phoneNumber, message); // jika file berupa gambar fungsi ini sebaiknya tidak dipakai
  }
}

function sendWaFile(number, message, file) {
  var idDevice = "xxx"; // Ganti dengan ID perangkat Anda
  // var date = new Date(); 
  // var schedule = Utilities.formatDate(date, Session.getScriptTimeZone(), "yyyy-MM-dd HH:mm:ss"); 
  
  var formdata = {
    "device_id" : "" + idDevice,
    "number" : "" + number,
    "message" : "" + message,
    "file" : "" + file,
    // "schedule" : "" + schedule
  };

  var requestOptions = {
    method: 'POST',
    contentType: 'application/json',
    payload: JSON.stringify(formdata),
    redirect: 'follow'
  };

  var response = UrlFetchApp.fetch("https://app.whacenter.com/api/send", requestOptions);
  Logger.log(response);
}

function sendWaText(number, message) {
  var idDevice = "xxx"; // Ganti dengan ID perangkat Anda
  // var date = new Date();
  // var schedule = Utilities.formatDate(date, Session.getScriptTimeZone(), "yyyy-MM-dd HH:mm:ss");
  
  var formdata = {
    "device_id" : "" + idDevice,
    "number" : "" + number,
    "message" : "" + message,
    //"file" : "" + file,
    // "schedule" : "" + schedule
  };

  var requestOptions = {
    method: 'POST',
    contentType: 'application/json',
    payload: JSON.stringify(formdata),
    redirect: 'follow'
  };

  var response = UrlFetchApp.fetch("https://app.whacenter.com/api/send", requestOptions);
  Logger.log(response);
}
adikiss: i'm just an ordinary person | Direktur PT. Adya Global Media | Telegram : <a href="https://t.me/adikiss">t.me/adikiss</a> | Whatsapp : <a href="https://wa.me/6285640206067">wa.me/6285640206067</a> | Facebook : <a href="https://fb.me/adikiswanto">fb.me/adikiswanto</a>
Related Post
X

Headline

You can control the ways in which we improve and personalize your experience. Please choose whether you wish to allow the following:

Privacy Settings