DEV Community

Cover image for How to build a knowledge system with Slack and Notion
Kazuki Yonemoto
Kazuki Yonemoto

Posted on • Edited on

How to build a knowledge system with Slack and Notion

Have you ever felt like managing information flows more efficiently if you usually use Slack?

I want to share tips to manage information by Slack and Notion in this article.

Knowledge system by Slack and Notion

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

  • Slack paid plan
  • Slack account
  • Notion account
  • Google account
  • Google sheets

We actually need Google sheets to post messages to Notion from Slack.

Settings of Notion

Create a table to stock information.

  • Question: title
  • Answer: rich_text
  • URL: url
  • Tags: multi_select

Image description

Get a database's ID in Notion.
📖 Lean more Notion databases

Image description

Use Copy link to view from the menu.

https://www.notion.so/{workspace_name}/{database_id}?v={view_id}
Enter fullscreen mode Exit fullscreen mode

⚠️ Save the ID to use it in development.

In your left sidebar, navigate to Settings & Members and then the Integrations tab.

Image description

Click "Develop your own integrations".

Image description

Click the + New integration button.

Image description

Setup settings of integration.

Image description

Copy the internal integration token.

⚠️ Save the token to use it in development.

Image description

Invite the integration which you created from the share menu.

Settings of Google Sheets

Create a sheet to recieve messages from Slack and post them to Notion.

Image description

Question Answer URL Tags
sample text sample text https://dev.to/ sample, tags

Open Apps Script from within Google Sheets.

📖 Lean more Extending Google Sheets

Get the script ID in Apps Script.

Image description

⚠️ Save the ID to use it in development.

Settings of Slack

We'll make an automation task with Workflow Builder in Slack.
📖 Lean more Workflow Builder

Image description

Create a new workflow.

Workflow steps

Follow this order and set up these settings.

  1. Emoji reaction
  2. Send a form
  3. Add a spreadsheet row
  4. Send a message

1. Emoji reaction

Choose "Emoji reaction" to start this workflow.
Feel free to select it.

Image description

This workflow starts when someone adds the emoji reactions in the channel you've selected.

2. Send a form

Image description

Select "Send a form" and add Questions like this below.

  1. Question: Long answer
  2. Answer: Long answer
  3. URL: Short answer
  4. Tags: Short answer

Image description

Make Question and Answer to be required.

3. Add a spreadsheet row

We can use Google Sheets for Workflow Builder to save and manage messages.

📖 Lean more Google Sheets for Workflow Builder

Image description

Choose "Add a spreadsheet row" from workflow options.

4. Send a message

Create a message to respond to users.

Image description

Let's test the workflow in your slack channel.

Image description

Of course, it's still not possible to post the message from Slack to Notion.

Deploy Google Apps Script

We need to deploy Apps Script to post the message via Google Sheets from Slack to Notion.

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

https://github.com/Kazuki-tam/gas-slack2notion

1. Clone template

Open the repository and click Use this template.

Image description

Clone the repository and install dependencies.

Install Clasp at first if you haven't done it yet.

npm install -g @google/clasp
Enter fullscreen mode Exit fullscreen mode
yarn install
Enter fullscreen mode Exit fullscreen mode

📖 Learn More Clasp

2. Login google account

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

npx 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 your token and database id.

NOTION_TOKEN=<YOUR_NOTION_TOKEN>
DATABASE_ID=<YOUR_DATABASE_ID>
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

To set up an installable trigger, click on the Trigger menu.
Click on it to add a trigger.

Set up these options like this.

Image description

Test workflow

That's all you have to setup to create this project's workflow. Check if it works without problems.

Conclusion

It's really important to share your knowledge and experience in your team and company. I hope this tutorial will help you to enhance your knowledge system.

Top comments (0)