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
hkobUpdated 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 database

  1. Please copy the following database to your favorite page (append workspace_name select property from ver 0.3)
Slack stocks DB

2. Create integration key and save the token

  1. Visit my-integrations page, and create an integration key.
  1. In this description, I use input_tasks integration key.
    1. notion image
  1. Copy internal integration token and write it.
    1. notion image

3. Invite the integration and obtain database_id

  1. Open the Slack Stock DB database, and invite the above integration.
    1. notion image
  1. Obtain the page URL. The red text in the URL is the database id.
    1. Copy the database_id from the URL and write it.

      4. Prepare Google Apps Script

      1. Open a new Google Spreadsheet and open Apps Script.
        1. notion image
      1. Copy a scripts from github repository and paste to the script editor.
        1. Slack2NotionScript
      1. Set the integration token saved at 2.3 to MY_NOTION_TOKEN in line 4.
      1. Set the database_id saved at 3.3 to DATABASE_ID in line 5.
      1. Select storeTokenAndIds and execute it.
        1. notion image
      1. At the first time, OAuth client verification is required. Please allow this Google Apps Script like as the following link.
      1. If storeTokenAndIds can be executed, you can see the above two parameters in execution log.
      1. 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.
        1. notion image
      1. Deploy the first version using New deployment.
        1. notion image
      1. Write Description and select Anyone as “Who has access”
        1. notion image
      1. Copy Web app’s URL and write it
        1. notion image

      5. Create Slack App

      1. Open Slack API page
      1. Click Create an App
        1. notion image
      1. Select From scratch
        1. notion image
      1. Set App Name and pick a workspace
        1. notion image
      1. Click Event Subscriptions
        1. notion image
      1. Turn on Enable Events
        1. notion image
      1. Set Web app’s URL saved at 4.8 to Request URL . If the deployment is correct, it should be Verified.
        1. notion image
      1. Push Add Bot User Event in Subscribe to bot events and choose rection_added.
        1. notion image
      1. Click OAuth & Permissions in the left menu.
        1. notion image
      1. Click Add an OAuth Scope in Bot Token Scopes and add the following scopes
        1. channels:history
        2. channels:read
        3. reactions:read
        4. team:read (from ver 0.3)
        5. users:read
        6. notion image
      1. Click Install App tab and click Install to Workspace. Grant permissions when the dialog appears. After successful installation, you will be redirected to the OAuth Tokens for Your Workspace page.
        1. notion image
      1. Copy Bot User OAuth Permissions and write it.
        1. notion image
      1. Click Basic Information and Copy Verification Token in App Credentials and write it.
        1. notion image

      6. Add Slack tokens to Google Apps Script

      1. Set the verification token saved at 5.13 to the left-hand side of the ":” in line 11.
      1. Set the Bot User OAuth Token saved at 5.12 to the right-hand side of the “:” in line 11.
      1. If you have another workspace, append the corresponding verification token and Bot User OAuth token pair.
      1. Select storeTokenAndIds and execute it. You can see the above parameters in execution log.
        1. notion image
      1. 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.
        1. notion image

      7. Add the created app to channels

      1. Select a target channel and click View channel details
        1. notion image
      1. Select Integrations tab and click Add an App.
        1. notion image
      1. Click Add button for the SlackToNotion
        1. notion image
          notion image

      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)
      • 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.
      1. Add team:read to OAuth Scope of Slack App (see 5.10) Click Add an OAuth Scope in Bot Token Scopes and add the following scopes
      1. 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.
      1. 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.
      1. 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.
      1. 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.
      1. 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.
      1. 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.
       
      Loading...