Skip to content

Using Slack Machine

Once you have installed Slack Machine, configuring and starting your bot is easy:

  1. Create a directory for your Slack Machine bot: mkdir my-slack-bot && cd my-slack-bot
  2. Add a file to your bot directory: touch
  3. Create a new app in Slack:
  4. Choose to create an app from an App manifest
  5. Copy/paste the following manifest:

      name: Slack Machine
        display_name: Slack Machine
        always_online: false
          - app_mentions:read
          - channels:history
          - channels:join
          - channels:read
          - chat:write
          - chat:write.public
          - emoji:read
          - groups:history
          - groups:read
          - groups:write
          - im:history
          - im:read
          - im:write
          - mpim:history
          - mpim:read
          - mpim:write
          - pins:read
          - pins:write
          - reactions:read
          - reactions:write
          - users:read
          - channels:manage
          - chat:write.customize
          - dnd:read
          - files:read
          - files:write
          - links:read
          - links:write
          - metadata.message:read
          - usergroups:read
          - usergroups:write
          - users.profile:read
          - users:write
          - app_mention
          - channel_archive
          - channel_created
          - channel_deleted
          - channel_id_changed
          - channel_left
          - channel_rename
          - channel_unarchive
          - group_archive
          - group_deleted
          - group_left
          - group_rename
          - group_unarchive
          - member_joined_channel
          - member_left_channel
          - message.channels
          - message.groups
          - message.mpim
          - reaction_added
          - reaction_removed
          - team_join
          - user_change
          - user_profile_changed
          - user_status_changed
        is_enabled: true
      org_deploy_enabled: false
      socket_mode_enabled: true
      token_rotation_enabled: false
  6. Add the Slack App and Bot tokens to your 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!

Configuring Slack Machine

All the configuration for your bot lives in the in the root of your bot directory. The core of Slack Machine, and the most of the built-in plugins, only need a SLACK_APP_TOKEN and SLACK_BOT_TOKEN to function.

You can override the log level by setting LOGLEVEL. By default this is set to "ERROR".

If you want to use Slack Machine behind a proxy, you can set HTTP_PROXY.

Using environment variables for configuration

For some configuration, it can be a security consideration not to store them in your source code (i.e. Slack Machine allows you to provide any setting - both built-in and for plugins - as environment variables. This is done by prefixing the setting name with SM_. Example: SM_SLACK_APP_TOKEN and SM_SLACK_BOT_TOKEN as environment variable can be used to set the SLACK_APP_TOKEN and SLACK_BOT_TOKEN settings instead of having to put it in the

This way you can follow the 12 Factor app best practices to configure your bot!

Setting aliases

The ALIASES configuration setting allows the bot to respond to a trigger symbol instead of a direct @botname.


If ALIASES='!,%' was set in then the bot would respond to the following phrases:

@botname release the hounds
!release the hounds
%release the hounds

Enabling plugins

Slack Machine comes with a few simple built-in plugins:

  • HelloPlugin: responds in kind when users greet the bot with "hello" or "hi" (only when the bot is mentioned)
  • PingPongPlugin: responds to "ping" with "pong" and vice versa (listens regardless of mention)
  • EchoPlugin: replies to any message the bot hears, with exactly the same message. The bot will reply to the same channel the original message was heard in
  • HelpPlugin: responds to "help" with a list of all available commands and how they work. You can use "robot help" to learn the regexes that are used to match commands.
  • MemePlugin: lets the user generate memes based on templates and captions Uses Memegen
  • ImageSearchPlugin: lets users search images and gifs using Google Custom Search (requires setting up a Programmable Search Engine in Google and adding the search engine id as GOOGLE_CSE_ID and a Google API key as GOOGLE_API_KEY)
  • RBACPlugin: lets admins assign, revoke and list user roles. Is used when you want to protect commands

By default, HelloPlugin and PingPongPlugin are enabled.

You can specify which plugins Slack Machine should load, by setting the PLUGINS variable in to a list of fully qualified classes or modules that contain plugins. You can either point to a plugin class directly, or to a module containing one or more plugins.

For example, to enable most of the built-in Slack Machine plugins, your would look like this:

SLACK_APP_TOKEN = "xapp-my-app-token"
SLACK_BOT_TOKEN = "xoxb-my-bot-token"

Or is you want import them by the modules they're in:

SLACK_APP_TOKEN = "xapp-my-app-token"
SLACK_BOT_TOKEN = "xoxb-my-bot-token"

Slack Machine can load any plugin that is on the Python path. This means you can load any plugin that is installed in the same virtual environment you installed Slack Machine in. And as a convenience, Slack Machine will also add the directory you start Slack Machine from, to your Python path.

Choosing storage

Slack Machine provides persistent storage, which can be used by plugins to store data of any kind. Slack Machine supports different backends for storage, so you can choose one that best fits your needs and existing infrastructure. You can configure which backend to use, by setting the STORAGE_BACKEND variable in to the fully qualified class of the chosen storage backend.

Out of the box, Slack Machine provides 3 options for storage backend:

in-memory (default):

This backend will store all data in-memory, which is great for testing because it doesn't have any external dependencies. Does not persist data between restarts



This backend stores data in Redis. Redis is a very fast key-value store that is super easy to install and operate. This backend is recommended, because it will persist data between restarts. The Redis backend requires you to provide a URL to your Redis instance by setting the REDIS_URL variable in The URL should have the following format:


Where db is optional and sets the database number (0 by default)

Optional parameters:

  • REDIS_MAX_CONNECTIONS: maximum number of connections Slack Machine can make to your Redis instance
  • REDIS_KEY_PREFIX: the prefix Slack Machine uses for keys (SM by default, so "key1" gets stored under SM:key1)



This backend stores data in DynamoDB. DynamoDB is a managed NoSQL datastore on AWS that, among other things, allows for easy persistance of objects by key. The DynamoDB backend requires either a set of valid AWS account credentials, or a locally running DynamoDB test bed, such as the one included in localstack. This backend requires the environment variables or path-based AWS credentials that are normally used to access AWS services. The following are optional parameters that can be set in your or SM_ environment variable slack-machine settings:

Optional parameters:

  • DYNAMODB_ENDPOINT_URL: specifies an optional alternate endpoint, for local bot testing
  • DYNAMODB_KEY_PREFIX: an optional prefix to use within the key lookup. Defaults to SM:
  • DYNAMODB_TABLE_NAME: specifies the table to use in DynamoDB. Defaults to slack-machine-state
  • DYNAMODB_CREATE_TABLE: optionally -create- the table to be used in DynamoDB. Defaults to False
  • DYNAMODB_CLIENT: if custom configuration is needed for the DynamoDB client, an optional aioboto3 resource can be specified here


So if, for example, you want to configure Slack Machine to use Redis as a storage backend, with your Redis instance running on localhost on the default port, you would add this to your

REDIS_URL = redis://localhost:6379'

That's all there is to it!