This Slack Bot fetches publications for authors from Google Scholar and sends notifications to a specified Slack channel or user. Keep your team updated with the latest scholarly articles seamlessly!
- Clone the repository:
git clone https://github.com/costantinoai/scholar-slack-bot.git cd scholar-slack-bot - Install dependencies:
pip install -r requirements.txt
- Edit the config file:
- Add your Slack API token.
- Set the
target_namefield to either a Slack channel (public or private, if the bot is added) or a Slack user (for direct messages). - Refer to the section Setting Up Your Slack Bot below for instructions on obtaining the Slack API token.
- Run the bot:
python main.py
- 🔧 Setting Up The Repo
- 🤖 Setting Up Your Slack Bot
- 🚀 Usage
- 📂 Directory Structure
- 📝 Files Descriptions
- 📄 License
Clone the repository:
git clone https://github.com/costantinoai/scholar-slack-bot.git
cd scholar-slack-botInstall dependencies:
pip install -r requirements.txtEdit slack.config with your bot’s API token and target name:
[slack]
api_token = xoxb-YOUR-API-TOKEN
channel_name = YOUR-TARGET-NAME # Can be a channel (e.g., "general") or a user (e.g., "john_doe")If a Slack channel name (e.g., weekly-papers-update) is provided, the bot will post there.
If a Slack user name is provided (e.g., Andrea Costantino), the bot will send a direct message.
Add author details to src/authors.db.
Legacy JSON caches (authors.json and per-author files under googleapi_cache) are
detected automatically on startup. When present, their contents are imported into
the SQLite databases and the original files are moved to src/obsolete for
archival.
- Go to the Slack API's "Your Apps" page.
- Click Create New App.
- Name your app, select a development workspace, and click Create App.
- In your app's settings, go to Bot Users and click Add a Bot User.
- Name your bot and enable it to be always online.
Slack apps require specific permissions (scopes) to function. Navigate to OAuth & Permissions in your app settings and add these bot token scopes:
channels:read- View public channels in the workspace.chat:write- Send messages to channels and users.groups:read- View private channels where the bot has been added.im:write- Send direct messages to users.mpim:write- Send group direct messages.users:read- View user profiles in the workspace.
- In OAuth & Permissions, find the OAuth Tokens for Your Workspace section.
- Copy the token (starts with
xoxb-). - Save it securely. Never commit this token to a public repository.
- In Slack, navigate to the target channel.
- Click the channel name → Add people & bots.
- Search for your bot’s name and invite it.
The script accepts several command-line arguments (flags) to customize its behavior:
-
--authors_path: Specifies the path to the authors database.- Default:
./src/authors.db
- Default:
-
--slack_config_path: Sets the path to theslack.configfile which contains Slack API token and channel information.- Default:
./src/slack.config
- Default:
-
--verbose: (Optional) Provides verbose output for detailed logging and debugging. -
--test_message: (Optional) Send test message. Do not fetch or save cache. Mutually exclusive with--add_scholar_idand--update_cache.- Example:
python main.py --test_message
- Example:
-
--add_scholar_id: (Optional) Add a new scholar by Google Scholar ID to the file specified in--authors_path, fetch publications and save them to cache (do not send message). Mutually exclusive with--test_messageand--update_cache.- Example:
python main.py --add_scholar_id="YourGoogleScholarID"
- Example:
-
--update_cache: (Optional) Re-fetch and save publications for all authors (do not send message). It overwrites the old cache. Mutually exclusive with--test_messageand--add_scholar_id.- Example:
python main.py --update_cache
- Example:
If running from an IDE (e.g., Spyder, VScode), configurations are set in IDEargs in main.py. Modify paths or debug settings as needed.
A modern Flask web UI is bundled for managing the bot. Launch it with:
python gui.pyThe responsive page at http://localhost:5000 offers:
- Author tools: add/remove authors, refresh or clear their cache.
- Publication browser: view cached papers in a searchable table.
- Settings editor: adjust database locations, Slack config path, and API call delay. Changes are saved to
settings.jsonfor future runs. - Utilities: clear all cache and run the project's tests. Destructive actions prompt for confirmation.
slack-bot
├── add_authors_batch.sh
├── fetch_and_send.sh
├── fetch_scholar.py
├── gui.py
├── helper_funcs.py
├── log_config.py
├── main.py
├── README.md
├── settings.json
├── slack_bot.py
├── streams_funcs.py
└── src
├── authors.db
├── publications.db
└── slack.config
-
add_authors_batch.sh: Bash script for batch-adding authors. -
fetch_and_send.sh: Bash script to run the bot workflow. -
fetch_scholar.py: Internal functions to fetch publications from Google Scholar. -
gui.py: Flask web application for author management and settings. -
helper_funcs.py: Internal utility functions. -
log_config.py: Internal Logging configuration. -
main.py: The main script to run the bot. -
slack_bot.py: Internal functions to format and send messages to Slack. -
streams_funcs.py: Internal, handles workflow logic based on CLI flags. -
authors.db: SQLite database storing author names and Google Scholar IDs. -
publications.db: SQLite database caching publication data. -
slack.config: Configuration file for Slack settings. Example format: -
settings.json: Persistent options used by the GUI (database paths, API delay, etc.).[slack] api_token = xoxb-YOUR-API-TOKEN channel_name = your-channel-or-user
💡 You do not need to specify a channel ID — the bot will automatically determine whether channel_name refers to a public/private channel or a user.
MIT © Andrea Ivan Costantino