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
h) Google Drive setup: All physical files or pdf files from links are downloaded on a google drive folder of your choice.
Setup Procedure:
a) Follow the README file located here
b) Move the credentials.json
file and token.json
to the creds
folder in the Bot folder
c) Now go to google drive and create a folder. The link of folder will be something like this https://drive.google.com/drive/folders/ID
d) Note the ID down. This will be the id of the folder where all files will be stored. Also share the folder accordingly
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 GDRIVE_FOLDER=<FOLDER ID YOU NOTED ABOVE>
$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>
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:
/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:
/search <Tag1>
For multiple tags: /search <Tag1> <Tag2>.....<TagN>
/delete <Tag 1>
For multiple tags: /delete <Tag 1> <Tag2>......<Tag N>
NOTE: In the below images the prefix used is: !
You can upload any file to the notion database. It can be a pdf, png, jpeg etc.
Here a png file is being uploaded
a) Drag your file to the chat in discord
b) Add comment to the file you uploaded
Here memoji and profile-pic are tags for the file
c) It will then ask the title of the file you uploaded:
d) Now the file will uploaded on the google drive folder which you mentioned above
e) The database will be updated:
f) The link will open the file in google drive
Instead of running the discord bot via python and exporting environment variables you can use our docker container.
Link to image: Docker Hub
You can also deploy this on heroku. Please follow the additional instructions here: Heroku Setup