A discord bot consuming Notion API to add, retrieve data to Notion databases.

Overview

Notion-DiscordBot

Build StatusVisits Badge

A discord bot consuming Notion API to add and retrieve data from Notion databases.




Instructions to use the bot:

Pre-Requisites:

a)Install all the requirements using pip3 install -r requirements.txt

b)Create a discord bot using the developer platform of discord and obtain your OAuth2 token. Keep it somewhere safe

c)Go to Notion and create a new Integration https://www.notion.so/my-integrations Note the internal Integration.

d)Go to Notion and create a table like this:

4 columns where:

  • Contributor is of property type Title
  • URL of url type
  • Title of text type
  • Tag of multi-select type

e)Click on the three dots and press Open as page


f)Then press share and copy the URL. The URL will look something like this: https://www.notion.so/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX?v=YYYYYYYYYYYYYYYYYYYYYYYYY

Note down the X part of the url (RED part)

This is your database id

g)Also press share again, press Invite and then click on the integration you made earlier

f)Now on the terminal of your machine:

$export DATABASE_TOKEN=<THE DATABASE TOKEN YOU NOTED DOWN>

$export AUTH_KEY=<THE INTEGRATION SECRET KEY FROM NOTION>

$export DISCORD_AUTH=<THE SECRET TOKEN OF BOT>
If you want your prefix to be something else other than '/' then $export PREFIX=<Your Desired character>

Running Procedure:

a)Now simply go into the Bot folder and run: $python3 bot.py

b)On the discord developer site copy the OAuth2 link and paste it in the browser and invite it to a server you own/have permissions to do so

c)Bot Usage:

Adding Record:

/add <URL_YOU_WANT_TO_RECORD> => This will add a new record to your database with a misc tag

/add <URL_YOU_WANT_TO_RECORD> <TAG> => This will add a new record to your database with the <TAG> tag

For multiple tags:

/add <URL_YOU_WANT_TO_RECORD> <TAG>,<TAG1>,<TAG2>
Example:

Sample database populated by the bot:

Searching Record through tags:

/search <Tag1>

For multiple tags: /search <Tag1> <Tag2>.....<TagN>

Example:

Deleting Record through tags:

/delete <Tag 1>

For multiple tags: /delete <Tag 1> <Tag2>......<Tag N>

Example:
Intial database:

Deleting Record:

Final Database:

Instead of running the discord bot via python and exporting environment variables you can use our docker container.

Link to image: Docker Hub

