DEV Community

Cover image for How to make a reminder posts messages from Google Sheets to Slack
Kazuki Yonemoto
Kazuki Yonemoto

Posted on

How to make a reminder posts messages from Google Sheets to Slack

You sometimes would like to remind something from Google Sheets you usually manage if you are a heavy Google Sheets user.

I'll introduce how to make a reminder that posts messages from Google Sheets to Slack.

This video shows our goal in this tutorial.

Prerequisites

You need to follow the below prerequisite before you start this tutorial.

  • Create a new sheet in Google sheets
  • Create a workspace or join an existing workspace in Slack
  • Use gas-sheets2slack

Settings of Google Sheets

Create a sheet to post messages to Slack.

Google Sheets

Notification Title Content Url
2022/08/29 Sample title This is a sample text. https://dev.to/

Open Apps Script from within Google Sheets.

๐Ÿ“– Lean more Extending Google Sheets

Get the script ID in Apps Script.
โš ๏ธ Save the ID to use it in development.

Settings of Slack apps

Open https://api.slack.com/apps and click โ€œCreate New Appโ€.

Image description

Select "From scratch".

Image description

Set up display information as you want.

Image description

In your left sidebar, navigate to "Incoming Webhooks" and then activate it.

Image description

Add new webhook to workspace and copy webhook URL.
โš ๏ธ Save the webhook URL to use it in development.

Google Apps Script

We want to use Apps Script to post messages from Google Sheets regularly.

I prepared a template for this project, so you don't have to spend extra time to develop.

๐Ÿ‘‰ gas-sheets2slack

1. Clone template

Open the repository and click Use this template.

Image description

Clone the repository and install dependencies.



yarn install


Enter fullscreen mode Exit fullscreen mode

2. Login Google account

Authorize management of your Google account's Apps Script projects.



yarn clasp login


Enter fullscreen mode Exit fullscreen mode

3. Create files

Create a .clasp.json at the root, and then add these settings.
Open App script from your spreadsheet and check out a script Id at the setting page.



{
  "scriptId": "<SCRIPT_ID>",
  "rootDir": "./dist"
}


Enter fullscreen mode Exit fullscreen mode

Create a .env at the root, and then add "SLACK_WEBHOOK_URL".



SLACK_WEBHOOK_URL=<SLACK_WEBHOOK_URL>


Enter fullscreen mode Exit fullscreen mode

4. Upload a script project

Upload your script project's files from your local with this command.



yarn deploy


Enter fullscreen mode Exit fullscreen mode

Click "Add trigger" from the trigger menu.
Set up these options like this.

Image description

Apps Script finds out if the list has a notification date the same as today from your sheet every day.
Apps Script posts a message when it finds out the date same as today.

Run Apps Script

Run "main.gs" in the editor menu and check out if you can receive a message in your slack channel.

Image description

Conclusion

I hope this tutorial will help you to enhance your reminder flow.

๐Ÿ‘‰ gas-sheets2slack

Top comments (0)