Fireship · @fireship
Cloud Scheduler - Time Triggers for Cloud Functions
Uploaded November 8, 2018 · Length 4:53
Summary
Learn how to use Cloud Scheduler to schedule Cloud Functions with time triggers, including a step-by-step example of creating a robocall with Twilio.
- cloud scheduler
- cloud functions
- time triggers
- twilio
- robocall
- scheduled jobs
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
[Music]
- 0:06
just a couple days ago Google cloud
- 0:08
platform announced the beta launch of a
- 0:10
very useful new tool called the cloud
- 0:12
scheduler firebase developers can use it
- 0:14
to schedule cloud functions to run at a
- 0:16
specific point in time or on a time
- 0:17
interval today you'll learn how to use
- 0:19
the scheduler and I'll also throw in a
- 0:20
few pro tips to make development of
- 0:22
scheduled jobs as smooth as possible if
- 0:25
you're new here like and subscribe and
- 0:26
you can check out the whole source code
- 0:27
on angular firebase com running cloud
- 0:30
functions on a schedule has been one of
- 0:32
the most commonly requested features so
- 0:33
I'm super excited to now be able to do
- 0:35
that there's all kinds of different use
- 0:36
cases for scheduled jobs but what I'm
- 0:38
going to do today is combine it with
- 0:40
Twilio to create a function that will
- 0:42
call my cell phone every five minutes
- 0:44
and remind me to have a good day
- 0:46
in other words we're going to build our
- 0:48
own Robo call thank you so first let's
- 0:57
take a look at the cloud scheduler tab
- 0:58
on the GCP console and you can see that
- 1:01
setting up a job is pretty
- 1:02
straightforward you can trigger jobs in
- 1:04
one of two ways you can either send a
- 1:06
data payload to an HTTP endpoint or you
- 1:08
can send it to a pub subchannel in most
- 1:11
cases I would recommend setting up your
- 1:12
jobs on a pub sub trigger the primary
- 1:15
reason is that pub sub channels are
- 1:16
secure by default meaning only
- 1:18
authorized google services can send data
- 1:20
to those channels in contrast HTTP
- 1:23
triggers are public to the world so
- 1:24
anybody that has that URL could
- 1:26
potentially trigger your function before
- 1:28
it's actually scheduled now the other
- 1:30
thing you'll notice here on the console
- 1:31
is that you set up the schedule using a
- 1:33
cron table this is just the standard
- 1:35
format for scheduling cron jobs and UNIX
- 1:37
based systems it's not something you
- 1:39
really need to know because there's
- 1:40
tools like crontab guru that allow you
- 1:42
to write out your schedule in a way that
- 1:44
a regular human can understand so now
- 1:46
we're going to write a cloud function
- 1:47
that is triggered on a pub sub message
- 1:49
and we'll hit the Twilio API to make a
- 1:51
voice call to my personal phone number
- 1:54
so we're here in the functions
- 1:55
environment and the only special thing
- 1:57
I've done is installed Twilio x' node
- 1:59
client library then I've also added a


