There are 3 ways I like to schedule triggering Google Cloud Functions:
- Google Cloud Scheduler (free)
- Zapier (paid version)
- IFTTT (free or paid)
Method 1: Google Cloud Scheduler
The pros of using Google Cloud Scheduler is it's super easy and it's free. Their free version is limited to 10 jobs but this is plenty for most people. If you exceed this your cheapest option is probably IFTTT which is $4 a month.
Go to the Cloud Scheduler page at console.cloud.google.com/cloudscheduler. Alternatively you can navigate there by clicking the menu, scroll all the way to the "Tools" section and hit "Cloud Scheduler." You can click the "Pin" icon to make it easier to access later if you want.
After the Cloud Scheduler page loads click "Create Job."
Give it a good name and description so you can figure out WTF this is in the future.
Enter the frequency you want. I run most of mine every hour but put whatever you want. The format is tricky if you've never come across unix-cron formatting before so here are a few examples you can copy and paste in:
* * * * *run every minute.
*/5 * * * *run every 5 minutes
*/30 * * * *run every 30 minutes
0 * * * *run every hour
If you want to learn more about unix-cron formats I would recommend this in-depth page or this simple unix-cron editor.
Enter your country/timezone, choose
HTTP as your target, paste your Cloud Function Trigger URL in "URL", and choose
POST for your "HTTP Method." Leave the other settings blank. Click "Create" and you're done!
Method 2: IFTTT
IFTTT has a free plan that includes 5 automations. I use their paid plan. It's only $4 a month and works great for scheduling Cloud Functions.
Go create a new applet by clicking "Create" or by visiting ifttt.com/create.
Click "Add" to add your trigger.
Choose the "Date & Time" service.
Then choose the interval. I normally use "Every hour" but use whatever makes sense for you.
Finish configuring the remaining inputs and click "Create Trigger"
Now it's time to add your action. Click add:
Choose "Webhook" as your service:
Then choose "Make a web request"
Paste the trigger URL of your Cloud Function into the URL field:
Click "Create Action," "Continue," and "Finish." That's it!
Method 3: Zapier
I love Zapier. It's such an amazing tool. The Zap we're making here is pretty simple but the things you can automate in Zapier are mind-blowing.
Log in and click "Make a Zap."
Choose "Schedule by Zapier" as your trigger:
Choose your trigger event. I use "Every Hour" most frequently but choose whatever makes sense for you and hit "Continue."
Customize it further or click "Continue" again.
Test your trigger and click "Continue" again.
Now choose the "Webhooks by Zapier" action on the next step:
Choose "POST" as your "Action Event" and hit "Continue."
Paste the Trigger URL for your Google Cloud Function (to find this visit Google Cloud Functions, click on your Cloud Function, then click the "Trigger" tab) in the "URL" field.
You can leave the other settings alone. Click "Continue."
Click "Test & Continue" and turn your Zap on. That's it!
Your Cloud Function will run automatically now. Woohoo!