⏱ Scheduling Firebase Cloud Functions with Cloud Scheduler

Pascal Luther
4 min readJan 13, 2019


I recently came across the use case where I needed to schedule a Firebase Cloud Function on a daily basis. I wanted a function that sends an email to my users via Amazon SES every night. A very common use case I’d say.

Since Firebase does not provide a scheduling functionality for its functions (yet), you need to find some other way to schedule a function. And there is a very easy way offered by Google itself: The Google Cloud Scheduler.

So let’s get started.

I am assuming that you already have a cloud function you call via your app manually (as described here), like the one below:

exports.sendEmail = functions.https.onCall((data, context) => {
// sending the email

Now that probably works well for you, but we want to call this function regularly and automatically.

Step 1 — Set up a Cloud Scheduler Job

So let’s hop over to your Google Cloud Platform console (which you can access with the same account you use Firebase) and then go to the Cloud Scheduler here.

@CodingDoug from the Firebase team just released an awesome and very insightful article about the relationship between Firebase and Google Cloud Platform, check it out here.

It should look more or less like this:

Google Cloud Platform — Cloud Scheduler

Now create a job with the following settings:

Name: (any name)
Description: (any description)
Frequency: Use https://crontab.guru for calculating the right expression
Frequency: (any timezone)

And now the important part:

Target: Pub/Sub
Topic: (any topic name -> note that down)
Payload: (leave blank)

Alright, so the scheduler is set up and will run at the specified interval and call our topic with the topic name we defined above.

But what the hell is a topic and how does that thing call my cloud function? Well, we are not going into the details of Pub/Sub topics, but we are going to create a topic now…



Pascal Luther

Cloud Product Architect by day, recreational web-developer by night. Currently a big fan of Vue & Nuxt.js and of going serverless with Google Firebase.