Comments
  • New setup - Prefix not working

    New setup - Prefix not working

    Hi,

    First of all thanks for your hard work. However I recently updated my docker image and since then it has been really hard to run the bot, (old docker compose below). I just saw there is a new setup command that can be run from discord, so I guess no need to use DATABASE_TOKEN and AUTH_KEY as environment variables anymore. So I removed them from my docker compose and then the annoying stuff happened. Every time I restart my container I have to run the setup command, the prefix does not work I have to use * everywhere instead of !. ( See screen attached below). I would personally prefer the notion's integration app as environment variable that is probably more secure than discord. Maybe in the future it could be prompted only when the user does not provide it as env 🤷‍♂️.

    Thanks for your time, and hope you will be able to fix those issues and update the README file.

    Regards

    ---
    version: "3.4"
    
    services:
      notiondiscordbot:
        image: servatom/notiondiscordbot
        container_name: notiondiscordbot
        restart: unless-stopped
        environment:
          - PUID=1000 
          - PGID=1000 
          - TZ=Europe/Paris
          - DATABASE_TOKEN=...  # Can be removed
          - AUTH_KEY=...               # Can be removed
          - DISCORD_AUTH=...      # Need to be change to TOKEN
          - GDRIVE_FOLDER=...
          - PREFIX=!
        volumes:
          - /user/docker/notion-data:/Bot/creds
        security_opt:
          - no-new-privileges:true
    
    prefix-bug
    opened by faceslog 5
  • Error when adding an item to the db

    Error when adding an item to the db

    Hi I just tried to install properly the bot via docker / and in a local env but I'm getting the same error everytime I run the add cmd:

    Ignoring exception in command add:
    Traceback (most recent call last):
      File "/home/user/.local/lib/python3.7/site-packages/discord/ext/commands/core.py", line 85, in wrapped
        ret = await coro(*args, **kwargs)
      File "bot.py", line 36, in add
        if((doesItExist(url) == False) and (amIThere(url) == False)):
      File "/home/user/notion/Notion-DiscordBot/Bot/duplicateCheck.py", line 31, in amIThere
        with open("./Bot/dataUploaded.txt") as log:
    FileNotFoundError: [Errno 2] No such file or directory: './Bot/dataUploaded.txt'
    

    I decided to remove the "Bot/" in line 31 in Bot/duplicateCheck.py
    I replaced with open("./Bot/dataUploaded.txt") as log: to with open("./dataUploaded.txt") as log: and now everything is working fine.

    Regards

    opened by faceslog 4
  • Persistent Storage for docker containers

    Persistent Storage for docker containers

    To prevent duplication of pdf links the file tracker dataUploaded.txt was created that keeps of links. But after restarting the container the file becomes clean. To prevent this, the txt file must be in a persistent volume.

    bug docker 
    opened by raghavTinker 1
  • Eliminated the need of temporary storage of guild data in json file

    Eliminated the need of temporary storage of guild data in json file

    In the current setup, we were storing the guild data in the JSON file to reduce the number of database interactions from each cog. But the issue still was there whereafter any change in the database there were still some extra file operations to be done where the JSON file was updated and each cog had to read the data of the JSON file. Now we are going to store the guild data inside an attribute of the bot object. This will reduce the number of I/O interactions and will make the bot much more faster when dealing with multiple requests across multiple servers

    opened by raghavTinker 0
  • Notion Version 2

    Notion Version 2

    A centrally hosted notion discord bot...which can manage multiple notion databases across multiple different discord servers. The previous version required multiple instances of the bot to run on multiple servers/notion databases. This version eliminates the need for personally hosting the bot.

    After adding the bot to your server just run the *setup command and follow the instructions For changing the prefix run: *prefix

    For more information refer: README.md

    opened by raghavTinker 0
  • Bump certifi from 2021.10.8 to 2022.12.7

    Bump certifi from 2021.10.8 to 2022.12.7

    Bumps certifi from 2021.10.8 to 2022.12.7.

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • [Feature Request] A switch command to add data continuously when switch is on

    [Feature Request] A switch command to add data continuously when switch is on

    As suggested with @daemon1024.

    Idea

    /saveurl on
    
    From here on whatever URLs are shared the links are kept in the database. Yeah will need to clean up 
    things regularly, but still would be convenient 
    

    Things that can be implemented

    • [ ] A switch command to switch on the bot to listen on a particular server/channel every time.
    • [ ] Delete command to delete previous messages containing links.
    opened by animesh-007 1
  • Create tests for the bot

    Create tests for the bot

    Create simple tests for the bot. Mainly to verify the API calls that are going to Notion. This is to make the Travis-ci integration useful. This will also let us know if something changed in the Notion API

    opened by raghavTinker 0
Linky bot, A open-source discord bot that allows you to add links to ur website, youtube url, etc for the people all around discord to see!

LinkyBot Linky bot, An open-source discord bot that allows you to add links to ur website, youtube url, etc for the people all around discord to see!

AlexyDaCoder 1 Sep 20, 2022
Framework to make using Bottle less time-consuming and easier

A class for the Bottle API to reduce clutter and difficulty while creating a website.

Tygzy 0 Dec 26, 2022
A Python API to retrieve and read MLB GameDay data

mlbgame mlbgame is a Python API to retrieve and read MLB GameDay data. mlbgame works with real time data, getting information as games are being playe

Zach Panzarino 493 Dec 13, 2022
A simple, fast, and awesome discord nuke bot! The only thing you need to add is your bot token.

SimpleNukeBot A simple, fast, and awesome discord nuke bot! The only thing you need to add is your bot token. Instructions: All you need to do is crea

