Slack to Notion テンプレート (日本語の説明はこちらです)
At first, please duplicate this template and write memos for several parameters to code blocks. I think there are still some bugs, so I will keep version control on GibHub.
slack_to_notion
hkob • Updated Jul 28, 2022
Version history
- Version 0.3 (2022/8/2): multiple workspaces support
- Version 0.2 (2022/7/30): add page when the reaction is the first one.
- Version 0.1 (2022/7/29): first release
↑ Table of Contents
1. Prepare a database2. Create integration key and save the token3. Invite the integration and obtain database_id4. Prepare Google Apps Script5. Create Slack App6. Add Slack tokens to Google Apps Script7. Add the created app to channels8. Setup is complete9. Other implementations9.1 Property only version10. Update from Ver 0.2
1. Prepare a database
- Please copy the following database to your favorite page (append workspace_name select property from ver 0.3)
2. Create integration key and save the token
- Visit my-integrations page, and create an integration key.
- In this description, I use
input_tasks
integration key.

- Copy internal integration token and write it.

3. Invite the integration and obtain database_id
- Open the
Slack Stock DB
database, and invite the above integration.

- Obtain the page URL. The red text in the URL is the database id.
- Copy the database_id from the URL and write it.
4. Prepare Google Apps Script
- Open a new Google Spreadsheet and open Apps Script.

- Copy a scripts from github repository and paste to the script editor.
- Set the integration token saved at 2.3 to MY_NOTION_TOKEN in line 4.
- Set the database_id saved at 3.3 to DATABASE_ID in line 5.
- Select
storeTokenAndIds
and execute it.

- At the first time, OAuth client verification is required. Please allow this Google Apps Script like as the following link.
- If
storeTokenAndIds
can be executed, you can see the above two parameters in execution log.
- Select
testCreateNotionPage
and execute it in order to verify that the above token is correct. If successful, the test data is registered in the database.

- Deploy the first version using
New deployment
.

- Write
Description
and selectAnyone
as “Who has access”

- Copy Web app’s URL and write it

5. Create Slack App
- Open Slack API page
- Click
Create an App

- Select
From scratch

- Set
App Name
and pick a workspace

- Click
Event Subscriptions

- Turn on
Enable Events

- Set Web app’s URL saved at 4.8 to
Request URL
. If the deployment is correct, it should be Verified.

- Push
Add Bot User Event
in Subscribe to bot events and chooserection_added
.

- Click
OAuth & Permissions
in the left menu.

- Click
Add an OAuth Scope
inBot Token Scopes
and add the following scopes - channels:history
- channels:read
- reactions:read
- team:read (from ver 0.3)
- users:read

- Click
Install App
tab and clickInstall to Workspace
. Grant permissions when the dialog appears. After successful installation, you will be redirected to the OAuth Tokens for Your Workspace page.

- Copy
Bot User OAuth Permissions
and write it.

- Click
Basic Information
and CopyVerification Token
inApp Credentials
and write it.

6. Add Slack tokens to Google Apps Script
- Set the verification token saved at 5.13 to the left-hand side of the ":” in line 11.
- Set the Bot User OAuth Token saved at 5.12 to the right-hand side of the “:” in line 11.
- If you have another workspace, append the corresponding verification token and Bot User OAuth token pair.
- Select
storeTokenAndIds
and execute it. You can see the above parameters in execution log.

- You can see these parameters at Script Properties in Project Setting. If you set VERIFICATION_TOKEN and BOT_USER_OAUTH_TOKEN in the previous version, please delete them.

7. Add the created app to channels
- Select a target channel and click
View channel details

- Select
Integrations
tab and clickAdd an App
.

- Click
Add
button for the SlackToNotion


8. Setup is complete
- Please add a 📌 reaction to any message.
9. Other implementations
9.1 Property only version
There has been a request to record information in properties rather than in the body of the Notion.
- Append “link” properties (url) and “whole_message” properties (text)
- Replace the code with the one below
- Redeploy Web App in GAS, and copy new Web app’s URL
- Open Event Subscription page in Slack api, and Change Request URL
10. Update from Ver 0.2
In Ver 0.3, the script has been modified considerably to support multiple Slack Apps. If you have using the previous version, please operate the following instructions to update your settings. A link to the relevant block is attached.
- Add
team:read
to OAuth Scope of Slack App (see 5.10) ClickAdd an OAuth Scope
inBot Token Scopes
and add the following scopes
- Obtain the new sciprt from Github and replace your Google Apps script. (see 4.2) Copy a scripts from github repository and paste to the script editor.
- Set your verifycation token at the left hand of
:
(see 6.1) Set the verification token saved at 5.13 to the left-hand side of the ":” in line 11.
- Set your Bot User OAuth Token at the right hand of
:
(see 6.2). If you are installing in multiple Slack workspaces, add the Slack App token created in each workspace in the same way. Set the Bot User OAuth Token saved at 5.12 to the right-hand side of the “:” in line 11.
- Try running testCreateNotionPage and verify that the workspace name is registered in the database. (see 4.8)
Select
testCreateNotionPage
and execute it in order to verify that the above token is correct. If successful, the test data is registered in the database.
- Deploy the modified source according to steps 4.9-11. Record the generated new URL. (see 4.9-11)
Deploy the first version using
New deployment
.
- Register the recorded URL by pressing Change in the Event Subsctipt. (see 5.7)
Set Web app’s URL saved at 4.8 to
Request URL
. If the deployment is correct, it should be Verified.