Skip to content

Repository files navigation

Notion2Discord (N2D)

Made with 💖 by Benjamin Herrera

N2D is a simple to use script that sends messages to a Discord channel for every new update to the items in your Notion database!

For any questions, please contact me via Discord at @bherrera or email at b10@asu.edu

👀 Preview

What it looks like on Notion

Alt text

What it looks like on Discord

Alt text

What it looks like on Discord with vertically stacked attributes

Alt text

📚 Dependencies

  1. Any Linux Distribution
  2. Docker (if not using in-house python packages)
  3. Miniconda (if not using Docker)

📝 Setup Guide

This is going to be tedious, but bare with me! 😉👍

  1. Git clone this repo
git clone https://github.com/BenjaminHerrera/Notion2Discord.git
  1. Create a .env file in the ./ directory. It should have the following contents:
NOTION_INTEGRATION_TOKEN="..."
NOTION_DATABASE_ID="..."
DISCORD_WEBHOOK_URL="..."
  1. Go to your Notion integration page >> New Integration >> Enter name for integration >> Submit >> Copy Internal Integration Secret >> Paste it as a value for the NOTION_INTEGRATION_TOKEN variable in your .env file.
  2. Go to your database on Notion >> Click on the three dots on the top right of the page >> Add connections >> Select integration that you made.
  3. Copy the database's link and extract the substring <hash_1> from this format:
https://www.notion.so/<hash_1>?v=<hash_2>
  1. Place this substring as a value for the NOTION_DATABASE_ID variable in your .env file.
  2. Click on the gear icon next discord channel name >> Integrations >> Webhooks >> New Webhook >> Click on new webhook >> Copy Webhook URL >> Paste the URL into the value section of the DISCORD_WEBHOOK_URL variable in your .env file.
  3. Hard part's done 🎉🎉🎉! Now that you have your .env created, check the Run Guide on how to run the project.

🏃‍♂️ Run Guide

If you want to use 🐳 DOCKER (preferred)

NOTE: To update the frequency, editor the MINUTES arguments value in ./docker-compose.yml. Default is at 15 minutes.

  1. docker compose up -d --build

If you want to use 🐍 PYTHON with ⏳ CRONTAB and 🧰 MINICONDA

NOTE: Installation requires repeat frequency in minutes. Replace X with your preferred repeat frequency.

  1. bash ./install_crontab.sh X

If you want to use 🐍 PYTHON with no repeat

  1. cd notion2discord
  2. pip install -r requirements.txt
  3. python main.py

📜 Configuration Documentation

Configuration for the application can be found in ./notion2discord/config/config.json

  • logo : string - Image URL to customize your webhook sender
  • name : string - Name of the webhook sender
  • color : int - Color of the embed messages. Use this to find decimal value representation of your preferred color.
  • inline_attributes : boolean - True to have everything fill from left to right. False if you want them to be in a straight column
  • datetime_format_with_time : string - Time formatter for dates with times. This is used for date attributes in Notion DB items with time specified. Use this to help you create your desired format string
  • datetime_format_without_time : string - Time formatter for dates without times. This is used for date attributes in Notion DB items with NO time specified. Use this to help you create your desired format string.
  • dispatch_limit : int or None - Limit how much can be dispatched to your Discord text channel.
  • empty_value : string - Standard format for values that are empty
  • checkbox_true : string or Emoji - Value to show if checkboxes are filled
  • checkbox_false : string or Emoji - Value to show if checkboxes are NOT filled
  • debug_mode : boolean - Either turn on or turn off debugging outputs
  • last_update_offset : int - Sometimes, timings can be finicky. Accounts for lag from Notion and your server's end. Use this value to get items that have been edited 60 seconds plus last_update_offset seconds amount of time.

🙋‍♂️ FAQ

  • Q: How does it work? 🤔
    • A: The script works by checking to see if a Notion item was changed after the last check. The script leverages crontab to check your every now and then.
  • Q: Why use crontab? ⏳❓
    • A: crontab is more efficient than using a while true loop or a scheduler inside Python. This project is designed to be easy to use and lightweight on resource utilization. You can dynamically control the refresh rate without stopping the system.
  • Q: I noticed a bug/issue. How do I report it? 🚨
    • A: Please go to the issues page and create a new issue there. When you create an issue, there will be steps on how to communicate them. Thanks in advance!

About

A automatic script that deploys messages based on new updates on your Notion Databases

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages