Skip to content

API Reference parrot.integrations.slack.commands

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.integrations.slack.commands

View source

Slack command routing infrastructure (FEAT-225).

Provides SlackCommandRouter, a simple registry that decouples slash-command dispatch from SlackAgentWrapper and SlackSocketHandler.

Usage::

from parrot.integrations.slack.commands import SlackCommandRouter
from parrot.integrations.slack.commands.jira_commands import register_jira_commands

router = SlackCommandRouter()
register_jira_commands(router, oauth_manager)

# In the command handler:
result = await router.dispatch("connect_jira", payload)
if result is not None:
    return web.json_response(result)

Class SlackCommandRouter

Routes slash commands to registered async handler functions.

Each command is registered under a normalized name (the text that follows the slash, without the / prefix, e.g. "connect_jira"). dispatch looks up the handler and calls it with the slash-command payload dict. If no handler is registered for the command, it returns None so the caller can fall through to the next handler.

Example::

router = SlackCommandRouter()
router.register("ping", my_ping_handler)
result = await router.dispatch("ping", payload)
# result is the return value of my_ping_handler, or None

Attributes:

Attribute Type Description
registered_commands list[str] Return the list of registered command names (without /).

Method SlackCommandRouter.register

Register a handler for command.

register(command: str, handler: Callable) -> None

Parameter Type Default Description
command str The slash-command name, with or without a leading / (e.g. "connect_jira" or "/connect_jira").
handler Callable An async callable with the signature async (payload: dict) -> dict | None.

Method SlackCommandRouter.dispatch

Dispatch command to its registered handler.

dispatch(command: str, payload: Dict[str, Any]) -> Optional[Dict[str, Any]]

Parameter Type Default Description
command str The slash-command name (with or without /).
payload Dict[str, Any] The Slack slash-command POST data as a dict.

Returns: Optional[Dict[str, Any]] — The handler's return value (typically an ephemeral response dict), or None if no handler is registered for command.

Attribute logger

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally