Skip to content

feat: Add SLACK_ALLOW_BOTS env var (parity with Discord's DISCORD_ALLOW_BOTS) #3198

@irispillars

Description

@irispillars

Problem

The Slack adapter unconditionally drops all bot messages at line 631 of gateway/platforms/slack.py:

# Ignore bot messages (including our own)
if event.get("bot_id") or event.get("subtype") == "bot_message":
    return

There is no configuration option to override this behavior. This means bot-to-bot communication is impossible on Slack — even when another bot explicitly @mentions the Hermes bot, the message is silently dropped.

Discord already solved this

The Discord adapter (gateway/platforms/discord.py, lines 539-551) has a DISCORD_ALLOW_BOTS env var with three modes:

  • "none" — ignore all other bots (default)
  • "mentions" — accept bot messages only when they @mention us
  • "all" — accept all bot messages
if getattr(message.author, "bot", False):
    allow_bots = os.getenv("DISCORD_ALLOW_BOTS", "none").lower().strip()
    if allow_bots == "none":
        return
    elif allow_bots == "mentions":
        if not self._client.user or self._client.user not in message.mentions:
            return
    # "all" falls through to handle_message

Requested change

Add an equivalent SLACK_ALLOW_BOTS env var to the Slack adapter with the same three modes (none / mentions / all), defaulting to "none" for backward compatibility.

The implementation would replace the current hard filter with:

if event.get("bot_id") or event.get("subtype") == "bot_message":
    allow_bots = os.getenv("SLACK_ALLOW_BOTS", "none").lower().strip()
    if allow_bots == "none":
        return
    elif allow_bots == "mentions":
        bot_user_id = getattr(self, "_bot_user_id", "")
        if bot_user_id and f"<@{bot_user_id}>" not in text:
            return
    # "all" falls through
    # Still ignore our own messages
    if event.get("bot_id") == getattr(self, "_bot_id", None):
        return

Note: The self-message guard should remain to prevent echo loops regardless of mode.

Use case

Multi-agent setups where different AI agents (running on different platforms/frameworks) coexist in the same Slack workspace and need to communicate via @mentions. Without this, Slack is the only platform where bot-to-bot handoffs are impossible.

Additional context

The SLACK_ALLOWED_USERS allowlist may also need consideration — bot user IDs should either be exempt from this check when SLACK_ALLOW_BOTS is set, or documentated as needing to be added to the allowlist separately.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions