Skip to main content

A bot for Slack

Project description

PyBites Karmabot - A Python based Slack Chatbot

Tests Black pre-commit BCH compliance codecov

A Python based Slack Chatbot for Community interaction


Karmabot's main features is the management of Karma within the slack community server. You can give karma, reduce karma, check your current karma points and manage your karma related username.

karma example

Additional commands / features are:

  • Jokes powered by PyJokes
  • Overview on top channels of the slack server
  • Random Python tip, quote or nugget from
  • Browse and search python documentation, "pydoc help"


pip install karmabot

Basic Usage

After installing you can start karmabot by using the command


However, you need to supply some settings prior to this.


By default we will look for a .karmabot file in the directory you used the karmabot command. The file should supply the following information.

  • KARMABOT_SLACK_USER The bot's slack user id. Once you've created your own Karmabot app, you can view its configuration details from the My Apps page. The user ID shows up under Basic Information --> App Credentials --> App ID.

  • KARMABOT_SLACK_TOKEN The auth token for your bot. You can find the token from the My Apps page for your Karmabot under OAuth & Permissions --> Tokens for Your Workspace --> Bot User OAuth Access Token. It starts with xoxb-.

  • KARMABOT_SLACK_INVITE_USER_TOKEN An invite token to invite the bot to new channels. Bots cannot autojoin channels, but we implemented an invite procedure for this.

  • KARMABOT_DATABASE_URL The database url which should be compatible with SqlAlchemy. For the provided docker file use postgres://user42:pw42@localhost:5432/karmabot.

    • Note: To start the provided Docker-based Postgres server, be sure you have Docker Compose installed and run docker-compose up from the karmabot directory.
  • KARMABOT_GENERAL_CHANNEL The channel id of your main channel slack

  • KARMABOT_ADMINS The slack user ids of the users that should have admin command access separated by commas.

If you do not want to use a file you have to provide environment variables with the above names. If no file is present we default to environment variables.

Development pattern for contributors

We use poetry and pyproject.toml for managing packages, dependencies and some settings.

Setup virtual environment for development

You should follow the instructions to get poetry up and running for your system. We recommend to use a UNIX-based development system (Linux, Mac, WSL). After setting up poetry you can use poetry install within the project folder to install all dependencies.

The poetry virtual environment should be available in the the project folder as .venv folder as specified in poetry.toml. This helps with .venv detection in IDEs.

Testing and linting

For testing you need to install nox separately from the project venv created by poetry. For testing just use the nox command within the project folder. You can run all the nox sessions separately if need, e.g.,

  • only linting nox -rs lint
  • only testing nox -rs tests

For different sessions see the file. You can run nox --list to see a list of all available sessions.

Please make sure all tests and checks pass before opening pull requests!


To ensure consistency you can use pre-commit. pip install pre-commit and after cloning the karmabot repo run pre-commit install within the project folder.

This will enable pre-commit hooks for checking before every commit.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for karmabot, version 1.2
Filename, size File type Python version Upload date Hashes
Filename, size karmabot-1.2.tar.gz (20.4 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page