
How to automate Google related tasks - LOLCAT1024
https://developers.google.com/apps-script/
======
Improvotter
Apps Script is honestly pretty terrible simply because the "IDE" you're
working in is terrible. There is no integration with any proper IDE or text
editor. It's using ES5 iirc when it could easily support more advanced
Javascript versions or when it could allow you to use Typescript. I only
sometimes use it out of necessity, but it remains a huge pain.

~~~
askvictor
Yeah, the IDE is painful. I think there are ways to expose the script files in
drive and edit them outside (possibly even debug in eclipse in a very
roundabout way? I might be dreaming). I wish they would integrate with
jetbrains (as they've done with android)

~~~
TheQwerty
There is this: [https://developers.google.com/apps-
script/guides/clasp](https://developers.google.com/apps-script/guides/clasp)

I've not used it and I have a feeling it doesn't really help one take full
advantage of their IDE of choice but it might still beat the online editor.

------
chasontherobot
Recently had to use Apps script to count the number of files in a number of
Google drives folder, it was pretty annoying.

The Drive API doesn't actually expose that information at all so I had to loop
through the files with a counter to get the information I needed, but that was
so inefficient that I got timeout errors for anything but the smallest of
folders.

Unfortunately I had to resort to their Python API which was totally awful in
its own way, but at least I didn't have to worry about timeout errors and
could get the job done.

Google apps script is probably good for doing stuff in spreadsheets or
documents, but its use as an API across Google's platform really needs some
work.

~~~
amelius
And this is called progress. Sharing files on a central computer system
(mainframe), and efficient scripting (e.g. VMS,Unix,etc) was solved in the
70s.

~~~
verinus
pretty much everything connected with the web is a leap backwards in many
ways...not only the programming language and tooling ;)

------
saagarjha
I use Google Apps Script to archive old, unread emails in a label
periodically:
[https://gist.github.com/saagarjha/d8657a5cee921856186cd12180...](https://gist.github.com/saagarjha/d8657a5cee921856186cd12180ae675a).
I find this handy to clear out a couple of labels that invariably accumulate a
junk; for example, I use this on all my mailing list subscriptions. One thing
that's really annoying is that Google Apps Script is _really_ eager to delete
log entries for some reason, so the logging message I put for checking
progress (when time runs out) doesn't ever show up in the logs because it's
always likely that the logs were cleared out before I could read them.

Just for fun, I also have an script to post XKCD to a Slack channel:
[https://gist.github.com/saagarjha/ea067aff9674e8382c15d3b7de...](https://gist.github.com/saagarjha/ea067aff9674e8382c15d3b7dec66594).
It's probably not the intended use, but it's free and runs periodically!

------
fiatjaf
Apps script is very good and powerful, and it's been around since a very long
time ago.

It seems they'll try to push it again now.

My problem with "automating Google-related tasks" was always the complexity of
their APIs, specially authorization, and the need to use those enourmously
complex SDKs they provide. Sometimes I want to just do some curl calls.

In the case of Google Apps Script, perhaps it would've been better if they
came up with a coding environment separate from Google Drive.

~~~
andmalc
Their Clasp tool lets you code Apps Script from your own editor:

[https://developers.google.com/apps-
script/guides/clasp](https://developers.google.com/apps-script/guides/clasp)

~~~
fiatjaf
Whoa, I didn't knew that. It looks great. I'll try it.

------
pbreit
Google Sheets + Apps Script + UrlFetchApp[1] is a very powerful API runner
enabling you to loop through a set of Google Sheet rows to make API calls.

The unofficial APIs exposed by single-page-apps are pretty easy to reverse
engineer, too.

1: [https://developers.google.com/apps-script/reference/url-
fetc...](https://developers.google.com/apps-script/reference/url-fetch/url-
fetch-app#fetch\(String,Object\))

~~~
sudshekhar
Can you give some examples where this combination was more effective than
using a standard file and shell/python

~~~
pbreit
When you have to massage, filter, sort, manipulate the data prior. Which for
me is almost always the point.

------
aarondf
I used Google apps script to make a full invoicing automation system with Zoho
CRM, Zoho Invoice, Google Drive, Google's Spreadsheet-to-PDF tool, and Google
Cloud Print.

There were a bunch of gotchas in terms of the 6-minute runtime, the available
runtime per day, and the script just getting killed randomly.

I managed to work around them all after a lot of hair-pulling... We ran ~15k
invoices through it last year!

~~~
therealmarv
impressive! Good job. But this hair pulling wants me to say "It's the VBA of
Google"

------
patrickdavey
All I want is an API for Google inbox so that I can programmatically make
tasks.

~~~
patrickdavey
To clarify after Bryan very kindly sent me a link to the tasks api [1], what
I'm really after is an interface to the "reminders" functionality in Google
Inbox (basically tasks-lite)

[1] [https://developers.google.com/apps-
script/advanced/tasks](https://developers.google.com/apps-
script/advanced/tasks)

------
RcouF1uZ4gsC
Good is slowly becoming Microsoft. Just when we finally have a handle on worms
spread through Word and Excel Macros, now we will have Google Doc Macros.It
will be interesting to see what kind of security vs usability we will see.
Also, with these Google macros, will an abusive macro that spams, get you
locked out of your Google account and unable to access your documents?

~~~
smackmybishop
Google Apps Script has been around since 2009...

~~~
candiodari
... and has had security incidents

[http://www.behind-the-enemy-lines.com/2012/04/google-
attack-...](http://www.behind-the-enemy-lines.com/2012/04/google-attack-how-i-
self-attacked.html)

~~~
charleslmunger
I don't see any mention of Apps Script in that blog post.

