Skip to main content

Django Slack Integration

This application helps you to integrate your existing Django application with Slack.

It provides you with

  • Models - needed to keep information from Slack API
  • Decorators - help you to write implementation of your Slack endpoints
  • Authorisation backend - allows you to pair your existing user model with your Slack users
  • Views - OAuth callbacks for "Add To Slack" and "Login With Slack" actions

Installation

  1. Add 'slack_app' to your INSTALLED_APPS setting like this:

    INSTALLED_APPS = [
        ...
        'slack_app',
        ...
    ]
    
  2. Include the urls in your project urls.py like this:

    path('slack/', include('slack_app.urls')),
    
  3. Run python manage.py migrate to create the slack_app models.

  4. Add slack_app.auth_backends.SlackAuthenticationBackend to your AUTHENTICATION_BACKENDS

    AUTHENTICATION_BACKENDS = [
        'django.contrib.auth.backends.ModelBackend',
        'slack_app.auth_backends.SlackAuthenticationBackend',
    ]
    
  5. Update your settings.py

    SLACK_CLIENT_ID=""
    SLACK_CLIENT_SECRET=""
    SLACK_SIGNING_SECRET=""
    
    SLACK_LOGIN_OAUTH_REDIRECT_URL=""
    SLACK_INSTALL_OAUTH_REDIRECT_URL=""
    
  6. Add following URLs to your Slack app's Redirect URLs (OAuth & Permissions)

    <your_host>/slack/oauthcallback/
    <your_host>/slack/login/
    
  7. (Optional) Put <your_host>/slack/interactivity/ as your Request URL in Interactive Components section

  8. (Optional) Configure your Slash commands's Request URL as <your_host>/slack/commands/<command_name>/

Usage

Slack commands

If you want to create a new Slack command with name /example, configure your Request URL as <your_host>/slack/commands/example/ and put the following code into slack.py inside your app's directory.

@slack_command('example', require_linked_account=True)
def scrumie_staging_command(request, slack_user_mapping, slack_workspace):
    print(slack_user_mapping, slack_workspace)
    return JsonResponse({
        "blocks": [
            {
                "type": "section",
                "text": {
                    "type": "mrkdwn",
                    "text": "Hello _world_"
                },
            }
        ],
        "text": "Hello World"
    })

Slack Interactivity

Put the following to your slack.py inside your app's directory.

@slack_interactivity('block_actions')
def process_block_actions(payload):
    print('>>>>', payload)
    return HttpResponse()

Metadata

Release files for django-slack-app 1.0.40

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-slack-app 1.0.40
File Size Uploaded Provenance Actions
django-slack-app-1.0.40.tar.gz 11.3 kB Without provenance Details for django-slack-app-1.0.40.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-slack-app 1.0.40
File Interpreter ABI Platform Actions
django_slack_app-1.0.40-py3-none-any.whl Python 3 none any Details for django_slack_app-1.0.40-py3-none-any.whl

Total release size: 26.6 kB

Release files / django-slack-app-1.0.40.tar.gz

Download URL django-slack-app-1.0.40.tar.gz
Size 11.3 kB
Tags Source
SHA-256 checksum
How to use checksums
6b0aa97715171b229f1db6d5894ac0b93923fe91b73b41db90421315afc7ad21
BLAKE2b-256 checksum
How to use checksums
90cbacdac7ecbb79f376fded591333ecafaf100eb2fbaae08edc54445e008e46
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2

Release files / django_slack_app-1.0.40-py3-none-any.whl

Download URL django_slack_app-1.0.40-py3-none-any.whl
Size 15.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
44d8995396756c1ecdf373efb23adfbf6f4b337768d88dcbe3d02bfd2e964e80
BLAKE2b-256 checksum
How to use checksums
bfd99caa2fe57a3e4a732d57980dd9be4876a7f789ed723215bc7324048853d9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2

Security for django-slack-app 1.0.40

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page