Full Google Workspace Automation - Apps Scripts
Section A - Introduction to RPA
With the advancement of cloud computing resources - general availability of cloud resources
became cheap and it offered a new platform for development of general automation techniques.
RPA stands for robotic process automation, these classes of procedures and tools aim to mimic
human actions to do a task - achieving equivalent results, at the same time minimizing human
intervention. Today, there are many tools available in the market that help achieve process
automation by creating robotic bots.
A bot is essentially a program or a set of instructions that performs a task. The idea is to design
n
the bot in a way it replicates the human actions required to perform that task - this is where the
various tools come into picture. Bots are primarily of 2 kinds - Attended and Unattended.
ai
Attended bots need human assistance to start, stop and manage. These are relatively simpler
and can be maintained on a local computer - just like your laptop.
os
Unattended bots run when they are triggered - this does not require human intervention. These
are more complicated and need a cloud server to maintain.
Section B - Requirements for Unattended Bots
G
Unattended bots can be triggered through an event or they can be time-based. These events
could be very specifically tied to one of your apps. For example, an event can be when you
v
receive an email from a particular person, or when someone submits a response to your form.
Time - based bots can be triggered at a specific time eg: 5 pm on Friday or at regular intervals
ra
Ex: every 5 minutes.
For an unattended bot to work autonomously, it is essential that a system should be in place to
au
monitor the specific events and clock intervals. This is the reason these bots require a server
preferably running 24 x 7. With Apps Scripts a lot of this overhead management is taken care of.
Since the automations we build with apps scripts do run on google servers - we can take
advantage of all the features and powers of unattended bots.
)G
Section C - Apps Script Triggers
Triggers play a crucial role in management of unattended bots. Apps Script offers both kinds of
triggers for creating and executing a bot which are event triggers and time triggers. Let us look
(C
at how we can create triggers and tie them to our apps script functions.
Refer video for description
Gaurav Gosain - gauraveil@[Link] / info@[Link]
Full Google Workspace Automation - Apps Scripts
Section D - Controlling Bot Behaviour and Monitoring Bot Health
With creation of every bot we have to keep track of their behavior and health. By right bot
behavior, we ensure it is doing what it is supposed to do. Usually this can be done by
introducing an activity tracker - this could simply be a data column with yes / no indicating that
the bot has run for those items. We will learn more about this technique in coming lectures.
The other way bot behavior can be monitored is through execution logs. Here we can log
exceptions and key results.
n
By maintaining bot health, we ensure that the bot performs efficiently within the current
hardware setup limits. Monitoring that our bot is capable of handling incoming jobs and is able
ai
to cope up with fluctuations in load. Usually with a variety of inputs, bots might sometimes
struggle to keep up, hence keeping a check on error rates is a must. This can be done in the
os
Project Overview section of apps script which gives the errors summary in the last 7 days. Here
you can also track the number of executions as a measure of incoming load. Make a habit of
reviewing this dashboard for your projects.
Section E - Limits of Bots in Apps Script
G
v
There are 3 limits that google has implicitly imposed on bots through quotas. These are -
ra
● Script Runtime - This should be less than 6 min / execution
● Triggers total runtime - This should be less than 6 hours / day
● Total Triggers - less than 20 / user / script
au
Now in operations you would not need more than 20 triggers per user for workspace automation
related work. So this limit is nearly impossible to breach.
)G
Let us try to understand how we can best utilize the other 2 limits. Script runtime of less than 6 min
has been imposed due to obvious reasons that google does not want you to bog down the servers.
So individual script executions are cut off at 360s. Any script function that takes more amount of
time is automatically cut off mid way during execution.
(C
So then how do we manage automations that take more than 360s to run. For example, say you have
built a script that sends campaign emails to hundreds of users. Obviously, this cannot be done in
one-go in less than 6 mins. More often than not, you will find yourself in such a situation. The
solution is to break a larger computation into smaller runs and keep track of what you have finished.
Think about it this way. Say you have a 1 pound chocolate cake and like me you want to eat it whole.
Instead of trying to gulp down the whole cake - we cut it into 8 equal slices. Each part is small
enough that we can have it in one go, still leaving some space in our mouth. Eating each slice should
Gaurav Gosain - gauraveil@[Link] / info@[Link]
Full Google Workspace Automation - Apps Scripts
not take more than 6 minutes and total time to finish the cake would be less than 6 x 8 ~ 48 mins
which is less than the 6 hours of trigger runtime quota.
Similarly if we were to send emails to 1000 people, we would send 50 to 100 emails in 1 script
runtime so that it does not take more than 6 mins. Design the bot in such a way that it tracks who it
has already sent the emails to and then continue from the last email sent in the next run.
This methodology will become clearer in the solutions we develop in next lectures.
n
ai
os
G
v
ra
au
)G
(C
Gaurav Gosain - gauraveil@[Link] / info@[Link]