6 ms·
Got the basics working. Made a spreadsheet. Made a google form ("how has your day been?" + a text area) - they automatically add their fields to the spreadshee
by 10ren 16y ago
Got the basics working.
Made a spreadsheet. Made a google form ("how has your day been?" + a text area) - they automatically add their fields to the spreadsheet. Wrote a short script that selects a random row at random, and emails it to me + a link to the form. Added a trigger that runs that script at 8pm-9pm daily. [if anyone wants the script, I'll post it - please improve it!]
Some flaws: 1. I couldn't work out how to automatically embed a form in the email directly, neither using their embed code (an <iframe>) - it works if they email it to you (which you need to trigger manually), but also gives a warning "you are leaving this page"; 2. also couldn't work out how to initialize the form with the random previous entry (a blog post said you could, but that was in 2008) nor 2. writing my own form (need an URL for the action: seems you need a form key, which you can't get, for security reasons(?))
Boy browser programming sure is frustrating: browser locked up twice had to set it all up again; 7 sec load time for pages; weird cursor movement for editing (and also not vim); along with the above limitation. Though it probably doesn't help that I don't know what I'm doing :-)
- gwern 16y agoI'd like to see the script; I take it that it's some sort of Perl thingy which goes through the Google spreadsheet API? Or does the spreadsheet have builtin scripting?
- 10ren 16y agoIt's built-in; it's Javascript. In the spreadsheet, the script stuff is in the "tools" menu, and it opens a new window which has a menu for "triggers". The help is pretty excellent (reference and tutorials), but it doesn't cover Javascript's standard libraries, only google's special spreadsheet classes (BTW: there's some cool stuff in there for webserves, you can download URLs and parse XML.) function sendEmail() { var sheet = SpreadsheetApp.getActiveSheet(); var numRows = sheet.getLastRow() -1;// don't count first row var selectedRow = Math.floor(Math.random() * numRows); var dataRange = sheet.getRange(selectedRow+2, 1, 1, 2);// from A2, 1 row, 2 cols var values = dataRange.getValues(); var date = values[0][0]; // 1st row, 1st col var prev = values[0][1]; // 1st row, 2nd col var message = "<HTML><BODY>" + '<a href="'+yourFormURLhere+'">goto form</a>' + '<BR>' + '<b>Oh snap! Remember this from '+date+'</b>' + '<BR>' + '<textarea rows="20" cols="60" name="prev">' + prev + '</textarea>' + '<font size=1>RemainingDailyQuota: '+ MailApp.getRemainingDailyQuota() +'<font>' + "</HTML></BODY>" ; MailApp.sendEmail( yourAddressHere, "How did your day go?", "", {htmlBody: message}); } You get the yourFormURLhere from the form editor. The daily quota is 500 emails. Protip: It turns out 8pm is not a good time for the trigger to send it, for you to record the day's events, if you keep odd hours like me and get up at 9pm sometimes... EDIT the http://OhLife.com http://OhLife.com selection of the previous entry is more useful: they first choose whether it will be "one month ago" or "one week ago" etc, then work out that date, and then get the entry from that date (or I guess the next one if blank). It might turn out that for a particular person that always being reminded of "this time last week" is a very effective context (or some mix of them). Bonus: it's trivial to then describe the entry with that string, which is much more natural than some timedate format.