0

I'm trying to pull data from google chat into a spreadsheet but I only need to pull the messages from one Space. I found a script to pull all chat messages but how can I specify which Space to pull from?

function getChats() {
  var sheet = SpreadsheetApp.getActiveSheet();

  sheet.getRange(1, 1).setValue("Date");
  sheet.getRange(1, 2).setValue("Subject");
  sheet.getRange(1, 3).setValue("Body");
  var row = 2;
  
  var chats = GmailApp.getChatThreads();
  var chat_count = chats.length;
  
  for (var i = 0; i < chat_count; i++) {
   var count = chats[i].getMessageCount();
   var messages = chats[i].getMessages();
    
    for (var j = 0; j < count; j++) {
      var chat_date = messages[j].getDate();
      var subject = messages[j].getSubject();
      var body = messages[j].getBody();
      sheet.getRange(row, 1).setValue(chat_date);
      sheet.getRange(row, 2).setValue(subject);
      sheet.getRange(row, 3).setValue(body);
      row++;
    }
    
  }
  Browser.msgBox("All done!");
}
  • https://stackoverflow.com/questions/71212971/get-google-chat-threads-from-today-to-google-sheet – Cooper Jun 13 '22 at 21:48
  • https://developers.google.com/chat/api/reference/rest/v1/spaces – Cooper Jun 13 '22 at 21:52
  • @Cooper Is there a way to add the JSON representation (developers.google.com/chat/api/reference/rest/v1/spaces) into the existing JSON script? – Allister Lobo Jun 15 '22 at 17:47
  • I don't understand. Why would you wish to add data to the manifest? – Cooper Jun 15 '22 at 17:51
  • I reviewed the links you sent but I just have no idea where I would put it. Would it go in the manifest or the function. – Allister Lobo Jun 15 '22 at 19:21
  • Your manifest is used to configure the setup for your projects google apps script. I would leave it alone. It's your data where do you want to put it? – Cooper Jun 15 '22 at 19:25

0 Answers0