Skip to main content

Little helpers for working with Slack bots 🤖 in Django.

Project description

django-slack-tools

License: MIT codecov PyPI - Version

Little helpers for working with Slack bots 🤖 in Django.

This project aims to implement helpful features for Slack bots and to provide reusable Django apps with database integration.

✨ Features

  • Reusable Django app for Slack messaging with various messaging backends for different environments
  • Database-backed Slack messaging policies with simple dictionary-based templates
  • Message histories
  • Built-in admin for managing Slack workspace integrations
  • Celery support for messaging backends, management tasks, and shortcut workflows
  • Django template support

And more on the future roadmap...

  • New Django apps and helpers for Slack features such as modals, event subscriptions, etc.
  • Better templating experience
  • A more complete working example with richer documentation

Currently it is focused on messaging features. In the future, we hope to add more helpful Slack bot features across the ecosystem, such as event subscriptions, modals, and bot interactions.

🚀 Quick start

[!WARNING] This project is still in early development and not recommended for production use.

Install the package:

$ pip install django-slack-tools

Add the app to your Django settings:

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

Add configuration for the application (the Slack app should already be configured):

DJANGO_SLACK_TOOLS = {
    "slack_app": "<module.path.to.your-slack-app>",
    "messengers": {
        "default": {
            "class": "django_slack_tools.messenger.shortcuts.Messenger",
            "kwargs": {
                "template_loaders": [
                    "django_slack_tools.slack_messages.messenger.DjangoTemplateLoader",
                ],
                "middlewares": [],
                "messaging_backend": {
                    "class": "django_slack_tools.messenger.shortcuts.SlackBackend",
                    "kwargs": {
                        "slack_app": "<module.path.to.your-slack-app>",
                    },
                },
            },
        },
    }
}

Then run the database migration and create a greet.xml file in your templates/ directory:

<root>
    <block type="section">
        <text type="mrkdwn">
            {{ greet }}
        </text>
    </block>
</root>

Send a message:

from django_slack_tools.slack_messages.shortcuts import slack_message

message = slack_message(
    "<channel-id>",
    template="greet.xml",
    context={"greet": "Hello, World!"},
)

Please check the documentation for more examples and details.

💖 Contributing

All contributions and help are welcome. Please check the CONTRIBUTING.md file for contribution guides.

📜 License

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

Project details


Download files

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

Source Distribution

django_slack_tools-0.4.2.tar.gz (1.1 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_slack_tools-0.4.2-py3-none-any.whl (50.3 kB view details)

Uploaded Python 3

File details

Details for the file django_slack_tools-0.4.2.tar.gz.

File metadata

  • Download URL: django_slack_tools-0.4.2.tar.gz
  • Upload date:
  • Size: 1.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for django_slack_tools-0.4.2.tar.gz
Algorithm Hash digest
SHA256 110377eb5f152cee5ae2ffc7a96f3fd2db1d5d3980f16b3dd4baf51c8ed9659f
MD5 372c9af36353706b772492019c2e187a
BLAKE2b-256 5a40af16deace345419e9a46dc155dbc71955815e8c55edfb6a68095b13d60fa

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_slack_tools-0.4.2.tar.gz:

Publisher: release.yaml on lasuillard-s/django-slack-tools

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_slack_tools-0.4.2-py3-none-any.whl.

File metadata

File hashes

Hashes for django_slack_tools-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4e139523c89e3eaaf81a75c0fda980cf9f1abe982c284e41639c10c065024423
MD5 f0147a70784666585863714bb3cace4a
BLAKE2b-256 48f284570dc8006063c46fcec707b50b45be483931ba8ca4875584c3681caf3e

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_slack_tools-0.4.2-py3-none-any.whl:

Publisher: release.yaml on lasuillard-s/django-slack-tools

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page