Let's build a robo-caller 🤖 ☎️. Learn how to use the new GCP Cloud Scheduler to trigger Firebase Cloud Functions at specific times or intervals. https://angularfirebase.com/lessons/cloud-scheduler-for-firebase-functions/

- Cloud Scheduler https://cloud.google.com/scheduler/
- Pubsub Functions https://firebase.google.com/docs/functions/pubsub-events
2024-02-04T07:08:47.713Z
nova-2
2-general-nova
2024-01-09.29447
30089e05-99d1-4376-b32e-c263170674af
160895e1-a82a-4c00-a1ab-af368dfd39b4
c08d34df3be95ffb85bd2a60bbe490d9264c4971ec3f2f2c4326188c422e1de1
67875a7f-c9c4-48a0-aa55-5bdb8a91c34a
deprecated
Just a couple days ago, Google Cloud Platform announced the beta launch of a very useful new tool called the Cloud Scheduler.
Firebase developers can use it to schedule Cloud functions to run at a specific point in time or on a time interval.
Today, you'll learn how to use the scheduler, and I'll also throw in a few pro tips to make development of scheduled jobs as smooth as possible.
If you're new here, like and subscribe, and you can check out the full source code on angularfirebase.com.
Running Cloud Functions on a schedule has been one of the most commonly requested features.
So I'm super excited to now be able to do that.
There's all kinds of different use cases for scheduled jobs, but what I'm going to do today is combine it with Twilio to create a function that will call my cell phone every 5 minutes and remind me to have a good day.
In other words, we're going to build our own robo Caller.
Hey, Jeff.
I just wanted to remind you to have an awesome day.
Thank you.
So first, let's take a look at the Cloud Scheduler tab on the GCP console, and you can see that setting up a job is pretty straightforward.
You can trigger jobs in one of 2 ways.
You can either send a data payload to an HTTP endpoint or you can send it to a PubSub channel.
In most cases, I would recommend setting up your jobs on a PubSub trigger.
The primary reason is that PubSub channels are secure by default, meaning only authorized Google services can send data to those channels.
In contrast, HTTP triggers are public to the world.
So anybody that has that URL could potentially trigger your function before it's actually scheduled.
Now the other thing you'll notice here on the console is that you set up the schedule using a cron table.
This is just the standard format for scheduling cron jobs in UNIX based systems.
It's not something you really need to know because there's tools like Chrontab Guru that allow you to write out your schedule in a way that a regular human can understand.
So now we're going to write a Cloud Function that is triggered on a PubSub message and we'll hit the Twilio API to make a voice call to my personal phone number.
So we're here in the Functions environment and the only special thing I've done is installed Twilio's NodeClient Library.
Then I've also added a series of environment variables to our function for the to and from phone numbers and also the client API keys.
All that information is contained on the Twilio dashboard.
I'm not really going to get into that because I just want to set this up as example so we can schedule it on a time interval.
From that point, we'll go ahead and take our API keys and then initialize the TwilioClient.
And And then we'll set up a Cloud Function that's triggered on a specific PubSub topic.
Anytime a message is sent to this topic, this Cloud Function will be invoked.
You'll wanna make a note of the topic you choose because you'll need that when setting up the Cloud Scheduler.
We can make this an async function and then we'll use the Twilio client to make a phone call which just needs a to and a from number.
Then we can give it a script which is a URL that needs to be saved somewhere with some XML data.
I'll show you that in just a second here.
And that's pretty much all the code that's necessary to build your own Robo caller with Twilio.
Obviously, there's a lot more we can do here, but we'll cover that in a future video.
Then just to show you what that XML looks like, it's called TwiML format and it has basically just a script that your bot will say when the user picks up the phone.
The next step is to just deploy our functions.
And then we'll set up a scheduled job to run them on a time interval.
Now the next thing we'll do is go into the GCP p Dashboard.
And we'll create the topic that we just registered this Cloud Function for.
So I actually changed the name of my trigger to call my phone.
And if you've deployed your Cloud Function, you should see that you have one subscriber after you create this topic.
And if you wanna test it out now, you can just send a message to this topic And you should get Twilio calling your phone after a couple seconds.
That's how the function gets invoked.
But we want this to happen, say, every 5 minutes or so.
Let's go back to Chrontab Guru and we'll figure out the pattern to send a message every 5 minutes.
Go ahead and copy that and then go back to the Cloud Scheduler tab on GCP.
You'll first need to give the job a name, and then we can paste in the Cron table into that frequency field.
Then the last step is to set the target as PubSub, and then we'll have it point to our call my phone topic.
Now every 5 minutes on the hour, you should get a call from Twilio reminding you to have a great day.
And A couple of other nice things about this interface is that you can trigger your Jobs to run early by just clicking the Run Now button and you can also view the logs to make sure that they're running on the schedule that you intended.
All in all this is a very useful new tool to have and I look forward to building some integrations with it in the future.
I'm gonna go ahead and wrap things Up there.
If this video helped you, please like and subscribe.
And, if you want to take your development to the next level, consider becoming a Pro Member at AngularFirebase dot com.
You'll get access to all kinds of exclusive Content designed to help you build and ship your app faster.
Thanks for watching, and I will talk to you soon.

