Want to Automate Chat Log Collection

Asked 1 years ago, Updated 1 years ago, 383 views

Chat log collection is performed with administrator authority, exported, and reported to senior managers.
I would like to automate this and report it regularly.Is there any way?

Workspace's standard functionality does not include the ability to collect reports regularly.GAS not supported

I wrote it on a spreadsheet with GAS and automated it, but I was able to do my share.
It is necessary for a third party other than yourself to realize it with the chat room ID.

I'm almost a beginner at GAS, and I'm working on it while studying.

google-apps-script

2022-12-27 02:19

1 Answers

Thank you for your help.
The chat is GoogleChat.
Currently, the following code is written.

function searchMails() {

constquery='is:chat"*";
const threads=GmailApp.search(query);

// Spreadsheet to be exported and its sheet
consts=SpreadsheetApp.getActiveSpreadsheet();
const sheet=ss.getSheetByName('Spreadsheet to Export');

threads.forEach(thread=>{
const messages=thread.getMessages();

messages.forEach(message=>{

  let fromData=message.getFrom(); // Source
  let subject = message.getSubject(); // Subject
  let body=message.getPlainBody();// Body
  let attachments = message.getAttachments(); // Attachment group (array)
  let getId = message.getId(); 
  //let roomId = message.getRooms(); // Attachment group (array)

  let attachmentList=[]; // Array of attachments for storing filenames

  if(attachments.length>0){
    attachments.forEach(attachment=>{

      let name = attachment.getName();

      attachmentList.push(name);
    });
  }

  attachmentList=attachmentList.join(',');

  // let data = [fromData, subject, body, attachmentList, getId, roomId];
    let data = [fromData, subject, body, attachmentList, getId];

  // Export (Add Row) Execution
  sheet.appendRow(data);

});

});
}


2022-12-27 09:08

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.