Bisc 1 Apr 18, 2022
Satoshi is a discord bot template in python using discord.py that allow you to track some live crypto prices with your own discord bot.

Satoshi ~ DiscordCryptoBot Satoshi is a simple python discord bot using discord.py that allow you to track your favorites cryptos prices with your own

Théo 2 Sep 15, 2022
API to retrieve the number of grades on the OGE website (Website listing the grades of students) to know if a new grade is available. If a new grade has been entered, the program sends a notification e-mail with the subject.

OGE-ESIREM-API Introduction API to retrieve the number of grades on the OGE website (Website listing the grades of students) to know if a new grade is

Benjamin Milhet 5 Apr 27, 2022
Discord RPC for Notion written in Python

Discord RPC for Notion This is a program that allows you to add your Notion workspace activities to your Discord profile. This project is currently un

Thuliumitation 1 Feb 10, 2022
IMDbPY is a Python package useful to retrieve and manage the data of the IMDb movie database about movies, people, characters and companies

IMDbPY is a Python package for retrieving and managing the data of the IMDb movie database about movies, people and companies. Revamp notice Starting

Davide Alberani 1.1k Jan 2, 2023
Cytotron - A unique discord bot like never before. Add it to your server to keep it active, motiviated, and amazing!!

Cytotron - Take your server to the next level Most of the details are in the website. Go to https://cytotron-bot.gq for more information. If that link

LeviathanProgramming 6 Jun 13, 2021
Unofficial Python API client for Notion.so

notion-py Unofficial Python 3 client for Notion.so API v3. Object-oriented interface (mapping database tables to Python classes/attributes) Automatic

Jamie Alexandre 3.9k Jan 3, 2023
A small repository with convenience functions for working with the Notion API.

Welcome! Within this respository are a few convenience functions to assist with the pulling and pushing of data from the Notion API.

null 10 Jul 9, 2022
Notion API Database Python Implementation

Python Notion Database Notion API Database Python Implementation created only by database from the official Notion API. Installing / Getting started p

minwook 78 Dec 19, 2022
Python 3 tools for interacting with Notion API

NotionDB Python 3 tools for interacting with Notion API: API client Relational database wrapper Installation pip install notiondb API client from noti

Viet Hoang 14 Nov 24, 2022
It's a Discord bot to control your PC using your Discord Channel or using Reco: Discord PC Remote Controller App.

Reco PC Server Reco PC Server is a cross platform PC Controller Discord Bot which is a modified and improved version of Chimera for Reco-Discord PC Re

Arvinth Krishna 12 Aug 31, 2022
A small and fun Discord Bot that is written in Python and discord-interactions (with discord.py)

Articuno (discord-interactions) A small and fun Discord Bot that is written in Python and discord-interactions (with discord.py) Get started If you wa

Blue 8 Dec 26, 2022
Discord bot script for sending multiple media files to a discord channel according to discord limitations.

Discord Bulk Image Sending Bot Send bulk images to Discord channel. This is a bot script that will allow you to send multiple images to Discord channe

Nikola Arbov 1 Jan 13, 2022
🚀 An asynchronous python API wrapper meant to replace discord.py - Snappy discord api wrapper written with aiohttp & websockets

Pincer An asynchronous python API wrapper meant to replace discord.py ❗ The package is currently within the planning phase ?? Links |Join the discord

Pincer 125 Dec 26, 2022
Retrieve information from DBLP and update BibTex files automatically

Rebib TLDR: This script retrieves information from DBLP to update your BibTex files. python rebib.py --bibfile xxx.bib It first parses the bib entries

Shangtong Zhang 49 Jan 1, 2023
VALORANT rank yoinker lets you retrieve the ranks and basic informations of everyone in the lobby, regardless of gamemode.

vRY VALORANT rank yoinker Retrieve the rank and basic information of everyone in the lobby, regardless of gamemode. Table of Contents Terms of Use Abo

Isaac Kenyon 270 Dec 30, 2022