Speaker 0: Just a couple days ago, Google Cloud Platform announced the beta launch of a very useful new tool called the Cloud Scheduler. Firebase developers can use it to schedule Cloud functions to run at a specific point in time or on a time interval. Today, you'll learn how to use the scheduler, and I'll also throw in a few pro tips to make development of scheduled jobs as smooth as possible. If you're new here, like and subscribe, and you can check out the full source code on angularfirebase.com. Running Cloud Functions on a schedule has been one of the most commonly requested features.

So I'm super excited to now be able to do that. There's all kinds of different use cases for scheduled jobs, but what I'm going to do today is combine it with Twilio to create a function that will call my cell phone every 5 minutes and remind me to have a good day. In other words, we're going to build our own robo Caller.

Speaker 1: Hey, Jeff. I just wanted to remind you to have an awesome day.

Speaker 0: Thank you. So first, let's take a look at the Cloud Scheduler tab on the GCP console, and you can see that setting up a job is pretty straightforward. You can trigger jobs in one of 2 ways. You can either send a data payload to an HTTP endpoint or you can send it to a PubSub channel. In most cases, I would recommend setting up your jobs on a PubSub trigger.

The primary reason is that PubSub channels are secure by default, meaning only authorized Google services can send data to those channels. In contrast, HTTP triggers are public to the world. So anybody that has that URL could potentially trigger your function before it's actually scheduled. Now the other thing you'll notice here on the console is that you set up the schedule using a cron table. This is just the standard format for scheduling cron jobs in UNIX based systems.

It's not something you really need to know because there's tools like Chrontab Guru that allow you to write out your schedule in a way that a regular human can understand. So now we're going to write a Cloud Function that is triggered on a PubSub message and we'll hit the Twilio API to make a voice call to my personal phone number. So we're here in the Functions environment and the only special thing I've done is installed Twilio's NodeClient Library. Then I've also added a series of environment variables to our function for the to and from phone numbers and also the client API keys. All that information is contained on the Twilio dashboard.

I'm not really going to get into that because I just want to set this up as example so we can schedule it on a time interval. From that point, we'll go ahead and take our API keys and then initialize the TwilioClient. And And then we'll set up a Cloud Function that's triggered on a specific PubSub topic. Anytime a message is sent to this topic, this Cloud Function will be invoked. You'll wanna make a note of the topic you choose because you'll need that when setting up the Cloud Scheduler.

We can make this an async function and then we'll use the Twilio client to make a phone call which just needs a to and a from number. Then we can give it a script which is a URL that needs to be saved somewhere with some XML data. I'll show you that in just a second here. And that's pretty much all the code that's necessary to build your own Robo caller with Twilio. Obviously, there's a lot more we can do here, but we'll cover that in a future video.

Then just to show you what that XML looks like, it's called TwiML format and it has basically just a script that your bot will say when the user picks up the phone. The next step is to just deploy our functions. And then we'll set up a scheduled job to run them on a time interval. Now the next thing we'll do is go into the GCP p Dashboard. And we'll create the topic that we just registered this Cloud Function for.

So I actually changed the name of my trigger to call my phone. And if you've deployed your Cloud Function, you should see that you have one subscriber after you create this topic. And if you wanna test it out now, you can just send a message to this topic And you should get Twilio calling your phone after a couple seconds. That's how the function gets invoked. But we want this to happen, say, every 5 minutes or so.

Let's go back to Chrontab Guru and we'll figure out the pattern to send a message every 5 minutes. Go ahead and copy that and then go back to the Cloud Scheduler tab on GCP. You'll first need to give the job a name, and then we can paste in the Cron table into that frequency field. Then the last step is to set the target as PubSub, and then we'll have it point to our call my phone topic. Now every 5 minutes on the hour, you should get a call from Twilio reminding you to have a great day.

And A couple of other nice things about this interface is that you can trigger your Jobs to run early by just clicking the Run Now button and you can also view the logs to make sure that they're running on the schedule that you intended. All in all this is a very useful new tool to have and I look forward to building some integrations with it in the future. I'm gonna go ahead and wrap things Up there. If this video helped you, please like and subscribe. And, if you want to take your development to the next level, consider becoming a Pro Member at AngularFirebase dot com.

