Monday 28 January 2019

Save email to Drive add-on - overview

Over the next few blog posts I look to explore my development of a Gmail add-on that is designed to save the current open email in a specific Google Drive folder, by entering a value which corresponds to said folder.

I was approached by a department a couple of months ago that were frustrated with saving student specific emails in a shared Team Drive folder. The process is quite cumbersome:
Open the email > click the Print all icon > change the printer to Save to Google Drive > click Save > now a PDF version of the email is in My Drive so you need to go in there and Move to the Team Drive folder ...
This was the current process for 1 cohort of students between about 4 members of staff, but they wanted to scale it up so that the next academic year they would have student folders for the new intake also, then subsequent years to come after that. Clearly this was going to become extremely time-consuming and needed a re-think.

So back in October I began to explore Gmail add-ons with a colleague, which use the concept of a card that contains a section composed of widgets to display information and interact via buttons. My initial exploration into this area (having only been learning Google Apps Script for about 1 month prior) was overwhelming and difficult to process. It was only once I got stuck into the meaty Student Feedback system did I really have the capacity to pick this up again and carry it into a completed project.

Solution - Overview
The idea evolved into this process:
Open the email > click to open the add-on > enter a student username > confirm the returned student details > click Save Email ...
Now there is more to the eye going on in the background here, primarily a Google Sheet containing a list of students (eg username, name) and then an ID for their Google drive folder. This way the add-on can lookup the username and find the corresponding folder ID to then save a PDF version of the email into it.
Image of the add-on for entering a username
Save message to Drive add-on
Solution - Scripts
Here is a list of the scripts that form the Gmail add-on, I will link them to the relevant blog posts as they are released:
  • getContextualAddOn - this is the first script that runs when the add-on is launched and prompts for a username.
  • getUserInfo - takes the above username, calls a function to look it up in the Google sheet, separates out the returned data and checks the error code status.
  • getDetails - queries the Google sheet with the username, collects the student details and sets an error code if any details are missing.
  • showCard - return the relevant card based on the above error code value, so that the user can proceed with saving the email or needs to investigate missing sheet data.
  • makeTheCopy/getCurrentMessage - save a copy of the email as a PDF in the relevant Google drive folder for the student.
  • finishedCard - success card for completion and to return to the start of the process again.

Solution - Download
Save email to Drive add-on folder

No comments:

Post a Comment