How to make a reminder posts messages from Google Sheets to Slack
Tags: tutorial, gas, webdev, productivity
Published: 2022-08-29 09:15:00

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.

{% embed https://www.youtube.com/watch?v=0N-3Wr9SmBU %}

## 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](https://github.com/Kazuki-tam/gas-sheets2slack)

## Settings of Google Sheets
Create a sheet to post messages to Slack.

![Google Sheets](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2du90tjoma2j2xnxyorl.png)

| 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](https://developers.google.com/apps-script/guides/sheets#get_started)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2uatfv28nzsdiarpvp6p.png)

Select "From scratch".

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ls4jid0ubpja3fvqw4dk.png)

Set up display information as you want.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7gpw6im9w219zwh740jt.png)

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m1jsl35mlv8darcn7asl.png)

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](https://github.com/Kazuki-tam/gas-sheets2slack)

### 1. Clone template
Open the repository and click Use this template.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/11relt9q7lzw6zp0y8j7.png)

Clone the repository and install dependencies.

```bash
yarn install
```

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

```bash
yarn clasp login
```

### 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.

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

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

```
SLACK_WEBHOOK_URL=<SLACK_WEBHOOK_URL>
```

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

```bash
yarn deploy
```

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cewl2aahnfoyjakbioli.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/27rff5p0npmrmkc56d5z.png)

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

[👉 gas-sheets2slack](https://github.com/Kazuki-tam/gas-sheets2slack)