Skip to main content

No project description provided

Project description


A simple framework for working with Slack interactivity (


pip install slacktools-interactivity


Register your CommandHandler class with the ComandFactory and when you receive a command request from Slack simply grab the command instance from the factory and execute it.

Basic Usage

Define your command:

from interactivity import CommandFactory, CommandHandler, CommandValidationError

from myproject import get_status, post_status

class StatusCommand(CommandHandler):
    def _validate(self):
        if not get_status(id=self.payload.text):
            raise CommandValidationError("Not a valid id.")

    def _execute(self):

Handle the Slack command request:

from rest_framework.views import APIView
from rest_framework.response import Response

from interactivity import CommandFactory

class CommandsView(APIView):
    def post(self, request):
        handler = CommandFactory.make_handler(
        return Response()

Action Commands

Action commands allow you execute many different actions from a single Slack command. The text following the command is used to determine which action should be performed. The text is split by spaces, the first character set determines the action and the remain character sets are passed to the action as options/parameters.


The below class definitions will handle the following command: /status service api

from interactivity import (

from myproject import post_status_msg

class ServiceStatus(CommandAction):
    def validate(self):
        if len(self.options) == 0:
            CommandValidationError(self.payload, "Missing service name")

    def execute(self):

class StatusCommand(ActionCommandHandler):
    ACTIONS = {
        "service": ServiceStatus


To document


To document

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 slacktools-interactivity, version 1.2.1
Filename, size File type Python version Upload date Hashes
Filename, size slacktools_interactivity-1.2.1-py3-none-any.whl (18.1 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size slacktools-interactivity-1.2.1.tar.gz (10.4 kB) File type Source Python version None Upload date Hashes View

Supported by

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