The ABC of Google Apps Script

There are cases where we want to do some automation on the Internet, says, checking availability of our website or creating a temporary URL that redirect to another site for testing, to accomplish such simple tasks we usually set up a server at our office or use cloud platform such as Digital Ocean, and write some python script. The process was tedious due to the need to set up the hardware (or cloud server), Linux servers, hardening them,  and after a few days of use, remove them from the Internet. All these tedious tasks are gone after I found the Google Apps Script (and Google App Engine).

With Google Apps Script, which everybody with Gmail has access, such simple tasks become really simple, no servers setup needed, I can go straight to writing the script that looks similar to (if it is not) javascript. With a short time to get familiar with the online editor, utilities, and services offered by Google, you are now ready to programming the Internet at your heart desire. Google Apps Script (GAS) allows you to access and automate (up to certain level)  Gmail, Google Calendar, Google Forms, Google Drive, and several other Google services, with ease. The GAS also let you write Web application using HTML services without learning web servers such as Apache or NGINX.

Besides scripting language and services, you can also set up the trigger so that your script can be executed periodically, at particular date and time, or when a Google Docs or Spreadsheet is open, or when a Google Form is submitted. You can set up a notification via email if there are errors in your script which help you to take appropriate actions when a certain event occurs.

For example, I set up a script to monitor Comnet website and if the website goes down, the script will generate and send the error to me so I can start fixing the problem asap.

GAS sent email to me immediately after the execution failure with a sufficiently clear error message including date and time the error occurred that I can understand and start fixing the problem.

GAS online editor can be accessed via ‘https://script.google.com’ and there are a lot of documents at ‘https://developers.google.com/apps-script/’ and many of them contain a simple example for you to get started.

The figure below illustrates how easy to create a website checker that periodically runs and sends errors when found one

.

Setting up trigger is equally simple, just click the Clock icon and you will be ready for a trigger. Multiple triggers can be created for the script e.g. different time trigger for the different function.

If you want a more advanced capability such as a Redirect Server, Please take a look at https://www.maxlaumeister.com/blog/how-to-use-google-app-engine-as-a-free-redirect-server/ for an idea.

เรื่องนี้ถูกเขียนใน Automation, Technology และติดป้ายกำกับ , , คั่นหน้า ลิงก์ถาวร