Skip to main content

A wonderful, simple, yet powerful and extendable Slack bot framework

Project description

Slack Machine

Join the chat at Slack image image image CI Status image

Slack Machine is a simple, yet powerful and extendable Slack bot framework. More than just a bot, Slack Machine is a framework that helps you develop your Slack workspace into a ChatOps powerhouse. Slack Machine is built with an intuitive plugin system that lets you build bots quickly, but also allows for easy code organization. A plugin can look as simple as this:

from machine.plugins.base import MachineBasePlugin
from machine.plugins.message import Message
from machine.plugins.decorators import respond_to


class DeploymentPlugin(MachineBasePlugin):
    """Deployments"""

    @respond_to(r"deploy (?P<application>\w+) to (?P<environment>\w+)")
    async def deploy(self, msg: Message, application, environment):
        """deploy <application> <environment>: deploy application to target environment"""
        await msg.say(f"Deploying {application} to {environment}")

Breaking Changes

Dropped support for Python 3.8 (v0.38.0)

As of v0.38.0, support for Python 3.8 has been dropped. Python 3.8 has reached end-of-life on 2024-10-07.

Features

  • Get started with mininal configuration
  • Built on top of the Slack Events API for smoothly responding to events in semi real-time. Uses Socket Mode so your bot doesn't need to be exposed to the internet!
  • Support for rich interactions using the Slack Web API
  • High-level API for maximum convenience when building plugins
  • Low-level API for maximum flexibility
  • Built on top of AsyncIO to ensure good performance by handling communication with Slack concurrently

Plugin API features:

  • Listen and respond to any regular expression
  • Respond to Slash Commands
  • Capture parts of messages to use as variables in your functions
  • Respond to messages in channels, groups and direct message conversations
  • Respond with reactions
  • Respond in threads
  • Respond with ephemeral messages
  • Send DMs to any user
  • Support for blocks
  • Support for message attachments [Legacy 🏚]
  • Support for interactive elements
  • Support for modals
  • Listen and respond to any Slack event supported by the Events API
  • Store and retrieve any kind of data in persistent storage (currently Redis, DynamoDB, SQLite and in-memory storage are supported)
  • Schedule actions and messages
  • Emit and listen for events
  • Help texts for Plugins

Coming Soon

  • Support for shortcuts
  • ... and much more

Installation

You can add Slack Machine to your uv project by running:

uv add slack-machine

or add it to your Poetry project:

poetry add slack-machine

Lastly, you can install it using pip (not recommended):

$ pip install slack-machine

It is strongly recommended that you install slack-machine inside a virtual environment!

Usage

  1. Create a directory for your Slack Machine bot: mkdir my-slack-bot && cd my-slack-bot

  2. Add a local_settings.py file to your bot directory: touch local_settings.py

  3. Create a new app in Slack: https://api.slack.com/apps

  4. Choose to create an app from an App manifest

  5. Copy/paste the following manifest: manifest.yaml

  6. Add the Slack App and Bot tokens to your local_settings.py like this:

    SLACK_APP_TOKEN = "xapp-my-app-token"
    SLACK_BOT_TOKEN = "xoxb-my-bot-token"
    
  7. Start the bot with slack-machine

  8. ...

  9. Profit!

Documentation

You can find the documentation for Slack Machine here: https://dondebonair.github.io/slack-machine/

Go read it to learn how to properly configure Slack Machine, write plugins, and more!

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

slack_machine-0.40.0.tar.gz (319.9 kB view details)

Uploaded Source

Built Distribution

slack_machine-0.40.0-py3-none-any.whl (62.1 kB view details)

Uploaded Python 3

File details

Details for the file slack_machine-0.40.0.tar.gz.

File metadata

  • Download URL: slack_machine-0.40.0.tar.gz
  • Upload date:
  • Size: 319.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.4

File hashes

Hashes for slack_machine-0.40.0.tar.gz
Algorithm Hash digest
SHA256 3cbe5fb01309b89d933857d3b88d2e3e93f38d0a8953040f27b4b3c302a59c9f
MD5 b8e28011f9c38020ee19f984be343845
BLAKE2b-256 b0757e8dbfdc043f55bf9e0edcc1bedff6049fd86df310f2b2489c493c9c7de4

See more details on using hashes here.

File details

Details for the file slack_machine-0.40.0-py3-none-any.whl.

File metadata

File hashes

Hashes for slack_machine-0.40.0-py3-none-any.whl
Algorithm Hash digest
SHA256 304458b7aa370030c351530557a0626d68aaf1fdfc16d20eeecdd41b4196eb0e
MD5 e05346dc116af4e340af6f6e73424718
BLAKE2b-256 fd17024dfa5a875554d195d7823cf30fbef6076087f5c6d7b4ca87add1c222ba

See more details on using hashes here.

Supported by

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