Skip to content

lasuillard/django-slack-tools

Repository files navigation

django-slack-tools

License: MIT CI codecov PyPI - Version

Little helpers working with Slack bot ๐Ÿค– in Django.

This project aims to implementing helpful features making Slack bot and providing reusable Django apps integrated with database.

โœจ Features

Key features are:

  • Reusable Django app for Slack messaging with various messaging backends for different environments
  • Database-backed Slack messaging policies with simple dictionary-based template
  • Message histories
  • Built-in admin for management working with Slack workspace

And more in future roadmap...

  • Celery support for messaging backends, management and shortcut tasks, etc.
  • Django template support
  • New Django apps and helpers for Slack features such as modals, event subscription, etc.

Currently it is focused on messaging features. In future, hoping to bring more helpful features across Slack Bot ecosystem, such as event subscriptions, modals, bot interactions, etc.

๐Ÿš€ Installation

django-slack-tools supports Python 3.8+ and Django 4.2+. Supports for each deps will be dropped as soon as the ends of security updates.

Install the package:

$ pip install django-slack-tools

Add the app to the your Django settings:

INSTALLED_APPS = [
    ...
    "django.contrib.messages", # Used in admin
    "django_slack_tools.slack_messages",
    ...
]

Add configuration for application:

DJANGO_SLACK_TOOLS = {
    # Module path to Slack Bolt application or callable returns the app
    "SLACK_APP": "path.to.your.slack.app",

    # Messaging backend configuration
    "BACKEND": {
        "NAME": "django_slack_tools.slack_messages.backends.SlackBackend",
        "OPTIONS": {
            # TODO(#44): Reasonable defaults to reduce some duplicates
            "slack_app": "path.to.your.slack.app",
        }
    }
}

Then, run the database migration and send messages:

from django_slack_tools.slack_messages.message import slack_message

message = slack_message(
    "I like threading",
    channel="id-of-channel",
    header={"reply_broadcast": True},
)

Please check the documentation for more about details.

๐Ÿ’– Contributing

All contributions and helps are welcome. Please check the CONTRIBUTING.md file for about details.

๐Ÿ“œ License

This project is licensed under the terms of the MIT license.