You'll get access to all kinds of exclusive Content designed to help you build and ship your app faster. Thanks for watching, and I will talk to you soon.
Just a couple days ago, Google Cloud Platform announced the beta launch of a very useful new tool called the Cloud Scheduler. Firebase developers can use it to schedule Cloud functions to run at a specific point in time or on a time interval. Today, you'll learn how to use the scheduler, and I'll also throw in a few pro tips to make development of scheduled jobs as smooth as possible. If you're new here, like and subscribe, and you can check out the full source code on angularfirebase.com. Running Cloud Functions on a schedule has been one of the most commonly requested features.
So I'm super excited to now be able to do that. There's all kinds of different use cases for scheduled jobs, but what I'm going to do today is combine it with Twilio to create a function that will call my cell phone every 5 minutes and remind me to have a good day.
phones
In other words, we're going to build our own robo Caller. Hey, Jeff. I just wanted to remind you to have an awesome day. Thank you. So first, let's take a look at the Cloud Scheduler tab on the GCP console, and you can see that setting up a job is pretty straightforward. You can trigger jobs in one of 2 ways. You can either send a data payload to an HTTP endpoint or you can send it to a PubSub channel. In most cases, I would recommend setting up your jobs on a PubSub trigger. The primary reason is that PubSub channels are secure by default, meaning only authorized Google services can send data to those channels. In contrast, HTTP triggers are public to the world. So anybody that has that URL could potentially trigger your function before it's actually scheduled. Now the other thing you'll notice here on the console is that you set up the schedule using a cron table. This is just the standard format for scheduling cron jobs in UNIX based systems. It's not something you really need to know because there's tools like Chrontab Guru that allow you to write out your schedule in a way that a regular human can understand. So now we're going to write a Cloud Function that is triggered on a PubSub message and we'll hit the Twilio API to make a voice call to my personal phone number. So we're here in the Functions environment and the only special thing I've done is installed Twilio's NodeClient Library. Then I've also added a series of environment variables to our function for the to and from phone numbers and also the client API keys. All that information is contained on the Twilio dashboard. I'm not really going to get into that because I just want to set this up as example so we can schedule it on a time interval. From that point, we'll go ahead and take our API keys and then initialize the TwilioClient. And And then we'll set up a Cloud Function that's triggered on a specific PubSub topic. Anytime a message is sent to this topic, this Cloud Function will be invoked. You'll wanna make a note of the topic you choose because you'll need that when setting up the Cloud Scheduler. We can make this an async function and then we'll use the Twilio client to make a phone call which just needs a to and a from number.
Then we can give it a script which is a URL that needs to be saved somewhere with some XML data. I'll show you that in just a second here. And that's pretty much all the code that's necessary to build your own Robo caller with Twilio. Obviously, there's a lot more we can do here, but we'll cover that in a future video. Then just to show you what that XML looks like, it's called TwiML format and it has basically just a script that your bot will say when the user picks up the phone. The next step is to just deploy our functions. And then we'll set up a scheduled job to run them on a time interval.
programming
Now the next thing we'll do is go into the GCP p Dashboard. And we'll create the topic that we just registered this Cloud Function for. So I actually changed the name of my trigger to call my phone. And if you've deployed your Cloud Function, you should see that you have one subscriber after you create this topic. And if you wanna test it out now, you can just send a message to this topic And you should get Twilio calling your phone after a couple seconds. That's how the function gets invoked. But we want this to happen, say, every 5 minutes or so. Let's go back to Chrontab Guru and we'll figure out the pattern to send a message every 5 minutes. Go ahead and copy that and then go back to the Cloud Scheduler tab on GCP. You'll first need to give the job a name, and then we can paste in the Cron table into that frequency field. Then the last step is to set the target as PubSub, and then we'll have it point to our call my phone topic. Now every 5 minutes on the hour, you should get a call from Twilio reminding you to have a great day.
And A couple of other nice things about this interface is that you can trigger your Jobs to run early by just clicking the Run Now button and you can also view the logs to make sure that they're running on the schedule that you intended. All in all this is a very useful new tool to have and I look forward to building some integrations with it in the future.
networking
programming
I'm gonna go ahead and wrap things Up there. If this video helped you, please like and subscribe. And, if you want to take your development to the next level, consider becoming a Pro Member at AngularFirebase dot com. You'll get access to all kinds of exclusive Content designed to help you build and ship your app faster. Thanks for watching, and I will talk to you soon.
youtube
software
streaming
multimedia
internet
software development
Just a couple days ago, Google Cloud Platform announced the beta launch of a very useful new tool called the Cloud Scheduler. Firebase developers can use it to schedule Cloud functions to run at a specific point in time or on a time interval. Today, you'll learn how to use the scheduler, and I'll also throw in a few pro tips to make development of scheduled jobs as smooth as possible. If you're new here, like and subscribe, and you can check out the full source code on angularfirebase.com. Running Cloud Functions on a schedule has been one of the most commonly requested features. So I'm super excited to now be able to do that. There's all kinds of different use cases for scheduled jobs, but what I'm going to do today is combine it with Twilio to create a function that will call my cell phone every 5 minutes and remind me to have a good day. In other words, we're going to build our own robo Caller. Hey, Jeff. I just wanted to remind you to have an awesome day. Thank you. So first, let's take a look at the Cloud Scheduler tab on the GCP console, and you can see that setting up a job is pretty straightforward. You can trigger jobs in one of 2 ways. You can either send a data payload to an HTTP endpoint or you can send it to a PubSub channel. In most cases, I would recommend setting up your jobs on a PubSub trigger. The primary reason is that PubSub channels are secure by default, meaning only authorized Google services can send data to those channels. In contrast, HTTP triggers are public to the world. So anybody that has that URL could potentially trigger your function before it's actually scheduled. Now the other thing you'll notice here on the console is that you set up the schedule using a cron table. This is just the standard format for scheduling cron jobs in UNIX based systems. It's not something you really need to know because there's tools like Chrontab Guru that allow you to write out your schedule in a way that a regular human can understand. So now we're going to write a Cloud Function that is triggered on a PubSub message and we'll hit the Twilio API to make a voice call to my personal phone number. So we're here in the Functions environment and the only special thing I've done is installed Twilio's NodeClient Library. Then I've also added a series of environment variables to our function for the to and from phone numbers and also the client API keys. All that information is contained on the Twilio dashboard. I'm not really going to get into that because I just want to set this up as example so we can schedule it on a time interval. From that point, we'll go ahead and take our API keys and then initialize the TwilioClient. And And then we'll set up a Cloud Function that's triggered on a specific PubSub topic. Anytime a message is sent to this topic, this Cloud Function will be invoked. You'll wanna make a note of the topic you choose because you'll need that when setting up the Cloud Scheduler. We can make this an async function and then we'll use the Twilio client to make a phone call which just needs a to and a from number. Then we can give it a script which is a URL that needs to be saved somewhere with some XML data. I'll show you that in just a second here. And that's pretty much all the code that's necessary to build your own Robo caller with Twilio. Obviously, there's a lot more we can do here, but we'll cover that in a future video. Then just to show you what that XML looks like, it's called TwiML format and it has basically just a script that your bot will say when the user picks up the phone. The next step is to just deploy our functions. And then we'll set up a scheduled job to run them on a time interval. Now the next thing we'll do is go into the GCP p Dashboard. And we'll create the topic that we just registered this Cloud Function for. So I actually changed the name of my trigger to call my phone. And if you've deployed your Cloud Function, you should see that you have one subscriber after you create this topic. And if you wanna test it out now, you can just send a message to this topic And you should get Twilio calling your phone after a couple seconds. That's how the function gets invoked. But we want this to happen, say, every 5 minutes or so. Let's go back to Chrontab Guru and we'll figure out the pattern to send a message every 5 minutes. Go ahead and copy that and then go back to the Cloud Scheduler tab on GCP. You'll first need to give the job a name, and then we can paste in the Cron table into that frequency field. Then the last step is to set the target as PubSub, and then we'll have it point to our call my phone topic. Now every 5 minutes on the hour, you should get a call from Twilio reminding you to have a great day. And A couple of other nice things about this interface is that you can trigger your Jobs to run early by just clicking the Run Now button and you can also view the logs to make sure that they're running on the schedule that you intended. All in all this is a very useful new tool to have and I look forward to building some integrations with it in the future. I'm gonna go ahead and wrap things Up there. If this video helped you, please like and subscribe. And, if you want to take your development to the next level, consider becoming a Pro Member at AngularFirebase dot com. You'll get access to all kinds of exclusive Content designed to help you build and ship your app faster. Thanks for watching, and I will talk to you soon.
Just
just
a
a
couple
couple
days
days
ago,
ago
Google
google
Cloud
cloud
Platform
platform
announced
announced
the
the
beta
beta
launch
launch
of
of
a
a
very
very
useful
useful
new
new
tool
tool
called
called
the
the
Cloud
cloud
Scheduler.
scheduler
Firebase
firebase
developers
developers
can
can
use
use
it
it
to
to
schedule
schedule
Cloud
cloud
functions
functions
to
to
run
run
at
at
a
a
specific
specific
point
point
in
in
time
time
or
or
on
on
a
a
time
time
interval.
interval
Today,
today
you'll
you'll
learn
learn
how
how
to
to
use
use
the
the
scheduler,
scheduler
and
and
I'll
i'll
also
also
throw
throw
in
in
a
a
few
few
pro
pro
tips
tips
to
to
make
make
development
development
of
of
scheduled
scheduled
jobs
jobs
as
as
smooth
smooth
as
as
possible.
possible
If
if
you're
you're
new
new
here,
here
like
like
and
and
subscribe,
subscribe
and
and
you
you
can
can
check
check
out
out
the
the
full
full
source
source
code
code
on
on
angularfirebase.com.
angularfirebase.com
Running
running
Cloud
cloud
Functions
functions
on
on
a
a
schedule
schedule
has
has
been
been
one
one
of
of
the
the
most
most
commonly
commonly
requested
requested
features.
features
So
so
I'm
i'm
super
super
excited
excited
to
to
now
now
be
be
able
able
to
to
do
do
that.
that
There's
there's
all
all
kinds
kinds
of
of
different
different
use
use
cases
cases
for
for
scheduled
scheduled
jobs,
jobs
but
but
what
what
I'm
i'm
going
going
to
to
do
do
today
today
is
is
combine
combine
it
it
with
with
Twilio
twilio
to
to
create
create
a
a
function
function
that
that
will
will
call
call
my
my
cell
cell
phone
phone
every
every
5
5
minutes
minutes
and
and
remind
remind
me
me
to
to
have
have
a
a
good
good
day.
day
In
in
other
other
words,
words
we're
we're
going
going
to
to
build
build
our
our
own
own
robo
robo
Caller.
caller
Hey,
hey
Jeff.
jeff
I
i
just
just
wanted
wanted
to
to
remind
remind
you
you
to
to
have
have
an
an
awesome
awesome
day.
day
Thank
thank
you.
you
So
so
first,
first
let's
let's
take
take
a
a
look
look
at
at
the
the
Cloud
cloud
Scheduler
scheduler
tab
tab
on
on
the
the
GCP
gcp
console,
console
and
and
you
you
can
can
see
see
that
that
setting
setting
up
up
a
a
job
job
is
is
pretty
pretty
straightforward.
straightforward
You
you
can
can
trigger
trigger
jobs
jobs
in
in
one
one
of
of
2
2
ways.
ways
You
you
can
can
either
either
send
send
a
a
data
data
payload
payload
to
to
an
an
HTTP
http
endpoint
endpoint
or
or
you
you
can
can
send
send
it
it
to
to
a
a
PubSub
pubsub
channel.
channel
In
in
most
most
cases,
cases
I
i
would
would
recommend
recommend
setting
setting
up
up
your
your
jobs
jobs
on
on
a
a
PubSub
pubsub
trigger.
trigger
The
the
primary
primary
reason
reason
is
is
that
that
PubSub
pubsub
channels
channels
are
are
secure
secure
by
by
default,
default
meaning
meaning
only
only
authorized
authorized
Google
google
services
services
can
can
send
send
data
data
to
to
those
those
channels.
channels
In
in
contrast,
contrast
HTTP
http
triggers
triggers
are
are
public
public
to
to
the
the
world.
world
So
so
anybody
anybody
that
that
has
has
that
that
URL
url
could
could
potentially
potentially
trigger
trigger
your
your
function
function
before
before
it's
it's
actually
actually
scheduled.
scheduled
Now
now
the
the
other
other
thing
thing
you'll
you'll
notice
notice
here
here
on
on
the
the
console
console
is
is
that
that
you
you
set
set
up
up
the
the
schedule
schedule
using
using
a
a
cron
cron
table.
table
This
this
is
is
just
just
the
the
standard
standard
format
format
for
for
scheduling
scheduling
cron
cron
jobs
jobs
in
in
UNIX
unix
based
based
systems.
systems
It's
it's
not
not
something
something
you
you
really
really
need
need
to
to
know
know
because
because
there's
there's
tools
tools
like
like
Chrontab
chrontab
Guru
guru
that
that
allow
allow
you
you
to
to
write
write
out
out
your
your
schedule
schedule
in
in
a
a
way
way
that
that
a
a
regular
regular
human
human
can
can
understand.
understand
So
so
now
now
we're
we're
going
going
to
to
write
write
a
a
Cloud
cloud
Function
function
that
that
is
is
triggered
triggered
on
on
a
a
PubSub
pubsub
message
message
and
and
we'll
we'll
hit
hit
the
the
Twilio
twilio
API
api
to
to
make
make
a
a
voice
voice
call
call
to
to
my
my
personal
personal
phone
phone
number.
number
So
so
we're
we're
here
here
in
in
the
the
Functions
functions
environment
environment
and
and
the
the
only
only
special
special
thing
thing
I've
i've
done
done
is
is
installed
installed
Twilio's
twilio's
NodeClient
nodeclient
Library.
library
Then
then
I've
i've
also
also
added
added
a
a
series
series
of
of
environment
environment
variables
variables
to
to
our
our
function
function
for
for
the
the
to
to
and
and
from
from
phone
phone
numbers
numbers
and
and
also
also
the
the
client
client
API
api
keys.
keys
All
all
that
that
information
information
is
is
contained
contained
on
on
the
the
Twilio
twilio
dashboard.
dashboard
I'm
i'm
not
not
really
really
going
going
to
to
get
get
into
into
that
that
because
because
I
i
just
just
want
want
to
to
set
set
this
this
up
up
as
as
example
example
so
so
we
we
can
can
schedule
schedule
it
it
on
on
a
a
time
time
interval.
interval
From
from
that
that
point,
point
we'll
we'll
go
go
ahead
ahead
and
and
take
take
our
our
API
api
keys
keys
and
and
then
then
initialize
initialize
the
the
TwilioClient.
twilioclient
And
and
And
and
then
then
we'll
we'll
set
set
up
up
a
a
Cloud
cloud
Function
function
that's
that's
triggered
triggered
on
on
a
a
specific
specific
PubSub
pubsub
topic.
topic
Anytime
anytime
a
a
message
message
is
is
sent
sent
to
to
this
this
topic,
topic
this
this
Cloud
cloud
Function
function
will
will
be
be
invoked.
invoked
You'll
you'll
wanna
wanna
make
make
a
a
note
note
of
of
the
the
topic
topic
you
you
choose
choose
because
because
you'll
you'll
need
need
that
that
when
when
setting
setting
up
up
the
the
Cloud
cloud
Scheduler.
scheduler
We
we
can
can
make
make
this
this
an
an
async
async
function
function
and
and
then
then
we'll
we'll
use
use
the
the
Twilio
twilio
client
client
to
to
make
make
a
a
phone
phone
call
call
which
which
just
just
needs
needs
a
a
to
to
and
and
a
a
from
from
number.
number
Then
then
we
we
can
can
give
give
it
it
a
a
script
script
which
which
is
is
a
a
URL
url
that
that
needs
needs
to
to
be
be
saved
saved
somewhere
somewhere
with
with
some
some
XML
xml
data.
data
I'll
i'll
show
show
you
you
that
that
in
in
just
just
a
a
second
second
here.
here
And
and
that's
that's
pretty
pretty
much
much
all
all
the
the
code
code
that's
that's
necessary
necessary
to
to
build
build
your
your
own
own
Robo
robo
caller
caller
with
with
Twilio.
twilio
Obviously,
obviously
there's
there's
a
a
lot
lot
more
more
we
we
can
can
do
do
here,
here
but
but
we'll
we'll
cover
cover
that
that
in
in
a
a
future
future
video.
video
Then
then
just
just
to
to
show
show
you
you
what
what
that
that
XML
xml
looks
looks
like,
like
it's
it's
called
called
TwiML
twiml
format
format
and
and
it
it
has
has
basically
basically
just
just
a
a
script
script
that
that
your
your
bot
bot
will
will
say
say
when
when
the
the
user
user
picks
picks
up
up
the
the
phone.
phone
The
the
next
next
step
step
is
is
to
to
just
just
deploy
deploy
our
our
functions.
functions
And
and
then
then
we'll
we'll
set
set
up
up
a
a
scheduled
scheduled
job
job
to
to
run
run
them
them
on
on
a
a
time
time
interval.
interval
Now
now
the
the
next
next
thing
thing
we'll
we'll
do
do
is
is
go
go
into
into
the
the
GCP
gcp
p
p
Dashboard.
dashboard
And
and
we'll
we'll
create
create
the
the
topic
topic
that
that
we
we
just
just
registered
registered
this
this
Cloud
cloud
Function
function
for.
for
So
so
I
i
actually
actually
changed
changed
the
the
name
name
of
of
my
my
trigger
trigger
to
to
call
call
my
my
phone.
phone
And
and
if
if
you've
you've
deployed
deployed
your
your
Cloud
cloud
Function,
function
you
you
should
should
see
see
that
that
you
you
have
have
one
one
subscriber
subscriber
after
after
you
you
create
create
this
this
topic.
topic
And
and
if
if
you
you
wanna
wanna
test
test
it
it
out
out
now,
now
you
you
can
can
just
just
send
send
a
a
message
message
to
to
this
this
topic
topic
And
and
you
you
should
should
get
get
Twilio
twilio
calling
calling
your
your
phone
phone
after
after
a
a
couple
couple
seconds.
seconds
That's
that's
how
how
the
the
function
function
gets
gets
invoked.
invoked
But
but
we
we
want
want
this
this
to
to
happen,
happen
say,
say
every
every
5
5
minutes
minutes
or
or
so.
so
Let's
let's
go
go
back
back
to
to
Chrontab
chrontab
Guru
guru
and
and
we'll
we'll
figure
figure
out
out
the
the
pattern
pattern
to
to
send
send
a
a
message
message
every
every
5
5
minutes.
minutes
Go
go
ahead
ahead
and
and
copy
copy
that
that
and
and
then
then
go
go
back
back
to
to
the
the
Cloud
cloud
Scheduler
scheduler
tab
tab
on
on
GCP.
gcp
You'll
you'll
first
first
need
need
to
to
give
give
the
the
job
job
a
a
name,
name
and
and
then
then
we
we
can
can
paste
paste
in
in
the
the
Cron
cron
table
table
into
into
that
that
frequency
frequency
field.
field
Then
then
the
the
last
last
step
step
is
is
to
to
set
set
the
the
target
target
as
as
PubSub,
pubsub
and
and
then
then
we'll
we'll
have
have
it
it
point
point
to
to
our
our
call
call
my
my
phone
phone
topic.
topic
Now
now
every
every
5
5
minutes
minutes
on
on
the
the
hour,
hour
you
you
should
should
get
get
a
a
call
call
from
from
Twilio
twilio
reminding
reminding
you
you
to
to
have
have
a
a
great
great
day.
day
And
and
A
a
couple
couple
of
of
other
other
nice
nice
things
things
about
about
this
this
interface
interface
is
is
that
that
you
you
can
can
trigger
trigger
your
your
Jobs
jobs
to
to
run
run
early
early
by
by
just
just
clicking
clicking
the
the
Run
run
Now
now
button
button
and
and
you
you
can
can
also
also
view
view
the
the
logs
logs
to
to
make
make
sure
sure
that
that
they're
they're
running
running
on
on
the
the
schedule
schedule
that
that
you
you
intended.
intended
All
all
in
in
all
all
this
this
is
is
a
a
very
very
useful
useful
new
new
tool
tool
to
to
have
have
and
and
I
i
look
look
forward
forward
to
to
building
building
some
some
integrations
integrations
with
with
it
it
in
in
the
the
future.
future
I'm
i'm
gonna
gonna
go
go
ahead
ahead
and
and
wrap
wrap
things
things
Up
up
there.
there
If
if
this
this
video
video
helped
helped
you,
you
please
please
like
like
and
and
subscribe.
subscribe
And,
and
if
if
you
you
want
want
to
to
take
take
your
your
development
development
to
to
the
the
next
next
level,
level
consider
consider
becoming
becoming
a
a
Pro
pro
Member
member
at
at
AngularFirebase
angularfirebase
dot
dot
com.
com
You'll
you'll
get
get
access
access
to
to
all
all
kinds
kinds
of
of
exclusive
exclusive
Content
content
designed
designed
to
to
help
help
you
you
build
build
and
and
ship
ship
your
your
app
app
faster.
faster
Thanks
thanks
for
for
watching,
watching
and
and
I
i
will
will
talk
talk
to
to
you
you
soon.
soon
success
In this video, Speaker 0 explains how to use the Cloud Scherver tool to schedule Cloud functions and mentions the benefits of using it for scheduling jobs. They also discuss setting up a cloud function for a specific topic and the use of Twilio to make a phone call. Speaker 1 reminds Speaker 0 to have a good day and explains how to set up the Cloud Schbed job using the GCP dashboard. They also discuss the use of a job to run the job and mention a link to access exclusive content for developers to build and ship their app.
Cloud Scheduler - Time Triggers for Cloud Functions
Just a couple days ago, Google Cloud Platform announced the beta launch of a very useful new tool called the Cloud Scheduler. Firebase developers can use it to schedule Cloud functions to run at a specific point in time or on a time interval. Today, you'll learn how to use the scheduler, and I'll also throw in a few pro tips to make development of scheduled jobs as smooth as possible. If you're new here, like and subscribe, and you can check out the full source code on angularfirebase.com. Running Cloud Functions on a schedule has been one of the most commonly requested features. So I'm super excited to now be able to do that. There's all kinds of different use cases for scheduled jobs, but what I'm going to do today is combine it with Twilio to create a function that will call my cell phone every 5 minutes and remind me to have a good day. In other words, we're going to build our own robo Caller. Hey, Jeff. I just wanted to remind you to have an awesome day. Thank you. So first, let's take a look at the Cloud Scheduler tab on the GCP console, and you can see that setting up a job is pretty straightforward. You can trigger jobs in one of 2 ways. You can either send a data payload to an HTTP endpoint or you can send it to a PubSub channel. In most cases, I would recommend setting up your jobs on a PubSub trigger. The primary reason is that PubSub channels are secure by default, meaning only authorized Google services can send data to those channels. In contrast, HTTP triggers are public to the world. So anybody that has that URL could potentially trigger your function before it's actually scheduled. Now the other thing you'll notice here on the console is that you set up the schedule using a cron table. This is just the standard format for scheduling cron jobs in UNIX based systems. It's not something you really need to know because there's tools like Chrontab Guru that allow you to write out your schedule in a way that a regular human can understand. So now we're going to write a Cloud Function that is triggered on a PubSub message and we'll hit the Twilio API to make a voice call to my personal phone number. So we're here in the Functions environment and the only special thing I've done is installed Twilio's NodeClient Library. Then I've also added a series of environment variables to our function for the to and from phone numbers and also the client API keys. All that information is contained on the Twilio dashboard. I'm not really going to get into that because I just want to set this up as example so we can schedule it on a time interval. From that point, we'll go ahead and take our API keys and then initialize the TwilioClient. And And then we'll set up a Cloud Function that's triggered on a specific PubSub topic. Anytime a message is sent to this topic, this Cloud Function will be invoked. You'll wanna make a note of the topic you choose because you'll need that when setting up the Cloud Scheduler. We can make this an async function and then we'll use the Twilio client to make a phone call which just needs a to and a from number. Then we can give it a script which is a URL that needs to be saved somewhere with some XML data. I'll show you that in just a second here. And that's pretty much all the code that's necessary to build your own Robo caller with Twilio. Obviously, there's a lot more we can do here, but we'll cover that in a future video. Then just to show you what that XML looks like, it's called TwiML format and it has basically just a script that your bot will say when the user picks up the phone. The next step is to just deploy our functions. And then we'll set up a scheduled job to run them on a time interval. Now the next thing we'll do is go into the GCP p Dashboard. And we'll create the topic that we just registered this Cloud Function for. So I actually changed the name of my trigger to call my phone. And if you've deployed your Cloud Function, you should see that you have one subscriber after you create this topic. And if you wanna test it out now, you can just send a message to this topic And you should get Twilio calling your phone after a couple seconds. That's how the function gets invoked. But we want this to happen, say, every 5 minutes or so. Let's go back to Chrontab Guru and we'll figure out the pattern to send a message every 5 minutes. Go ahead and copy that and then go back to the Cloud Scheduler tab on GCP. You'll first need to give the job a name, and then we can paste in the Cron table into that frequency field. Then the last step is to set the target as PubSub, and then we'll have it point to our call my phone topic. Now every 5 minutes on the hour, you should get a call from Twilio reminding you to have a great day. And A couple of other nice things about this interface is that you can trigger your Jobs to run early by just clicking the Run Now button and you can also view the logs to make sure that they're running on the schedule that you intended. All in all this is a very useful new tool to have and I look forward to building some integrations with it in the future. I'm gonna go ahead and wrap things Up there. If this video helped you, please like and subscribe. And, if you want to take your development to the next level, consider becoming a Pro Member at AngularFirebase dot com. You'll get access to all kinds of exclusive Content designed to help you build and ship your app faster. Thanks for watching, and I will talk to you soon.
In this video, Speaker 0 explains how to use the Cloud Scherver tool to schedule Cloud functions and mentions the benefits of using it for scheduling jobs. They also discuss setting up a cloud function for a specific topic and the use of Twilio to make a phone call. Speaker 1 reminds Speaker 0 to have a good day and explains how to set up the Cloud Schbed job using the GCP dashboard. They also discuss the use of a job to run the job and mention a link to access exclusive content for developers to build and ship their app.

        [INST]
        You are youtuber called Fireship you make engaging high-intensity and entertaining coding tutorials and tech news. 
        you covers a wide range of topics relevant to programmers, aiming to help them learn and improve their skills quickly.
        
        Given the title of the video : Cloud Scheduler - Time Triggers for Cloud Functions 
        and a small summary : In this video, Speaker 0 explains how to use the Cloud Scherver tool to schedule Cloud functions and mentions the benefits of using it for scheduling jobs. They also discuss setting up a cloud function for a specific topic and the use of Twilio to make a phone call. Speaker 1 reminds Speaker 0 to have a good day and explains how to set up the Cloud Schbed job using the GCP dashboard. They also discuss the use of a job to run the job and mention a link to access exclusive content for developers to build and ship their app.
        [/INST]
        
        Generate the video : Just a couple days ago, Google Cloud Platform announced the beta launch of a very useful new tool called the Cloud Scheduler. Firebase developers can use it to schedule Cloud functions to run at a specific point in time or on a time interval. Today, you'll learn how to use the scheduler, and I'll also throw in a few pro tips to make development of scheduled jobs as smooth as possible. If you're new here, like and subscribe, and you can check out the full source code on angularfirebase.com. Running Cloud Functions on a schedule has been one of the most commonly requested features. So I'm super excited to now be able to do that. There's all kinds of different use cases for scheduled jobs, but what I'm going to do today is combine it with Twilio to create a function that will call my cell phone every 5 minutes and remind me to have a good day. In other words, we're going to build our own robo Caller. Hey, Jeff. I just wanted to remind you to have an awesome day. Thank you. So first, let's take a look at the Cloud Scheduler tab on the GCP console, and you can see that setting up a job is pretty straightforward. You can trigger jobs in one of 2 ways. You can either send a data payload to an HTTP endpoint or you can send it to a PubSub channel. In most cases, I would recommend setting up your jobs on a PubSub trigger. The primary reason is that PubSub channels are secure by default, meaning only authorized Google services can send data to those channels. In contrast, HTTP triggers are public to the world. So anybody that has that URL could potentially trigger your function before it's actually scheduled. Now the other thing you'll notice here on the console is that you set up the schedule using a cron table. This is just the standard format for scheduling cron jobs in UNIX based systems. It's not something you really need to know because there's tools like Chrontab Guru that allow you to write out your schedule in a way that a regular human can understand. So now we're going to write a Cloud Function that is triggered on a PubSub message and we'll hit the Twilio API to make a voice call to my personal phone number. So we're here in the Functions environment and the only special thing I've done is installed Twilio's NodeClient Library. Then I've also added a series of environment variables to our function for the to and from phone numbers and also the client API keys. All that information is contained on the Twilio dashboard. I'm not really going to get into that because I just want to set this up as example so we can schedule it on a time interval. From that point, we'll go ahead and take our API keys and then initialize the TwilioClient. And And then we'll set up a Cloud Function that's triggered on a specific PubSub topic. Anytime a message is sent to this topic, this Cloud Function will be invoked. You'll wanna make a note of the topic you choose because you'll need that when setting up the Cloud Scheduler. We can make this an async function and then we'll use the Twilio client to make a phone call which just needs a to and a from number. Then we can give it a script which is a URL that needs to be saved somewhere with some XML data. I'll show you that in just a second here. And that's pretty much all the code that's necessary to build your own Robo caller with Twilio. Obviously, there's a lot more we can do here, but we'll cover that in a future video. Then just to show you what that XML looks like, it's called TwiML format and it has basically just a script that your bot will say when the user picks up the phone. The next step is to just deploy our functions. And then we'll set up a scheduled job to run them on a time interval. Now the next thing we'll do is go into the GCP p Dashboard. And we'll create the topic that we just registered this Cloud Function for. So I actually changed the name of my trigger to call my phone. And if you've deployed your Cloud Function, you should see that you have one subscriber after you create this topic. And if you wanna test it out now, you can just send a message to this topic And you should get Twilio calling your phone after a couple seconds. That's how the function gets invoked. But we want this to happen, say, every 5 minutes or so. Let's go back to Chrontab Guru and we'll figure out the pattern to send a message every 5 minutes. Go ahead and copy that and then go back to the Cloud Scheduler tab on GCP. You'll first need to give the job a name, and then we can paste in the Cron table into that frequency field. Then the last step is to set the target as PubSub, and then we'll have it point to our call my phone topic. Now every 5 minutes on the hour, you should get a call from Twilio reminding you to have a great day. And A couple of other nice things about this interface is that you can trigger your Jobs to run early by just clicking the Run Now button and you can also view the logs to make sure that they're running on the schedule that you intended. All in all this is a very useful new tool to have and I look forward to building some integrations with it in the future. I'm gonna go ahead and wrap things Up there. If this video helped you, please like and subscribe. And, if you want to take your development to the next level, consider becoming a Pro Member at AngularFirebase dot com. You'll get access to all kinds of exclusive Content designed to help you build and ship your app faster. Thanks for watching, and I will talk to you soon.
        