Edit on GitHub
Report issue
Page history

Building a Slack reminder app with Cloud Functions and Cloud Scheduler

Author(s): @timtech4u ,   Published: 2019-07-13

Contributed by the Google Cloud community. Not official Google documentation.

In this tutorial, you build and deploy a serverless application that sends messages to Slack using a Cloud Function. You also use Cloud Scheduler to periodically run your application at an interval of 3 hours.


  • Create a Slack app.
  • Create an HTTP serverless function that sends messages to Slack with a Cloud Function.
  • Create a scheduled job that calls your Cloud Function every 3 hours with Cloud Scheduler.

Before you begin

  1. Create a new Google Cloud project, or use an existing one.
  2. Enable billing for your project.
  3. Create a new Slack team, or use a team for which you have permissions to add integrations.


This tutorial uses billable components of Google Cloud including Compute Engine. Use the Pricing Calculator to estimate the costs for your usage.

Slack is free for up to 10 apps and integrations. Check the Slack pricing page for details.

Get the sample code

Get the sample code from GitHub Gist, here.

Create a new Slack app and set up Slack

  1. Go to the Slack app management page.
  2. Click Create new app.
  3. Give the app a name, such as "RestReminder".
  4. Choose the Slack team for development and where you will eventually install it.
  5. Click Incoming Webhooks.
  6. Enable incoming webhooks.
  7. Click Add New Webhook to Team. An authorization page opens.
  8. From the drop-down menu, select the channel to which you would like notifications sent. We'll be using the #random channel.
  9. Click Authorize.
  10. A webhook for your Slack application has been created. Copy the webhook and save it for later use.

Set up the Cloud Function

  1. Go to the Cloud Functions page of the Cloud Console.
  2. Click Create Function.
  3. Enter your function's name in the Name field.
  4. Set Memory allocated to 256MB.
  5. Set Trigger to HTTP.
  6. For Authentication, check Allow unauthenticated invocations.
  7. For Source code, select Inline editor.
  8. For Runtime, choose Node.js 8. (Feel free to change this to suit your choice in future.)
  9. Paste the sample code into the inline editor, both index.js and package.json.
  10. For Function to execute, enter sendToSlack.
  11. Click the Create button to deploy the new Cloud Function.

After these steps are done, you can visit the URL on your Cloud Function URL to test.

Set up Cloud Scheduler

  1. Go to the Cloud Scheduler page of the Cloud Console.
  2. Click Create Job.
  3. Enter a job name in the Name field.
  4. In the Frequency field, enter 0 */3 * * *, which indicates every 3 hours in unix-cron format.
  5. For Target, select HTTP.
  6. In the URL field, enter your deployed Cloud Function URL.
  7. For HTTP method, select GET.

Great! You just scheduled a Slack Bot that sends a message to your Slack channel every 3 hours.

Cleaning up

To prevent unnecessary charges, clean up the resources created for this tutorial.

  1. Delete the project used (if you created a new project).
  2. Delete the Cloud Scheduler job and Cloud Function.

You might also choose to pause the Cloud Scheduler job.

Next steps

If you want to learn more about Cloud Functions and Cloud Scheduler, check out the following resources:

Submit a tutorial

Share step-by-step guides

Submit a tutorial

Request a tutorial

Ask for community help

Submit a request

View tutorials

Search Google Cloud tutorials

View tutorials

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see our Site Policies. Java is a registered trademark of Oracle and/or its affiliates.