Implementation:OpenHands OpenHands SlackManager
| Knowledge Sources | |
|---|---|
| Domains | Platform_Integration, Slack |
| Last Updated | 2026-02-11 21:00 GMT |
Overview
Orchestrates Slack integration by handling user authentication, repository inference from messages, and conversation creation via the Slack SDK.
Description
SlackManager extends the base Manager class to manage the Slack bot integration. It authenticates Slack users against Keycloak records, infers repository names from natural language messages using regex patterns, generates Slack Block Kit repository selection forms for ambiguous matches, and manages multi-turn conversations. It uses SlackFactory to create appropriate view objects for conversation creation.
Usage
Use this class when processing incoming Slack events (app mentions, messages). It handles the complete flow from user authentication through repository selection and conversation creation.
Code Reference
Source Location
- Repository: OpenHands
- File: enterprise/integrations/slack/slack_manager.py
- Lines: 1-376
Signature
class SlackManager(Manager):
def __init__(self, token_manager: TokenManager): ...
async def authenticate_user(
self, slack_user_id: str
) -> tuple[SlackUser | None, UserAuth | None]: ...
def _infer_repo_from_message(self, user_msg: str) -> str | None: ...
async def _get_repositories(self, user_auth: UserAuth) -> list[Repository]: ...
def _generate_repo_selection_form(
self, repo_list, message_ts, thread_ts
) -> list[dict]: ...
def filter_potential_repos_by_user_msg(
self, user_msg: str, user_repos
) -> tuple[bool, list[Repository]]: ...
async def receive_message(self, message: Message) -> None: ...
async def send_message(
self, channel_id, text, blocks=None, ephemeral=False
) -> None: ...
Import
from enterprise.integrations.slack.slack_manager import SlackManager
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| token_manager | TokenManager | Yes | Manages authentication tokens |
| slack_user_id | str | Yes | Slack user identifier |
| message | Message | Yes | Incoming Slack message object |
| user_msg | str | Yes | Raw message text from Slack |
Outputs
| Name | Type | Description |
|---|---|---|
| authenticate_user() | tuple[SlackUser, UserAuth] | Slack user and auth records |
| _infer_repo_from_message() | str or None | Inferred repository name from message text |
| _generate_repo_selection_form() | list[dict] | Slack Block Kit blocks for repo selection |
Usage Examples
from enterprise.integrations.slack.slack_manager import SlackManager
manager = SlackManager(token_manager=token_mgr)
# Process incoming Slack event
await manager.receive_message(message=slack_message)
# Send response to Slack channel
await manager.send_message(
channel_id="C12345",
text="Working on it!",
blocks=None,
)