This is a Discord bot that ports book recommendations from Discord to Notion. Here is a simple diagram to illustrate what the bot does!
This integration works using an unofficial Python SDK for the Notion API, which can be found at notion-sdk-py.
For a more comprehensive explanation about this project, and better set-up instructions, visit this tutorial: Making a Discord bot that talks to Notion.
To test this Discord bot, you will need to set up a few things:
You can duplicate this template for running this example. You need to create a Notion integration as explained in the Notion API documentation here. After doing this, you will obtain a Notion Internal Integration Token and a database ID. Note these down somewhere secure to use later.
Follow the instructions here to create a Discord Bot and add it to your server. Make sure to give the bot permissions to view the channel(s) where book recommendations will be coming in! At the end of this, you will obtain a Discord Bot Token. Note this down too.
Create a GCP project and get your Google Books API credentials by following these instructions.
- Clone this repository locally:
git clone https://github.com/FruitVodka/notion-discord-book-recommendations.git
- Add the credentials from the previous sections to a
.env
file insrc
folder; the file should look like:
DISCORD_TOKEN={discord-bot-token}
DISCORD_GUILD={discord-server-name}
NOTION_TOKEN={notion-integration-token}
DATABASE_ID={notion-database-id}
BOOKS_API_KEY={google-books-api-key}
- Install the requirements in
requirements.txt
by running this command in the project root directory
pip3 install -r requirements.txt
- Run
src/bot.py
- it contains the code that powers this Discord bot - using the command
python3 src/bot.py
!add <book-name>
will look up the book-name on Google Books, and add the best match to the Notion database. If it cannot find a match, it will display a message saying adding failed.!tma >book-name>
will look up the book-name on Google Books, and display the description of the book. Based on this, users can decide whether to add the book to the database using the previous command.
- Notion API Documentation
- notion-sdk-py
- discord.py
- If you want to use your own database instead of using the provided template, you might find this description of the
page object
in Notion useful.
This is a work-in-progress. To contribute, fork this repository and raise a pull request. Feedback and suggestions are welcome, please head to the Discussions section to start a conversation!